diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8baaae..469f2a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: run: | $env:YES_MAKE_TONS_OF_FOLDERS=1 ./redirector.ps1 + ./buildMap.ps1 - run: pip install -r requirements.txt - run: mkdocs gh-deploy --force -f mkdocs.github.yml diff --git a/buildMap.ps1 b/buildMap.ps1 new file mode 100644 index 0000000..305f265 --- /dev/null +++ b/buildMap.ps1 @@ -0,0 +1,58 @@ +Set-Location $PSScriptRoot + +if (-not(Get-Command ConvertFrom-Yaml -ErrorAction Ignore)) { + Install-Module -Name powershell-yaml -Force +} + +[Hashtable[]]$nav = (Get-Content .\mkdocs.yml | ConvertFrom-Yaml).nav + +function Display ([Hashtable]$Table, [int32]$Depth) { + $str = '#' * $depth + ' ' + $depth++ + + foreach ($item in $table.GetEnumerator()) { + + # Wait-Debugger + if ($item.value.keys.length -gt 1) { + $link = if (-not($item.value.index)) { + $item.value | Where-Object { $_ -is [string] } + } + else { + $item.value.index + } + write-output ("`n`n" + $str + '[' + $item.name + "](https://ctt.cx/$link)`n") + } + if ($item.value -is [string]) { + write-output ($str + '[' + $item.name + "](https://ctt.cx/$($item.value))") + } + foreach ($nesteditems in $item.value) { + if ($nesteditems -is [string]) { continue } + Display $nesteditems $depth + } + } +} +$depth = 1 +$ret = foreach ($category in $nav) { + + display $category $depth + +} + +Set-Content ./map.md -Value @' +# [CTT.cx](https://cttt.cx) +'@ +$ret -replace '#', '##' -replace "\.md" -replace "/index" | Add-Content ./map.md + + +if (-not(Test-Path ./map)) { + mkdir map | out-null +} + +if (-not(Get-Command markmap -ErrorAction Ignore)) { + + npm install -g markmap-cli +} + +markmap ./map.md --offline --no-toolbar --no-open -o ./map/index.html + +remove-item ./map.md \ No newline at end of file