use markdown(1) and cat(1) to build the html

* add an empty footer
    * add a minimal html header
    * indent the nav
    * modify the build process (publish.sh):
      * use a tmp directory
      * use discount markdown(1) rather than discount mkd2html(1)
      * generate html page title from the file name
      * indent html body
      * use cat(1) to combine the pieces
    * remove trailing newlines in publish.sh
    * git ignore tmp/ directory
This commit is contained in:
sceox 2020-09-14 10:16:48 -07:00
parent fca71a607c
commit fedb059fdb
6 changed files with 29 additions and 13 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
tmp

2
foot.html Normal file
View File

@ -0,0 +1,2 @@
<footer>
</footer>

5
head.html Normal file
View File

@ -0,0 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">

View File

@ -1,6 +1,6 @@
<nav>
<a href="/index.html">home</a>
<a href="/projects.html">projects</a>
<a href="/webring.html">webring</a>
<a href="/contact.html">contact</a>
</nav>
<nav>
<a href="/index.html">home</a>
<a href="/projects.html">projects</a>
<a href="/webring.html">webring</a>
<a href="/contact.html">contact</a>
</nav>

View File

@ -3,15 +3,21 @@
PUB_DIR=${1:-/home/html/planet/static}
FILES=md/*.md
test -d tmp || mkdir tmp
for f in $FILES
do
filename=$(basename -- $f .md)
echo "publishing md/$filename.md to $PUB_DIR/$filename.html"
mkd2html -css style.css $f
mv md/*.html $PUB_DIR
# TODO insert nav before <body> tag
# sed '/<body>/e cat nav.html' html/$filename.html
markdown -o tmp/$filename.html $f
sed -i 's/^/ /' tmp/$filename.html
cp head.html tmp/
# set the title
title="$(echo $filename | awk '{for(i=1;i<=NF;i++){ $i=toupper(substr($i,1,1)) substr($i,2) }}1')"
echo " <title>$title • Anarchy Planet</title>" >> tmp/head.html
echo " </head>" >> tmp/head.html
echo " <body>" >> tmp/head.html
# compile the elements in order
cat tmp/head.html nav.html tmp/$filename.html foot.html tail.html \
> $PUB_DIR/$filename.html
done

2
tail.html Normal file
View File

@ -0,0 +1,2 @@
</body>
</html>