feat(tvl/template): support markdown via cheddar

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>
This commit is contained in:
sterni 2021-05-12 16:41:51 +02:00
parent 513e733f8a
commit 25ff41452b

View file

@ -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
''