alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

genpage (999B) [raw]


      1 #!/bin/sh
      2 # nihdoc -> html with header and footer
      3 
      4 [ -z "$1" ] && echo "usage: genpage FILE" 1>&2 && exit 1
      5 
      6 REPO=$(dirname "$(dirname "$0")")
      7 GITDIR=${GITDIR:-$REPO}
      8 title=$(grep '^# ' "$1" | cut -c3- | tr -d '`*_')
      9 
     10 cat <<EOM
     11 <!DOCTYPE html>
     12 <html lang="en">
     13 <head>
     14 <meta charset="utf-8"/>
     15 <meta name="viewport" content="width=device-width,initial-scale=1">
     16 <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
     17 <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
     18 <!-- Inspired by https://www.swyx.io/css-100-bytes/ -->
     19 <style>
     20 EOM
     21 cat "$REPO/www/style.css"
     22 cat <<EOM
     23 </style>
     24 <title>$title | alexkarle.com</title>
     25 </head>
     26 <body>
     27 <nav>
     28 <a href="/">Home</a> |
     29 <a href="/blog">Blog</a> |
     30 <a href="/license.html">License</a>
     31 </nav>
     32 EOM
     33 
     34 nihdoc < "$1"
     35 
     36 if echo "$1" | grep -q -v "blog/"; then
     37 	cat <<EOM
     38 <footer>
     39 <br>
     40 <em>Last Updated: $(git -C "$GITDIR" log --pretty="%cs" -n 1 -- "$1")</em>
     41 </footer>
     42 </body>
     43 </html>
     44 EOM
     45 fi
     46 
     47 cat <<EOM
     48 </body>
     49 </html>
     50 EOM