about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2022-06-30T19·48-0700
committerclbot <clbot@tvl.fyi>2022-11-04T20·48+0000
commite3a66cbd5d0ffb2306b6fe2cd65b53a1dbd8394f (patch)
treeda58e9552d33143b405f240be5884306376d5c1a
parent9c7d8e791af7f6bfd4e518120cef4e36ba087fd6 (diff)
fix(web/blog): Parameterize renderPost with staticUrl r/5243
This was broken in my blog for way too long.

Change-Id: I03c45c666d67006a4608a4b19d6167ab692e321d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5905
Reviewed-by: wpcarro <wpcarro@gmail.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
-rw-r--r--users/wpcarro/website/blog/default.nix1
-rw-r--r--web/blog/fragments.nix8
2 files changed, 4 insertions, 5 deletions
diff --git a/users/wpcarro/website/blog/default.nix b/users/wpcarro/website/blog/default.nix
index 31b1c7df9c79..27541b0f39b4 100644
--- a/users/wpcarro/website/blog/default.nix
+++ b/users/wpcarro/website/blog/default.nix
@@ -11,6 +11,7 @@ let
   config = {
     name = "bill and his blog";
     baseUrl = "https://${domain}/blog";
+    staticUrl = "https://static.tvl.fyi/latest";
     footer = "";
   };
 
diff --git a/web/blog/fragments.nix b/web/blog/fragments.nix
index 4d08a76b84e9..8c78b2cc928b 100644
--- a/web/blog/fragments.nix
+++ b/web/blog/fragments.nix
@@ -11,15 +11,13 @@ let
   inherit (pkgs) runCommand writeText;
   inherit (depot.nix) renderMarkdown;
 
-  staticUrl = "https://static.tvl.fyi/${depot.web.static.drvHash}";
-
   # Generate a post list for all listed, non-draft posts.
   isDraft = post: (hasAttr "draft" post) && post.draft;
   isUnlisted = post: (hasAttr "listed" post) && !post.listed;
 
   escape = replaceStrings [ "<" ">" "&" "'" ] [ "&lt;" "&gt;" "&amp;" "&#39;" ];
 
-  header = name: title: ''
+  header = name: title: staticUrl: ''
     <!DOCTYPE html>
     <head>
       <meta charset="utf-8">
@@ -61,8 +59,8 @@ let
     <hr>
   '';
 
-  renderPost = { name, footer, ... }: post: runCommand "${post.key}.html" { } ''
-    cat ${writeText "header.html" (header name post.title)} > $out
+  renderPost = { name, footer, staticUrl ? "https://static.tvl.fyi/${depot.web.static.drvHash}", ... }: post: runCommand "${post.key}.html" { } ''
+    cat ${writeText "header.html" (header name post.title staticUrl)} > $out
 
     # Write the post title & date
     echo '<article><h2 class="inline">${escape post.title}</h2>' >> $out