Skip to content

Commit 8d2365d

Browse files
Check if file is module page by checking yaml metadata
1 parent 10a9039 commit 8d2365d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/platyPS/platyPS.psm1

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,18 +1492,8 @@ function GetMarkdownFilesFromPath
14921492
[switch]$IncludeModulePage
14931493
)
14941494

1495-
if ($IncludeModulePage)
1496-
{
1497-
$filter = '*.md'
1498-
}
1499-
else
1500-
{
1501-
$filter = '*-*.md'
1502-
}
1503-
15041495
$aboutFilePrefixPattern = 'about_*'
15051496

1506-
15071497
$MarkdownFiles = @()
15081498
if ($Path) {
15091499
$Path | ForEach-Object {
@@ -1516,7 +1506,16 @@ function GetMarkdownFilesFromPath
15161506
}
15171507
elseif (Test-Path -PathType Container $_)
15181508
{
1519-
$MarkdownFiles += Get-ChildItem $_ -Filter $filter | Where-Object {$_.BaseName -notlike $aboutFilePrefixPattern}
1509+
$MarkdownFiles += Get-ChildItem $_ -File | ForEach-Object {
1510+
$md = Get-Content -Raw -Path $_
1511+
$yml = [Markdown.MAML.Parser.MarkdownParser]::GetYamlMetadata($md)
1512+
$isModulePage = $null -ne $yml.'Module Guid'
1513+
1514+
if ($IncludeModulePage -and $isModulePage -or -not $isModulePage -and -not $IncludeModulePage)
1515+
{
1516+
$_ | Where-Object {$_.BaseName -notlike $aboutFilePrefixPattern}
1517+
}
1518+
}
15201519
}
15211520
else
15221521
{

0 commit comments

Comments
 (0)