hsmwebsite/build.sh

17 lines
669 B
Bash
Raw Normal View History

2024-11-17 23:06:42 +01:00
#!/bin/bash
source_to_target() { sed -E -e 's:\.\./src/:\./:' -e 's/.md$/.html/'; }
shopt -s globstar
rm -rf dist/
mkdir dist&&cd dist
cp ../style.css .
for file in $(du -a ../src/ | cut -f2 | grep -E '.md$'); do
target="$(echo $file | source_to_target)"
2024-11-19 22:51:41 +01:00
export CONTENT="$(pandoc --from markdown+emoji --wrap=none -i $file)"
export PREFIX=$(realpath --relative-to $(dirname $target) .)
export SIDEBAR=$(for x in ../src/**/*.md; do echo "<li><a href=\"$(echo $PREFIX/$x | source_to_target)\">$(realpath --relative-to ../src/ $x | sed -e 's/.md$//')</a></li>"; done)
2024-11-17 23:06:42 +01:00
mkdir -p $(dirname $target)
2024-11-19 22:51:41 +01:00
cat ../template.tpl | awk -f ../template.awk | bash > $target
2024-11-17 23:06:42 +01:00
done