Reutilizar código de markdown en index
All checks were successful
continuous-integration/woodpecker the build was successful

This commit is contained in:
Cat /dev/Nulo 2021-10-11 16:27:56 -03:00
parent d74c32321b
commit 34d9d8134f

View file

@ -18,6 +18,13 @@ template () {
fi
}
markdown () {
# TODO: hacky
cmark --unsafe "$1" \
| sed "s/<a /<a rel='noopener noreferrer' /gi" \
| sed 's/\[\[\(.*\)\]\]/<a href="\1.html">\1<\/a>/g'
}
outdir=build
mkdir -p $outdir
# Autocopiarnos :)
@ -25,7 +32,7 @@ cp ./*.sh ./*.md ./*.css ./*.png ./*.mp4 "$outdir"
index="$outdir/index.html"
inicio=true header=false template "nulo.in" > "$index"
cmark --unsafe index.md >> "$index"
markdown index.md >> "$index"
echo "<h2>Lista de páginas</h2><ul>" >> "$index"
for file in *.md; do
@ -33,10 +40,7 @@ for file in *.md; do
title="$(basename "$file" .md)"
outfile="$outdir/$title.html"
template "$title" "$file" > "$outfile"
cmark --unsafe "$file" >> "$outfile"
# TODO: hacky
sed -i "s/<a /<a rel='noopener noreferrer' /gi" "$outfile"
sed -i 's/\[\[\(.*\)\]\]/<a href="\1.html">\1<\/a>/g' "$outfile"
markdown "$file" >> "$outfile"
echo "<li><a href='$title.html'>$title</a></li>" >> "$index"
done