tvl-depot/users/wpcarro/website/blog/default.nix
William Carroll c05c6920ee fix(wpcarro/blog): Fix broken post links
TL;DR:
- copy rendered posts to $out/posts
- update postUrl attr
- remove unused attrs

Change-Id: I027c20d6244e4626128788ad9aa1f1aad7855f32
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4723
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
2021-12-28 00:20:38 +00:00

45 lines
1.2 KiB
Nix

{ depot, lib, pkgs, ... }:
with depot.nix.yants;
let
inherit (builtins) hasAttr filter readFile;
inherit (depot.web.blog) post includePost renderPost;
inherit (depot.users) wpcarro;
config = {
name = "wpcarro's blog";
baseUrl = "https://wpcarro.dev/blog";
footer = "";
};
posts = filter includePost (list post (import ./posts.nix));
rendered = pkgs.runCommandNoCC "wpcarros-blog-posts" {} ''
mkdir -p $out
${lib.concatStringsSep "\n" (map (post:
"cp ${renderPost config post} $out/${post.key}.html"
) posts)}
'';
formatDate = date: readFile (pkgs.runCommandNoCC "date" {} ''
date --date='@${toString date}' '+%B %e, %Y' > $out
'');
postsHtml = readFile (pkgs.substituteAll {
src = ./fragments/posts.html;
postsHtml = lib.concatStringsSep "\n" (map toPostHtml posts);
});
toPostHtml = post: readFile (pkgs.substituteAll {
src = ./fragments/post.html;
postUrl = "${config.baseUrl}/posts/${post.key}.html";
postTitle = post.title;
postDate = formatDate post.date;
});
in pkgs.runCommandNoCC "wpcarros-blog" {} ''
mkdir -p $out
cp ${wpcarro.website.render postsHtml} $out/index.html
cp -r ${rendered} $out/posts
''