This repository has been archived on 2024-02-11. You can view files and clone it, but cannot push or open issues or pull requests.
sitio/build.sh

43 lines
1.3 KiB
Bash
Raw Normal View History

2021-10-08 23:36:43 +00:00
#!/bin/sh
template () {
echo -n "<!doctype html>"
echo -n "<meta charset=utf-8>"
2021-10-09 00:00:34 +00:00
echo -n "<meta name=viewport content='width=device-width, initial-scale=1.0'>"
2021-10-08 23:36:43 +00:00
echo -n "<link rel=stylesheet href=drip.css>"
echo -n "<title>$1</title>"
if test "$inicio" != true; then
echo -n "<a href=.>☚ Volver al inicio</a>"
fi
if test -n "$2"; then
echo -n "<header>"
echo -n "<h1>$1</h1>"
echo -n "<p><small>Último cambio: <time datetime='$(git log -1 --format=%ai "$2")'>$(date -d "@$(git log -1 --format=%at "$2")" '+%Y-%m-%d %H:%M')</time></small></p>"
2021-10-08 23:36:43 +00:00
echo -n "</header>"
fi
}
outdir=build
mkdir -p $outdir
# Autocopiarnos :)
2021-10-11 19:09:41 +00:00
cp *.sh *.md *.css *.png *.mp4 "$outdir"
2021-10-08 23:36:43 +00:00
index="$outdir/index.html"
inicio=true header=false template "nulo.in" > "$index"
cmark --unsafe index.md >> "$index"
echo -n "<h2>Lista de páginas</h2><ul>" >> "$index"
for file in *.md; do
test "$(basename "$file")" = index.md && continue
2021-10-08 23:36:43 +00:00
title="$(basename "$file" .md)"
outfile="$outdir/$title.html"
template "$title" "$file" > "$outfile"
2021-10-11 19:10:22 +00:00
cmark --unsafe "$file" >> "$outfile"
2021-10-08 23:36:43 +00:00
# TODO: hacky
sed -i "s/<a /<a rel='noopener noreferrer' /gi" "$outfile"
2021-10-08 23:48:29 +00:00
sed -i 's/\[\[\(.*\)\]\]/<a href="\1.html">\1<\/a>/g' "$outfile"
2021-10-08 23:36:43 +00:00
echo -n "<li><a href='$title.html'>$title</a></li>" >> "$index"
done
echo -n "</ul>" >> "$index"