blob: cf1009dac49bbc0039cfc20139166548a671cff3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/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 "<!doctype html>
<html lang="fr">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/main.css">
<link rel="icon" href="/icon.png">
<script src="/main.js"></script>
<title>Recettes</title>
<header>Recettes</header>" > public/index.html
function section {
SECTION_TITLE="$1"
RECIPE_PATH="$2"
echo "<h1>$SECTION_TITLE</h1><ul>" >> public/index.html
for RECIPE in $RECIPE_PATH; do
TITLE=$(cat "$RECIPE" | head -n 1)
echo "<li><a href="${RECIPE%.md}.html">${TITLE:2}</a>" >> public/index.html
done
echo "</ul>" >> 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!"
|