blob: 0ac8175e62d7dd2fa13c93a1373178d91ff89a11 (
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
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/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
|