#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
echo "Building HTML files…"
for RECIPE in recettes/**/*.md; do
OUT="public/${RECIPE%.md}.html"
mkdir -p "$(dirname "$OUT")"
pandoc "$RECIPE" --template=template.html -o "$OUT"
done
echo "Building index…"
echo "
Recettes
" > public/index.html
function section {
SECTION_TITLE="$1"
RECIPE_PATH="$2"
echo "$SECTION_TITLE
" >> public/index.html
for RECIPE in $RECIPE_PATH; do
TITLE=$(cat "$RECIPE" | head -n 1)
echo "- ${TITLE:2}" >> public/index.html
done
echo "
" >> public/index.html
}
section "Plats" "recettes/plat/*.md"
section "Desserts" "recettes/dessert/*.md"
section "Pains" "recettes/pain/*.md"
section "Nettoyage" "recettes/nettoyage/*.md"
section "Conservation" "recettes/conservation/*.md"
echo "Done!"