about summary refs log tree commit diff
path: root/web/blog/fragments.nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-11-02T13·34+0100
committertazjin <mail@tazj.in>2021-11-03T15·43+0000
commitbbf92dcdeaaf8bd8ab43fdd167f0709bb8840eb6 (patch)
treea5ba8f5323b144b051a2ac16868854cfd6477b22 /web/blog/fragments.nix
parente99d8510d7f8d47cbf6217b2b6c7cd64d9457570 (diff)
refactor(web/blog): Configurable blog name and footer r/2998
Required for actually using this generically for the TVL blog.

Change-Id: I92d8d10341f9ab4f92c90f7976be261b3255a0f0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3768
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'web/blog/fragments.nix')
-rw-r--r--web/blog/fragments.nix30
1 files changed, 11 insertions, 19 deletions
diff --git a/web/blog/fragments.nix b/web/blog/fragments.nix
index eb46a09fd044..56e603905d03 100644
--- a/web/blog/fragments.nix
+++ b/web/blog/fragments.nix
@@ -4,9 +4,6 @@
 #
 # An entire post is rendered by `renderPost`, which assembles the
 # fragments together in a runCommand execution.
-#
-# The post index is generated by //users/tazjin/homepage, not by this
-# code.
 { depot, lib, pkgs, ... }:
 
 let
@@ -20,33 +17,28 @@ let
 
   escape = replaceStrings [ "<" ">" "&" "'" ] [ "&lt;" "&gt;" "&amp;" "&#39;" ];
 
-  header = title: ''
+  header = name: title: ''
   <!DOCTYPE html>
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1">
-    <meta name="description" content="tazjin&#39;s blog">
+    <meta name="description" content="${escape name}">
     <link rel="stylesheet" type="text/css" href="/static/tvl.css" media="all">
     <link rel="icon" type="image/webp" href="/static/favicon.webp">
     <link rel="alternate" type="application/atom+xml" title="Atom Feed" href="/feed.atom">
-    <title>tazjin&#39;s blog: ${escape title}</title>
+    <title>${escape name}: ${escape title}</title>
   </head>
   <body class="light">
     <header>
-      <h1><a class="blog-title" href="/">tazjin&#39;s interblag</a> </h1>
+      <h1><a class="blog-title" href="/">${escape name}</a> </h1>
       <hr>
     </header>
   '';
 
-  footer = ''
+  footer = content: ''
     <hr>
     <footer>
-      <p class="footer">
-        <a class="uncoloured-link" href="https://tazj.in">homepage</a>
-        |
-        <a class="uncoloured-link" href="https://cs.tvl.fyi/">code</a>
-      </p>
-      <p class="lod">ಠ_ಠ</p>
+      ${content}
     </footer>
   </body>
   '';
@@ -54,7 +46,7 @@ let
   draftWarning = writeText "draft.html" ''
     <p class="cheddar-callout cheddar-warning">
       <b>Note:</b> This post is a <b>draft</b>! Please do not share
-      the link to it without asking me first.
+      the link to it without asking first.
     </p>
     <hr>
   '';
@@ -62,13 +54,13 @@ let
   unlistedWarning = writeText "unlisted.html" ''
     <p class="cheddar-callout cheddar-warning">
       <b>Note:</b> This post is <b>unlisted</b>! Please do not share
-      the link to it without asking me first.
+      the link to it without asking first.
     </p>
     <hr>
   '';
 
-  renderPost = post: runCommandNoCC "${post.key}.html" {} ''
-    cat ${writeText "header.html" (header post.title)} > $out
+  renderPost = { name, footer }: post: runCommandNoCC "${post.key}.html" {} ''
+    cat ${writeText "header.html" (header name post.title)} > $out
 
     # Write the post title & date
     echo '<article><h2 class="inline">${escape post.title}</h2>' >> $out
@@ -97,5 +89,5 @@ let
     cat ${writeText "footer.html" footer} >> $out
   '';
 in {
-  inherit renderPost isDraft isUnlisted;
+  inherit isDraft isUnlisted renderPost;
 }