From 452b8c7e2338670826aab4f822b7d8ed1099cc81 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 10 Aug 2020 22:48:05 +0100 Subject: refactor(tazjin/blog): Extract post rendering to utility function To use cheddar for both the feed & web views, the rendering function is extracted a level up - this prevents duplicate renderer calls. Change-Id: I31812c5c3f905f2f84914c6a8ab7c14602227be1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1710 Tested-by: BuildkiteCI Reviewed-by: tazjin --- users/tazjin/blog/fragments.nix | 3 ++- users/tazjin/renderMarkdown.nix | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 users/tazjin/renderMarkdown.nix (limited to 'users/tazjin') diff --git a/users/tazjin/blog/fragments.nix b/users/tazjin/blog/fragments.nix index 978dfa2a23df..18f1c4e4c236 100644 --- a/users/tazjin/blog/fragments.nix +++ b/users/tazjin/blog/fragments.nix @@ -12,6 +12,7 @@ let inherit (builtins) filter map hasAttr replaceStrings toFile; inherit (depot.third_party) runCommandNoCC writeText; + inherit (depot.users.tazjin) renderMarkdown; # Generate a post list for all listed, non-draft posts. isDraft = post: (hasAttr "draft" post) && post.draft; @@ -87,7 +88,7 @@ let } # Write the actual post through cheddar's about-filter mechanism - cat ${post.content} | ${depot.tools.cheddar}/bin/cheddar --about-filter ${post.content} >> $out + cat ${renderMarkdown post.content} >> $out echo '' >> $out cat ${toFile "footer.html" footer} >> $out diff --git a/users/tazjin/renderMarkdown.nix b/users/tazjin/renderMarkdown.nix new file mode 100644 index 000000000000..58f29c30e0f3 --- /dev/null +++ b/users/tazjin/renderMarkdown.nix @@ -0,0 +1,9 @@ +# Render a Markdown file to HTML. +{ depot, ... }: + +with depot.nix.yants; + +defun [ path drv ] (file: depot.third_party.runCommandNoCC "${file}.rendered.html" {} '' + cat ${file} | ${depot.tools.cheddar}/bin/cheddar --about-filter ${file} > $out +'') + -- cgit 1.4.1