alexkarle.com

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

genpage (1182B) [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 title=$(grep '^# ' "$1" | cut -c3- | tr -d '`*_')
      8 
      9 cat <<EOM
     10 <!DOCTYPE html>
     11 <html lang="en">
     12 <head>
     13 <meta charset="utf-8"/>
     14 <meta name="viewport" content="width=device-width,initial-scale=1">
     15 <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
     16 <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
     17 <!-- Inspired by https://www.swyx.io/css-100-bytes/ -->
     18 <style>
     19 html {
     20   max-width: 70ch;
     21   padding: 3em 1em;
     22   margin: auto;
     23   font-size: 1em;
     24   font-family: sans-serif;
     25 }
     26 footer {
     27   margin-top: 50px;
     28   font-size: .8em;
     29 }
     30 code { font-family: consolas, courier, monospace; }
     31 h1 { font-size: 1.5em; }
     32 h2 { font-size: 1.2em; }
     33 h3 { font-size: 1.1em; }
     34 blockquote, pre {
     35   background: #f2f2f2;
     36   overflow: auto;
     37   padding: 10px;
     38   border: 2px solid black;
     39 }
     40 </style>
     41 <title>$title</title>
     42 </head>
     43 <body>
     44 EOM
     45 
     46 
     47 "$REPO/bin/gencrumbs" "${1%%txt}html"
     48 nihdoc < "$1"
     49 
     50 cat <<EOM
     51 <footer>
     52   © 2019-2022 Alex Karle | <a href="/">Home</a> | <a href="/license.html">License</a>
     53 </footer>
     54 </body>
     55 </html>
     56 EOM