-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_sidebars.sh
More file actions
executable file
·19 lines (17 loc) · 1.03 KB
/
generate_sidebars.sh
File metadata and controls
executable file
·19 lines (17 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env bash
rm -rf ./static/temp/*.json
find docs/ -name "_sidebar.json" | while IFS= read -r NAME; do
actualPath="${NAME/\/\///}"
fullPath="${actualPath/docs\//}"
relativePath="${fullPath/_sidebar.json/}"
noSlashRelativePath="${relativePath%/}"
tempFilePath="./static/temp/${NAME//\//_}"
jq --arg relativePath "${relativePath}" --arg noSlashRelativePath "${noSlashRelativePath}" '(.. | .id?) |= if . then $relativePath + . else empty end | (.. | .items?) |= if . then (.[] |= if type=="string" then $relativePath + . else . end) else empty end | (.. | objects | select(.type=="autogenerated")) |= if . then { "type": "autogenerated", "dirName": $noSlashRelativePath } else empty end' ${actualPath} > ${tempFilePath}
done
jq -rs 'reduce .[] as $item ({}; . * $item)' ./static/temp/*.json > ./static/combined_sidebars.json
cat > ./sidebars.js <<EOF
module.exports = $(<./static/combined_sidebars.json)
EOF
rm -rf ./static/temp/*.json
rm ./static/combined_sidebars.json
echo "workshop.amorphicdata.io" > ./static/CNAME