about summary refs log tree commit diff
path: root/web/blog
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-02-08T13·47+0000
committerVincent Ambo <tazjin@google.com>2020-02-08T13·47+0000
commit8e9fb739582b5ed871522826ea145f4a9dac2777 (patch)
treeeb6b58fc4f68f2943b30a218040cdf019b26a776 /web/blog
parentcc2c130352eddb78c8b690320f0a765bb77b5bf6 (diff)
refactor(web/blog): Use timestamps for dates instead of strings r/486
This lets me easily create an ordered list of entries if the homepage
is designed to list both blog posts and other content.
Diffstat (limited to 'web/blog')
-rw-r--r--web/blog/default.nix5
-rw-r--r--web/blog/fragments.nix8
-rw-r--r--web/blog/posts.nix10
3 files changed, 13 insertions, 10 deletions
diff --git a/web/blog/default.nix b/web/blog/default.nix
index bc7b9666f7..1bc026bf2a 100644
--- a/web/blog/default.nix
+++ b/web/blog/default.nix
@@ -11,7 +11,7 @@ let
   post = struct "blog-post" {
     key = string; #
     title = string;
-    date = string; # *sigh*
+    date = int;
 
     # Path to the Markdown file containing the post content.
     content = path;
@@ -39,8 +39,7 @@ let
     ${lib.concatStringsSep "\n" (map (post:
       "cp ${fragments.renderPost post} $out/${post.key}.html"
     ) posts)}
-  ''; # '' (this line makes nix-mode happy :/)
-
+  '';
 in import ./nginx.nix (args // {
   inherit posts renderedBlog;
 })
diff --git a/web/blog/fragments.nix b/web/blog/fragments.nix
index 2c9127b7f7..4af642c01e 100644
--- a/web/blog/fragments.nix
+++ b/web/blog/fragments.nix
@@ -51,9 +51,13 @@ let
   renderPost = post: runCommandNoCC "${post.key}.html" {} ''
     cat ${toFile "header.html" (header post.title)} > $out
 
-    # Write the actual post
+    # Write the post title & date
     echo '<article><h2 class="inline">${escape post.title}</h2>' >> $out
-    echo '<aside class="date">${post.date}</aside>' >> $out
+    echo '<aside class="date">' >> $out
+    date --date="@${toString post.date}" '+%Y-%m-%d' >> $out
+    echo '</aside>' >> $out
+
+    # Write the actual post through cheddar's about-filter mechanism
     cat ${post.content} | ${pkgs.tools.cheddar}/bin/cheddar --about-filter ${post.content} >> $out
     echo '</article>' >> $out
 
diff --git a/web/blog/posts.nix b/web/blog/posts.nix
index e6fb821f95..164ffa142d 100644
--- a/web/blog/posts.nix
+++ b/web/blog/posts.nix
@@ -3,35 +3,35 @@
   {
     key = "reversing-watchguard-vpn";
     title = "Reverse-engineering WatchGuard Mobile VPN";
-    date = "2017-02-11";
+    date = 1486830338;
     content = ./posts/reversing-watchguard-vpn.md;
     oldKey = "1486830338";
   }
   {
     key = "make-object-t-again";
     title = "Make Object <T> Again!";
-    date = "2016-10-18";
+    date = 1476807384;
     content = ./posts/make-object-t-again.md;
     oldKey = "1476807384";
   }
   {
     key = "the-smu-problem";
     title = "The SMU-problem of messaging apps";
-    date = "2015-12-17";
+    date = 1450354078;
     content =./posts/the-smu-problem.md;
     oldKey = "1450354078";
   }
   {
     key = "sick-in-sweden";
     title = "Being sick in Sweden";
-    date = "2015-02-15";
+    date = 1423995834;
     content = ./posts/sick-in-sweden.md;
     oldKey = "1423995834";
   }
   {
     key = "nsa-zettabytes";
     title = "The NSA's 5 zettabytes of data";
-    date = "2013-07-31";
+    date = 1375310627;
     content = ./posts/nsa-zettabytes.md;
     oldKey = "1375310627";
   }