2021-12-27 14:38:35 +01:00
|
|
|
{ depot, lib, pkgs, ... }:
|
2020-03-09 16:14:49 +01:00
|
|
|
|
2021-12-27 14:38:35 +01:00
|
|
|
with depot.nix.yants;
|
|
|
|
|
|
|
|
let
|
2021-12-27 16:52:53 +01:00
|
|
|
inherit (builtins) hasAttr filter readFile;
|
2021-12-27 14:38:35 +01:00
|
|
|
inherit (depot.web.blog) post includePost renderPost;
|
2021-12-27 16:52:53 +01:00
|
|
|
inherit (depot.users) wpcarro;
|
2021-12-27 14:38:35 +01:00
|
|
|
|
|
|
|
config = {
|
|
|
|
name = "wpcarro's blog";
|
2021-12-27 17:12:12 +01:00
|
|
|
baseUrl = "https://wpcarro.dev/blog";
|
2021-12-28 01:06:08 +01:00
|
|
|
footer = "";
|
2021-12-27 14:38:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
posts = filter includePost (list post (import ./posts.nix));
|
|
|
|
|
2021-12-28 01:06:08 +01:00
|
|
|
rendered = pkgs.runCommandNoCC "wpcarros-blog-posts" {} ''
|
2020-03-09 16:14:49 +01:00
|
|
|
mkdir -p $out
|
2021-12-27 14:38:35 +01:00
|
|
|
|
|
|
|
${lib.concatStringsSep "\n" (map (post:
|
|
|
|
"cp ${renderPost config post} $out/${post.key}.html"
|
|
|
|
) posts)}
|
2020-03-09 16:14:49 +01:00
|
|
|
'';
|
2021-12-27 14:38:35 +01:00
|
|
|
|
2021-12-28 01:06:08 +01:00
|
|
|
formatDate = date: readFile (pkgs.runCommandNoCC "date" {} ''
|
2021-12-27 16:52:53 +01:00
|
|
|
date --date='@${toString date}' '+%B %e, %Y' > $out
|
|
|
|
'');
|
|
|
|
|
2021-12-28 01:06:08 +01:00
|
|
|
postsHtml = readFile (pkgs.substituteAll {
|
|
|
|
src = ./fragments/posts.html;
|
|
|
|
postsHtml = lib.concatStringsSep "\n" (map toPostHtml posts);
|
|
|
|
});
|
|
|
|
|
|
|
|
toPostHtml = post: readFile (pkgs.substituteAll {
|
|
|
|
src = ./fragments/post.html;
|
2021-12-28 01:17:20 +01:00
|
|
|
postUrl = "${config.baseUrl}/posts/${post.key}.html";
|
2021-12-28 01:06:08 +01:00
|
|
|
postTitle = post.title;
|
|
|
|
postDate = formatDate post.date;
|
|
|
|
});
|
2021-12-28 01:17:20 +01:00
|
|
|
in pkgs.runCommandNoCC "wpcarros-blog" {} ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp ${wpcarro.website.render postsHtml} $out/index.html
|
|
|
|
cp -r ${rendered} $out/posts
|
|
|
|
''
|