about summary refs log tree commit diff
path: root/users/wpcarro/website/blog
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2021-12-27T15·52-0400
committerclbot <clbot@tvl.fyi>2021-12-27T16·02+0000
commit1d4f88cbde37bceab2bfecd7e22c9e5918930386 (patch)
tree9b281848e8ec085c3d78c094e26e6b86e96785bf /users/wpcarro/website/blog
parent7ce9277a8e9e91b477c072a457d84cabd0054850 (diff)
feat(wpcarro/blog): Add a blog index page r/3476
TL;DR:
- Create an index page to list blog posts
- Drop blog.wpcarro.dev -> wpcarro.dev/blog
- Create fragments directory to host reusable static website components
- Consume fragments in wpcarro.dev and wpcarro.dev/blog for brand consistency

Change-Id: Ib8440300c008c3c0c5e5a6f207e4ea207dd41b47
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4717
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
Diffstat (limited to 'users/wpcarro/website/blog')
-rw-r--r--users/wpcarro/website/blog/default.nix41
1 files changed, 39 insertions, 2 deletions
diff --git a/users/wpcarro/website/blog/default.nix b/users/wpcarro/website/blog/default.nix
index df5502330ce3..0f9527edb827 100644
--- a/users/wpcarro/website/blog/default.nix
+++ b/users/wpcarro/website/blog/default.nix
@@ -3,8 +3,10 @@
 with depot.nix.yants;
 
 let
-  inherit (builtins) hasAttr filter;
+  inherit (builtins) hasAttr filter readFile;
   inherit (depot.web.blog) post includePost renderPost;
+  inherit (depot.users) wpcarro;
+  inherit (pkgs) runCommandNoCC;
 
   config = {
     name = "wpcarro's blog";
@@ -14,7 +16,7 @@ let
 
   posts = filter includePost (list post (import ./posts.nix));
 
-  rendered = pkgs.runCommandNoCC "wpcarros-blog" {} ''
+  rendered = runCommandNoCC "wpcarros-blog" {} ''
     mkdir -p $out
 
     ${lib.concatStringsSep "\n" (map (post:
@@ -22,6 +24,41 @@ let
     ) posts)}
   '';
 
+  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">&gt; Half-baked musings lossily encoded.</p>
+        <p class="text-gray-500">&gt; - 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>
+  '';
 in {
   inherit posts rendered config;
+
+  root = runCommandNoCC "wpcarros-blog" {} ''
+    mkdir -p $out
+
+    cat ${wpcarro.website.header} \
+        ${postsList} \
+        ${wpcarro.website.addendum} > $out/index.html
+  '';
 }