Skip to content

Commit 42571c2

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

2 files changed

Lines changed: 21 additions & 39 deletions

File tree

Pipelines/Scripts/prepare-pages.ps1

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

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

1530
# Loop through package directories and copy documentation
1631
Get-ChildItem -Path (Join-Path $ProjectRoot "*" "package.json") | ForEach-Object {
@@ -25,7 +40,8 @@ Get-ChildItem -Path (Join-Path $ProjectRoot "*" "package.json") | ForEach-Object
2540
$packagePath = $_.Directory
2641

2742
# Create README, add front matter, and copy content
28-
New-Item -Path "./$packageName.md" -Value @"
43+
$packageReadmeDestination = Join-Path $docs "$packageName.md"
44+
New-Item -Path $packageReadmeDestination -Value @"
2945
---
3046
title: $packageFriendlyName
3147
parent: Packages
@@ -35,16 +51,17 @@ parent: Packages
3551
"@
3652
$readmeContent = (Get-Content -Path (Join-Path $packagePath "README.md"))
3753
$readmeContent = $readmeContent -replace "> \[!(\w+)\]", { "{: .$("$($_.Groups[1])".ToLower()) }" } # Convert GitHub admonitions to just-the-docs syntax
38-
Add-Content -Path "./$packageName.md" -Value $readmeContent
54+
Add-Content -Path $packageReadmeDestination -Value $readmeContent
3955

4056
# Create CHANGELOG, add front matter, and copy content
41-
New-Item -Path "./$packageName.CHANGELOG.md" -Value @"
57+
$packageChangelogDestination = Join-Path $docs "$packageName.CHANGELOG.md"
58+
New-Item -Path $packageChangelogDestination -Value @"
4259
---
4360
title: Changelog
4461
parent: $packageFriendlyName
4562
---
4663
4764
4865
"@
49-
Add-Content -Path "./$packageName.CHANGELOG.md" -Value (Get-Content -Path (Join-Path $packagePath "CHANGELOG.md"))
66+
Add-Content -Path $packageChangelogDestination -Value (Get-Content -Path (Join-Path $packagePath "CHANGELOG.md"))
5067
}

docs/index.md

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

0 commit comments

Comments
 (0)