Skip to content

Commit

Permalink
add /map
Browse files Browse the repository at this point in the history
  • Loading branch information
couleurm committed Feb 24, 2024
1 parent d931a2f commit d80dbb3
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
58 changes: 58 additions & 0 deletions buildMap.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d80dbb3

Please sign in to comment.