From 674603f6c8b91ca121a9ebfd4bb9a43ca89c009e Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 5 Nov 2021 14:11:41 +0100 Subject: feat(web/tvl): Render blog posts and atom feed for TVL Includes the blog posts and feed in the $out directory, but without linking them from the TVL homepage yet. Change-Id: If9c094b29e43e9a81b0cc3d731261dc4b10557c1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3776 Tested-by: BuildkiteCI Reviewed-by: grfn --- web/tvl/default.nix | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'web/tvl') diff --git a/web/tvl/default.nix b/web/tvl/default.nix index e918fc4a998a..c40335003139 100644 --- a/web/tvl/default.nix +++ b/web/tvl/default.nix @@ -1,7 +1,20 @@ -{ depot, pkgs, ... }: +{ depot, lib, pkgs, ... }: + +with depot.nix.yants; let inherit (pkgs) graphviz runCommandNoCC writeText; + inherit (depot.web) blog atom-feed; + + blogConfig = { + name = "TVL's blog"; + footer = depot.web.tvl.footer {}; + }; + + postRenderingCommands = defun [ (list blog.post) string ] (posts: + lib.concatStringsSep "\n" + (map (p: "cp ${blog.renderPost blogConfig p} $out/blog/${p.key}.html") posts) + ); tvlGraph = runCommandNoCC "tvl.svg" { nativeBuildInputs = with pkgs; [ fontconfig freetype cairo jetbrains-mono ]; @@ -9,6 +22,22 @@ let ${graphviz}/bin/neato -Tsvg ${./tvl.dot} > $out ''; + feed = { + id = "https://tvl.fyi/"; + title = "TVL blog"; + subtitle = "Thoughts and news from The Virus Lounge"; + authors = [ "tazjin" ]; # TODO(tazjin): Extract from post info + + links = lib.singleton { + rel = "self"; + href = "https://tvl.fyi/feed.atom"; + }; + + entries = map blog.toFeedEntry depot.web.tvl.blog.posts; + }; + + atomFeed = writeText "feed.atom" (atom-feed.renderFeed feed); + homepage = depot.web.tvl.template { title = "The Virus Lounge"; content = '' @@ -78,6 +107,8 @@ let ''; }; in runCommandNoCC "website" {} '' - mkdir -p $out/static + mkdir -p $out/blog cp ${homepage} $out/index.html + ${postRenderingCommands depot.web.tvl.blog.posts} + cp ${atomFeed} $out/feed.atom '' -- cgit 1.4.1