web

A collection of scripts used to generate this website
git clone https://erai.gay/code/web/
Log | Files | Refs | LICENSE

render.sh (1782B)


      1 #!/bin/bash
      2 
      3 set -ue
      4 
      5 if [ $# -ne 1 ]; then
      6   echo "usage: ./render.sh <page.html>" >&2
      7   exit 1
      8 fi
      9 
     10 title="Untitled"
     11 thumbnail="https://omiltem.net/about/pfp.jpg"
     12 description=""
     13 copyright="2024"
     14 canonical="$(echo "https://omiltem.net/$1" | sed -e 's/\/index.html$/\//')"
     15 
     16 eval "$(sed -e '/^$/,$d' "$1")"
     17 
     18 if [ -z "${description}" ]; then
     19   echo "error: no description" >&2
     20   exit 1
     21 fi
     22 
     23 cat << EOF
     24 <!DOCTYPE html>
     25 <html lang="en">
     26 <!--
     27 $(cat LICENSE)
     28 -->
     29   <head>
     30     <title>${title} &mdash; Omiltem</title>
     31     <meta charset="utf-8">
     32     <meta name="viewport" content="width=device-width, initial-scale=1">
     33     <meta name="twitter:card" content="summary">
     34     <meta name="twitter:site" content="@erai271">
     35     <meta property="og:image" content="${thumbnail}">
     36     <meta property="og:type" content="article">
     37     <meta property="og:title" content="${title}">
     38     <meta property="og:description" content="${description}">
     39     <meta name="description" content="${description}">
     40     <link rel="canonical" href="${canonical}">
     41     <link rel="shortcut icon" type="image/png" href="data:image/png;base64,$(base64 < favicon.png | tr -d '\n')">
     42     <style>$(cat css/style.css)</style>
     43 $(sed -ne '/<head>/,/<\/head>/p' "$1" | sed -e '1d;$d')
     44   </head>
     45   <body>
     46     <header>
     47       <p class="title">Omiltem</p>
     48       <nav>
     49         <ul class="links">
     50           <li><a href="/">HOME</a></li>
     51           <li><a href="https://github.com/erai271">CODE</a></li>
     52           <li><a href="/about/">ABOUT</a></li>
     53         </ul>
     54       </nav>
     55     </header>
     56     <main>
     57       <article>
     58         <header>
     59           <h1>${title}</h1>
     60         </header>
     61 $(sed -e '1,/^$/d' -e '/<head>/,/<\/head>/d' "$1")
     62       </article>
     63     </main>
     64     <footer>
     65       &copy; ${copyright} erai
     66     </footer>
     67   </body>
     68 </html>
     69 EOF