refactor(web/blog): Use timestamps for dates instead of strings
This lets me easily create an ordered list of entries if the homepage is designed to list both blog posts and other content.
This commit is contained in:
parent
cc2c130352
commit
8e9fb73958
3 changed files with 13 additions and 10 deletions
|
@ -11,7 +11,7 @@ let
|
||||||
post = struct "blog-post" {
|
post = struct "blog-post" {
|
||||||
key = string; #
|
key = string; #
|
||||||
title = string;
|
title = string;
|
||||||
date = string; # *sigh*
|
date = int;
|
||||||
|
|
||||||
# Path to the Markdown file containing the post content.
|
# Path to the Markdown file containing the post content.
|
||||||
content = path;
|
content = path;
|
||||||
|
@ -39,8 +39,7 @@ let
|
||||||
${lib.concatStringsSep "\n" (map (post:
|
${lib.concatStringsSep "\n" (map (post:
|
||||||
"cp ${fragments.renderPost post} $out/${post.key}.html"
|
"cp ${fragments.renderPost post} $out/${post.key}.html"
|
||||||
) posts)}
|
) posts)}
|
||||||
''; # '' (this line makes nix-mode happy :/)
|
'';
|
||||||
|
|
||||||
in import ./nginx.nix (args // {
|
in import ./nginx.nix (args // {
|
||||||
inherit posts renderedBlog;
|
inherit posts renderedBlog;
|
||||||
})
|
})
|
||||||
|
|
|
@ -51,9 +51,13 @@ let
|
||||||
renderPost = post: runCommandNoCC "${post.key}.html" {} ''
|
renderPost = post: runCommandNoCC "${post.key}.html" {} ''
|
||||||
cat ${toFile "header.html" (header post.title)} > $out
|
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 '<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
|
cat ${post.content} | ${pkgs.tools.cheddar}/bin/cheddar --about-filter ${post.content} >> $out
|
||||||
echo '</article>' >> $out
|
echo '</article>' >> $out
|
||||||
|
|
||||||
|
|
|
@ -3,35 +3,35 @@
|
||||||
{
|
{
|
||||||
key = "reversing-watchguard-vpn";
|
key = "reversing-watchguard-vpn";
|
||||||
title = "Reverse-engineering WatchGuard Mobile VPN";
|
title = "Reverse-engineering WatchGuard Mobile VPN";
|
||||||
date = "2017-02-11";
|
date = 1486830338;
|
||||||
content = ./posts/reversing-watchguard-vpn.md;
|
content = ./posts/reversing-watchguard-vpn.md;
|
||||||
oldKey = "1486830338";
|
oldKey = "1486830338";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
key = "make-object-t-again";
|
key = "make-object-t-again";
|
||||||
title = "Make Object <T> Again!";
|
title = "Make Object <T> Again!";
|
||||||
date = "2016-10-18";
|
date = 1476807384;
|
||||||
content = ./posts/make-object-t-again.md;
|
content = ./posts/make-object-t-again.md;
|
||||||
oldKey = "1476807384";
|
oldKey = "1476807384";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
key = "the-smu-problem";
|
key = "the-smu-problem";
|
||||||
title = "The SMU-problem of messaging apps";
|
title = "The SMU-problem of messaging apps";
|
||||||
date = "2015-12-17";
|
date = 1450354078;
|
||||||
content =./posts/the-smu-problem.md;
|
content =./posts/the-smu-problem.md;
|
||||||
oldKey = "1450354078";
|
oldKey = "1450354078";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
key = "sick-in-sweden";
|
key = "sick-in-sweden";
|
||||||
title = "Being sick in Sweden";
|
title = "Being sick in Sweden";
|
||||||
date = "2015-02-15";
|
date = 1423995834;
|
||||||
content = ./posts/sick-in-sweden.md;
|
content = ./posts/sick-in-sweden.md;
|
||||||
oldKey = "1423995834";
|
oldKey = "1423995834";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
key = "nsa-zettabytes";
|
key = "nsa-zettabytes";
|
||||||
title = "The NSA's 5 zettabytes of data";
|
title = "The NSA's 5 zettabytes of data";
|
||||||
date = "2013-07-31";
|
date = 1375310627;
|
||||||
content = ./posts/nsa-zettabytes.md;
|
content = ./posts/nsa-zettabytes.md;
|
||||||
oldKey = "1375310627";
|
oldKey = "1375310627";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue