Skip to content

Commit

Permalink
Check if file is module page by checking yaml metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
arpatward13 committed Jun 15, 2021
1 parent 10a9039 commit daadb2c
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/platyPS/platyPS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1492,18 +1492,8 @@ function GetMarkdownFilesFromPath
[switch]$IncludeModulePage
)

if ($IncludeModulePage)
{
$filter = '*.md'
}
else
{
$filter = '*-*.md'
}

$aboutFilePrefixPattern = 'about_*'


$MarkdownFiles = @()
if ($Path) {
$Path | ForEach-Object {
Expand All @@ -1516,7 +1506,16 @@ function GetMarkdownFilesFromPath
}
elseif (Test-Path -PathType Container $_)
{
$MarkdownFiles += Get-ChildItem $_ -Filter $filter | Where-Object {$_.BaseName -notlike $aboutFilePrefixPattern}
$MarkdownFiles += Get-ChildItem $_ -File | ForEach-Object {
$md = Get-Content -Raw -Path $_
$yml = [Markdown.MAML.Parser.MarkdownParser]::GetYamlMetadata($md)
$isModulePage = $null -ne $yml.'Module Guid'

if ($IncludeModulePage -and $isModulePage -or -not $isModulePage -and -not $IncludeModulePage)
{
$_ | Where-Object {$_.BaseName -notlike $aboutFilePrefixPattern}
}
}
}
else
{
Expand Down

0 comments on commit daadb2c

Please sign in to comment.