Skip to content

Commit d2b775e

Browse files
committed
Generate index.md from the project root readme
1 parent 152da8d commit d2b775e

2 files changed

Lines changed: 18 additions & 39 deletions

File tree

Pipelines/Scripts/prepare-pages.ps1

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ param(
1111
)
1212

1313
$ProjectRoot = Resolve-Path -Path $ProjectRoot
14+
$docs = Join-Path $ProjectRoot "docs"
15+
16+
$indexDestination = Join-Path $docs "index.md"
17+
# Create home page, add front matter, and copy content
18+
New-Item -Path $indexDestination -Value @"
19+
---
20+
title: Home
21+
---
22+
23+
24+
"@
25+
Add-Content -Path $indexDestination -Value (Get-Content -Path (Join-Path $ProjectRoot "README.md"))
1426

1527
# Loop through package directories and copy documentation
1628
Get-ChildItem -Path (Join-Path $ProjectRoot "*" "package.json") | ForEach-Object {
@@ -25,7 +37,8 @@ Get-ChildItem -Path (Join-Path $ProjectRoot "*" "package.json") | ForEach-Object
2537
$packagePath = $_.Directory
2638

2739
# Create README, add front matter, and copy content
28-
New-Item -Path "./$packageName.md" -Value @"
40+
$packageReadmeDestination = Join-Path $docs "$packageName.md"
41+
New-Item -Path $packageReadmeDestination -Value @"
2942
---
3043
title: $packageFriendlyName
3144
parent: Packages
@@ -35,16 +48,17 @@ parent: Packages
3548
"@
3649
$readmeContent = (Get-Content -Path (Join-Path $packagePath "README.md"))
3750
$readmeContent = $readmeContent -replace "> \[!(\w+)\]", { "{: .$("$($_.Groups[1])".ToLower()) }" } # Convert GitHub admonitions to just-the-docs syntax
38-
Add-Content -Path "./$packageName.md" -Value $readmeContent
51+
Add-Content -Path $packageReadmeDestination -Value $readmeContent
3952

4053
# Create CHANGELOG, add front matter, and copy content
41-
New-Item -Path "./$packageName.CHANGELOG.md" -Value @"
54+
$packageChangelogDestination = Join-Path $docs "$packageName.CHANGELOG.md"
55+
New-Item -Path $packageChangelogDestination -Value @"
4256
---
4357
title: Changelog
4458
parent: $packageFriendlyName
4559
---
4660
4761
4862
"@
49-
Add-Content -Path "./$packageName.CHANGELOG.md" -Value (Get-Content -Path (Join-Path $packagePath "CHANGELOG.md"))
63+
Add-Content -Path $packageChangelogDestination -Value (Get-Content -Path (Join-Path $packagePath "CHANGELOG.md"))
5064
}

docs/index.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)