#!/bin/sh set -eu SRC=pages OUT=public cd "$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" [ -f "$SRC/index.md" ]||{ echo "error: $SRC/index.md not found" >&2;exit 1; } [ -f scripts/md2html ]||{ echo "error: scripts/md2html not found" >&2;exit 1; } [ -f scripts/rblxscrapper.sh ]||{ echo "error: scripts/rblxscrapper.sh not found" >&2;exit 1; } title(){ awk 'NR==1&&$0=="---"{f=1;next} f&&/^title:[[:space:]]*/{sub(/^title:[[:space:]]*/,"");print;exit} f&&$0=="---"{exit}' "$1"; } build(){ src=$1 dest=$2 base=$3 url=$4 name=$(title "$src");[ -n "$name" ]||name="casz's house :3" mkdir -p "$(dirname "$dest")" { cat < $name
' sh scripts/md2html "$src" printf '%s\n' '
' }>"$dest" } rm -rf "$OUT";mkdir -p "$OUT" [ -f assets/rblxstats.md ]&& export $(sh scripts/rblxscrapper.sh assets/rblxstats.md) build "$SRC/index.md" "$OUT/index.html" ./ / find "$SRC" -type f -name index.md|sort|while IFS= read -r src;do [ "$src" = "$SRC/index.md" ]&&continue dir=${src#"$SRC"/};dir=${dir%/index.md};depth=$(printf '%s\n' "$dir"|awk -F/ '{print NF}') base=./;i=0 while [ "$i" -lt "$depth" ];do base=../$base;i=$((i+1));done build "$src" "$OUT/$dir/index.html" "$base" "/$dir/" done cp style.css colors.css "$OUT" [ -d fonts ]&&cp -R fonts "$OUT/fonts" [ -f favicon.ico ]&&cp favicon.ico "$OUT/favicon.ico" [ -f assets/favicon.ico ]&&cp assets/favicon.ico "$OUT/favicon.ico" [ -f gen.sh ]&&cp gen.sh "$OUT/gen.sh" [ -f casz.asc ]&&cp casz.asc "$OUT/casz.asc" [ -f scripts/stats.js ]&&cp scripts/stats.js "$OUT/stats.js" [ -f assets/rblxstats.md ]&& grep '^[[:space:]]*$//' >"$OUT/rblx-universes.txt" touch "$OUT/.nojekyll" printf '%s\n' "Build complete."