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;
|
|
|
|
inherit (pkgs) runCommandNoCC;
|
2021-12-27 14:38:35 +01:00
|
|
|
|
|
|
|
config = {
|
|
|
|
name = "wpcarro's blog";
|
|
|
|
baseUrl = "https://blog.wpcarro.dev";
|
|
|
|
footer = "";
|
|
|
|
};
|
|
|
|
|
|
|
|
posts = filter includePost (list post (import ./posts.nix));
|
|
|
|
|
2021-12-27 16:52:53 +01:00
|
|
|
rendered = runCommandNoCC "wpcarros-blog" {} ''
|
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-27 16:52:53 +01:00
|
|
|
formatDate = date: readFile (runCommandNoCC "date" {} ''
|
|
|
|
date --date='@${toString date}' '+%B %e, %Y' > $out
|
|
|
|
'');
|
|
|
|
|
|
|
|
postsList = pkgs.writeText "index.html" ''
|
|
|
|
<div class="max-w-sm md:max-w-prose mx-auto">
|
|
|
|
<section class="pt-8 pb-14">
|
|
|
|
<p class="font-bold pb-4">Personal blog by <a class="font-bold text-blue-600 hover:underline" href="https://wpcarro.dev">wpcarro</a>.</p>
|
|
|
|
<p class="text-gray-500">> Half-baked musings lossily encoded.</p>
|
|
|
|
<p class="text-gray-500">> - misc reviewer</p>
|
|
|
|
</section>
|
|
|
|
<ul>
|
|
|
|
${lib.concatStringsSep "\n" (map (post: ''
|
|
|
|
<li class="pb-10">
|
|
|
|
<h2 class="text-bold font-2xl ">
|
|
|
|
<a class="font-bold text-blue-600 hover:underline" href="${config.baseUrl}/${post.key}.html">
|
|
|
|
${post.title}
|
|
|
|
</a>
|
|
|
|
</h2>
|
|
|
|
<p class="text-gray-500">
|
|
|
|
${formatDate post.date}
|
|
|
|
</p>
|
|
|
|
</li>
|
|
|
|
'') posts)}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
'';
|
2021-12-27 14:38:35 +01:00
|
|
|
in {
|
|
|
|
inherit posts rendered config;
|
2021-12-27 16:52:53 +01:00
|
|
|
|
|
|
|
root = runCommandNoCC "wpcarros-blog" {} ''
|
|
|
|
mkdir -p $out
|
|
|
|
|
|
|
|
cat ${wpcarro.website.header} \
|
|
|
|
${postsList} \
|
|
|
|
${wpcarro.website.addendum} > $out/index.html
|
|
|
|
'';
|
2020-03-09 16:14:49 +01:00
|
|
|
}
|