From 25ff41452b3bf4442139aea8fe089de43950f74e Mon Sep 17 00:00:00 2001 From: sterni Date: Wed, 12 May 2021 16:41:51 +0200 Subject: 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 --- web/tvl/template/default.nix | 48 ++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'web') 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" ('' - - - - - - - - ${title} -'' + lib.optionalString (args ? extraHead) extraHead + '' - - -
-

${title}

-
-
+runCommandNoCC "index.html" { + headerPart = '' + + + + + + + + ${title} + '' + lib.optionalString (args ? extraHead) extraHead + '' + + +
+

${title}

+
+
+ ''; - ${content} + inherit content; + footerPart = ''
-'') + ''; + + passAsFile = [ "headerPart" "content" "footerPart" ]; +} '' + ${cheddar}/bin/cheddar --about-filter content.md < $contentPath > rendered.html + cat $headerPartPath rendered.html $footerPartPath > $out +'' -- cgit 1.4.1