Files
EarthborneTrailerblazer/ET/Web/SyncDocs.ps1
T
2026-06-10 21:31:37 -04:00

25 lines
863 B
PowerShell

$src = Resolve-Path "$PSScriptRoot\..\..\docs\Notes"
$dst = "$PSScriptRoot\wwwroot\docs\notes"
if (Test-Path $dst) { Remove-Item "$dst\*" -Force -ErrorAction SilentlyContinue }
New-Item -ItemType Directory -Path $dst -Force | Out-Null
$entries = @()
Get-ChildItem -Path $src -Filter "*.md" | ForEach-Object {
$base = $_.BaseName
$slug = $base.ToLowerInvariant()
$slug = $slug -replace "'", ""
$slug = $slug -replace "\.", ""
$slug = $slug -replace "[^a-z0-9 -]", ""
$slug = $slug -replace "\s+", "-"
$slug = $slug -replace "-+", "-"
$slug = $slug.Trim('-')
Copy-Item $_.FullName (Join-Path $dst "$slug.md")
$entries += @{ slug = $slug; title = $base }
}
$indexPath = "$PSScriptRoot\wwwroot\docs\notes-index.json"
$index = @{ notes = $entries } | ConvertTo-Json
Set-Content -Path $indexPath -Value $index -Encoding UTF8