Skip to content

Commit 717163d

Browse files
committed
Convert GitHub admonitions to just-the-docs syntax
1 parent 59d634e commit 717163d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Pipelines/Scripts/prepare-pages.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ nav_order: 1
2828
"@
2929
Add-Content -Path $indexDestination -Value (Get-Content -Path (Join-Path $ProjectRoot "README.md"))
3030

31+
# Convert GitHub admonitions to just-the-docs syntax for in-place docs files
32+
# We leave them checked-in so they render correctly in the GitHub repo, but we convert them for Pages
33+
Get-ChildItem -Path (Join-Path $docs "*" "*.md") -Recurse | ForEach-Object {
34+
$fileContent = Get-Content -Path $_
35+
Set-Content -Path $_ -Value ($fileContent -replace "> \[!(\w+)\]", { "{: .$("$($_.Groups[1])".ToLower()) }" })
36+
}
37+
3138
# Loop through package directories and copy documentation
3239
Get-ChildItem -Path (Join-Path $ProjectRoot "*" "package.json") | ForEach-Object {
3340
$packageName = Select-String -Pattern "org\.mixedrealitytoolkit\.\w+(\.\w+)*" -Path $_ | Select-Object -First 1
@@ -53,9 +60,9 @@ parent: Packages
5360
5461
5562
"@
56-
$readmeContent = (Get-Content -Path (Join-Path $packagePath "README.md"))
57-
$readmeContent = $readmeContent -replace "> \[!(\w+)\]", { "{: .$("$($_.Groups[1])".ToLower()) }" } # Convert GitHub admonitions to just-the-docs syntax
58-
Add-Content -Path $packageReadmeDestination -Value $readmeContent
63+
$readmeContent = Get-Content -Path (Join-Path $packagePath "README.md")
64+
# Convert GitHub admonitions to just-the-docs syntax
65+
Add-Content -Path $packageReadmeDestination -Value ($readmeContent -replace "> \[!(\w+)\]", { "{: .$("$($_.Groups[1])".ToLower()) }" })
5966

6067
# Create CHANGELOG, add front matter, and copy content
6168
$packageChangelogDestination = Join-Path $packageDocsPath "CHANGELOG.md"
@@ -87,6 +94,8 @@ parent: $packageFriendlyName
8794
8895
8996
"@
90-
Add-Content -Path $fileDestination -Value (Get-Content -Path $_)
97+
$fileContent = Get-Content -Path $_
98+
# Convert GitHub admonitions to just-the-docs syntax
99+
Add-Content -Path $fileDestination -Value ($fileContent -replace "> \[!(\w+)\]", { "{: .$("$($_.Groups[1])".ToLower()) }" })
91100
}
92101
}

0 commit comments

Comments
 (0)