#!/bin/sh -e rm -rf public mkdir -p public if [ ! -f md2html.sh ]; then curl -LO https://codeberg.org/emmett1/md2html/raw/branch/main/md2html.sh || { rm -f md2html.sh; exit 1; } fi chmod +x md2html.sh for i in $(find . -type f -name "*.html" | sed 's|^\./||'); do dir=${i%/*} file=${i##*/} title=${dir##*/} [ "$dir" = "$file" ] && { title=home; dir= } mkdir -p public/$dir echo "copy html for $i..." { sed "s/@TITLE@/$title/g" header cat $i cat footer } > public/$dir/$file done # docs cat docs/header > docs/index.md for f in docs/*.md; do case $f in */index.md) continue;; esac title=$(head -n1 $f) file=${f##*/} echo "- [$title](./${file%.md}.html)" >> docs/index.md done for i in $(find . -type f -name "*.md" | sed 's|^\./||'); do dir=${i%/*} file=${i##*/} title=${dir##*/} [ "$dir" = "$file" ] && { title=home; dir= } mkdir -p public/$dir echo "generating html for $i..." { sed "s/@TITLE@/$title/g" header ./md2html.sh $i cat footer } > public/$dir/${file%.md}.html done rm -f docs/index.md if [ -d assets ]; then cp -ra assets public/ fi exit 0