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 <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2021-11-05 14:11:41 +01:00 committed by tazjin
parent 4b33401a36
commit 674603f6c8

View file

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