-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·52 lines (44 loc) · 1.31 KB
/
build
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
47
48
49
50
51
52
#!/bin/bash
set -euo pipefail
outd="dist"
contentsmdf="$outd/innehåll.md"
cd "${0%/*}"
datadir="$(pwd)"
rm -rf "$outd"
mkdir -p "$outd"
cp -af images "$outd/"
pandoc() {
command pandoc --standalone --from=markdown-tex_math_dollars --to=html5 --data-dir="$datadir" \
-M fontsize=18px \
-M linestretch=1.6 \
-M fontcolor=#191919 \
-M linkcolor=#191959 \
-M backgroundcolor=#fafafa \
-M title-suffix="Pjodds wiki" \
--include-after-body footer.html \
--lua-filter filters.lua \
"$@"
}
# we skip some pages that never were linked from other pages, or publicly
skipcontents=()
while IFS= read -r target; do
skipcontents+=("$target")
done <skipcontents.txt
touch "$contentsmdf"
for mdf in pages/*.md; do
outf="${mdf%.md}.html"
outf="$outd/${outf#pages/}"
pandoc -M build_showedit=true >"$outf" "$mdf"
printf "wrote %s\n" "$outf"
title="$(sed -n "s/^title: \(.*\)/\1/p" "$mdf" | head -n1)"
target="${outf##*/}"
[[ " ${skipcontents[*]} " =~ \ $target\ ]] && continue
[[ "$target" = "index.html" ]] && target="/"
printf >>"$contentsmdf" -- "- [%s](%s)\n" "$title" "$target"
done
outf="${contentsmdf%.md}.html"
{
printf -- "---\ntitle: Innehåll\n---\n\n"
sort "$contentsmdf"
} | pandoc >"$outf" -
printf "wrote %s\n" "$outf"