~chambln/cosine.blue

df1b8035a4ce0af6ed2d9b0f5b14a17363ea7e49 — Gregory Chamberlain 8 months ago 483994d
Update templating to include title on all pages
3 files changed, 56 insertions(+), 46 deletions(-)

M bin/make
M env/index.html.sh.sh
M share/header.html
M bin/make => bin/make +27 -17
@@ 29,7 29,7 @@ html() {
            echo '<meta name="viewport" content="width=device-width, initial-scale=1">'
            x title "${pagetitle:-$title}"

            [ "${description-}" ] &&
            [ "${description+_}" ] &&
                printf '<meta name="description" content="%s">\n' "$description"

            # Embed CSS directly in the HTML to reduce the number of requests.


@@ 40,28 40,38 @@ html() {
        } | x head
        {
            x small < share/header.html | x header
            x main
            {
                {
                    if [ "${title+_}" ]; then
                        x h1 "$title"
                    fi
                    if [ "${description+_}" ]; then
                        x p "$description"
                    fi
                    if [ "${date+_}" ]; then
                        {
                            x time "$date"
                            [ "${log+_}" ] && printf ' &mdash; <a href="%s">History</a>' "$log"
                        } | x p
                    fi
                    if [ "${cover_img_src+_}" ]; then
                        {
                            # shellcheck disable=SC2154
                            alt=${cover_img_alt:+ alt=\"Cover image: $cover_img_alt\"}
                            x "img src=\"$cover_img_src\"$alt"
                            [ "${cover_img_caption+_}" ] &&
                                x figcaption "$cover_img_caption" | x small
                        } | x figure
                    fi
                } | x header
                cat
            } | x main
            x small < share/footer.html | x footer
        } | x body
    } | x 'html lang="en-GB"'
}

article() {
    :|{
        x h1 "$title"
        [ "${description-}" ] && x p "$description"
        [ "${date-}" ] && {
            x time "$date"
            [ "${log-}" ] && printf ' &mdash; <a href="%s">History</a>' "$log"
        } | x p
        if [ "${cover_img_src-}" ]; then
            # shellcheck disable=SC2154
            alt=${cover_img_alt:+ alt=\"Cover image: $cover_img_alt\"}
            x "img src=\"$cover_img_src\"$alt"
            [ "${cover_img_caption-}" ] &&
                x figcaption "$cover_img_caption" | x small
        fi | x figure
    } | x header
    x article
    x hr
    x p <<EOF

M env/index.html.sh.sh => env/index.html.sh.sh +2 -0
@@ 1,1 1,3 @@
title=Home

pagetitle=cosine.blue

M share/header.html => share/header.html +27 -29
@@ 1,29 1,27 @@
<header>
  <h1><a href="/">cosine.blue</a></h1>
  <p>Blog by Gregory Chamberlain.</p>
  <table>
    <tbody>
      <tr>
        <td>Feed</td>
        <td><a href="/rss.xml" title="Subscribe to cosine.blue via RSS">rss.xml</a></td>
      </tr>
      <tr><td>Email</td><td><a href="mailto:greg@cosine.blue"
                               title="Contact the site author and maintainer">greg@cosine.blue</a></td></tr>
      <tr>
        <td>PGP</td>
        <td>
          <a href="/pubkey-gc.txt"
             title="Save this file as, say, pubkey-gc.txt, then run “gpg --import pubkey-gc.txt”">B271 F6B8 7BBF</a>
        </td>
      </tr>
      <tr>
        <td>Sourcehut</td>
        <td><a href="https://sr.ht/~chambln" title="Source code repositories">~chambln</a></td>
      </tr>
      <tr>
        <td>Mastodon</td>
        <td><a href="https://mastodon.social/@chambln" title="Federated & decentralised microblog">@chambln</a></td>
      </tr>
    </tbody>
  </table>
</header>
<h1><a href="/">cosine.blue</a></h1>
<p>Blog by Gregory Chamberlain.</p>
<table>
  <tbody>
    <tr>
      <td>Feed</td>
      <td><a href="/rss.xml" title="Subscribe to cosine.blue via RSS">rss.xml</a></td>
    </tr>
    <tr><td>Email</td><td><a href="mailto:greg@cosine.blue"
                             title="Contact the site author and maintainer">greg@cosine.blue</a></td></tr>
    <tr>
      <td>PGP</td>
      <td>
        <a href="/pubkey-gc.txt"
           title="Save this file as, say, pubkey-gc.txt, then run “gpg --import pubkey-gc.txt”">B271 F6B8 7BBF</a>
      </td>
    </tr>
    <tr>
      <td>Sourcehut</td>
      <td><a href="https://sr.ht/~chambln" title="Source code repositories">~chambln</a></td>
    </tr>
    <tr>
      <td>Mastodon</td>
      <td><a href="https://mastodon.social/@chambln" title="Federated & decentralised microblog">@chambln</a></td>
    </tr>
  </tbody>
</table>