Types/OpenPackage/get_Includes.ps1

<#
.SYNOPSIS
    Gets Open Package Includes
.DESCRIPTION
    Gets any `_includes` files within an Open Package.

    If the include file type has a reader, will read the content.

    If the include file type does not have a reader, will include the part.
.NOTES
    Returns all includes as a dictionary.
#>

if (-not $this.GetParts) { return }

$includes = [Ordered]@{}

foreach ($part in $this.GetParts()) {
    if ($part.Uri -notmatch '/_includes/') {
        continue
    }

    $includeKey = $part.Uri -replace '.{0,}?/_includes/'
    if ($part.Reader) {
        $includes[$includeKey] = $part.Read()
    } else {
        $includes[$includeKey] = $part
    }
}

return $includes