about summary refs log tree commit diff
path: root/web/tvl
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-05-12T14·41+0200
committersterni <sternenseemann@systemli.org>2021-05-12T15·36+0000
commit25ff41452b3bf4442139aea8fe089de43950f74e (patch)
tree79549e5aa3bd38c0ab9f4dcd7f376a5f10dd56c0 /web/tvl
parent513e733f8a37fcb1b829edad06c5cece389a5442 (diff)
feat(tvl/template): support markdown via cheddar r/2587
Since the template already was a derivation we can just reimplement a
specialized writeText which runs cheddar on parts of its input to avoid
import from derivation.

Change-Id: I0cffd0e86fd23a749599174260d04269379f4b5f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3114
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'web/tvl')
-rw-r--r--web/tvl/template/default.nix48
1 files changed, 29 insertions, 19 deletions
diff --git a/web/tvl/template/default.nix b/web/tvl/template/default.nix
index a48003de8d19..9d5c8101c82e 100644
--- a/web/tvl/template/default.nix
+++ b/web/tvl/template/default.nix
@@ -11,30 +11,34 @@
 }@args:
 
 let
-  inherit (pkgs) writeText lib;
+  inherit (pkgs) runCommandNoCC lib;
+  inherit (depot.tools) cheddar;
 
   baseUrl = lib.optionalString useUrls "https://tvl.fyi";
 in
 
-writeText "index.html" (''
-  <!DOCTYPE html>
-  <head>
-    <meta charset="utf-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <meta name="description" content="The Virus Lounge">
-    <link rel="stylesheet" type="text/css" href="${baseUrl}/static/tazjin.css" media="all">
-    <link rel="icon" type="image/webp" href="${baseUrl}/static/favicon.webp">
-    <title>${title}</title>
-'' + lib.optionalString (args ? extraHead) extraHead + ''
-  </head>
-  <body class="light">
-    <header>
-      <h1><a class="blog-title" href="/">${title}</a> </h1>
-      <hr>
-    </header>
+runCommandNoCC "index.html" {
+  headerPart = ''
+    <!DOCTYPE html>
+    <head>
+      <meta charset="utf-8">
+      <meta name="viewport" content="width=device-width, initial-scale=1">
+      <meta name="description" content="The Virus Lounge">
+      <link rel="stylesheet" type="text/css" href="${baseUrl}/static/tazjin.css" media="all">
+      <link rel="icon" type="image/webp" href="${baseUrl}/static/favicon.webp">
+      <title>${title}</title>
+  '' + lib.optionalString (args ? extraHead) extraHead + ''
+    </head>
+    <body class="light">
+      <header>
+        <h1><a class="blog-title" href="/">${title}</a> </h1>
+        <hr>
+      </header>
+  '';
 
-    ${content}
+  inherit content;
 
+  footerPart = ''
     <hr>
     <footer>
       <p class="footer">
@@ -51,4 +55,10 @@ writeText "index.html" (''
       <p class="lod">ಠ_ಠ</p>
     </footer>
   </body>
-'')
+  '';
+
+  passAsFile = [ "headerPart" "content" "footerPart" ];
+} ''
+  ${cheddar}/bin/cheddar --about-filter content.md < $contentPath > rendered.html
+  cat $headerPartPath rendered.html $footerPartPath > $out
+''