From 1d4f88cbde37bceab2bfecd7e22c9e5918930386 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 27 Dec 2021 11:52:53 -0400 Subject: [PATCH] feat(wpcarro/blog): Add a blog index page 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 Autosubmit: wpcarro --- users/wpcarro/nixos/diogenes/default.nix | 7 +-- users/wpcarro/website/blog/default.nix | 41 ++++++++++++- users/wpcarro/website/default.nix | 32 ++++++++--- users/wpcarro/website/fragments/.skip-subtree | 0 users/wpcarro/website/fragments/addendum.html | 13 +++++ users/wpcarro/website/fragments/footer.html | 20 +++++++ users/wpcarro/website/fragments/header.html | 57 +++++++++++++++++++ users/wpcarro/website/fragments/homepage.html | 20 +++++++ 8 files changed, 173 insertions(+), 17 deletions(-) create mode 100644 users/wpcarro/website/fragments/.skip-subtree create mode 100644 users/wpcarro/website/fragments/addendum.html create mode 100644 users/wpcarro/website/fragments/footer.html create mode 100644 users/wpcarro/website/fragments/header.html create mode 100644 users/wpcarro/website/fragments/homepage.html diff --git a/users/wpcarro/nixos/diogenes/default.nix b/users/wpcarro/nixos/diogenes/default.nix index dea89aa34..decf632c1 100644 --- a/users/wpcarro/nixos/diogenes/default.nix +++ b/users/wpcarro/nixos/diogenes/default.nix @@ -109,12 +109,7 @@ in { "wpcarro.dev" = { addSSL = true; enableACME = true; - root = wpcarro.website; - }; - "blog.wpcarro.dev" = { - addSSL = true; - enableACME = true; - root = wpcarro.website.blog.rendered; + root = wpcarro.website.root; }; }; }; diff --git a/users/wpcarro/website/blog/default.nix b/users/wpcarro/website/blog/default.nix index df5502330..0f9527edb 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" '' +
+
+

Personal blog by wpcarro.

+

> Half-baked musings lossily encoded.

+

> - misc reviewer

+
+
    + ${lib.concatStringsSep "\n" (map (post: '' +
  • +

    + + ${post.title} + +

    +

    + ${formatDate post.date} +

    +
  • + '') posts)} +
+
+ ''; in { inherit posts rendered config; + + root = runCommandNoCC "wpcarros-blog" {} '' + mkdir -p $out + + cat ${wpcarro.website.header} \ + ${postsList} \ + ${wpcarro.website.addendum} > $out/index.html + ''; } diff --git a/users/wpcarro/website/default.nix b/users/wpcarro/website/default.nix index 9480c38e9..60d8dc19e 100644 --- a/users/wpcarro/website/default.nix +++ b/users/wpcarro/website/default.nix @@ -1,13 +1,27 @@ { pkgs, depot, ... }: -pkgs.stdenv.mkDerivation { - name = "wpcarro.dev"; - src = builtins.path { path = ./.; name = "website"; }; - installPhase = '' - mkdir -p $out - cp $src/index.html $out +rec { + inherit (depot.users) wpcarro; - mkdir -p $out/habits - cp -r ${depot.users.wpcarro.website.habit-screens} $out/habits/index.html - ''; + header = "${./fragments/header.html}"; + footer = "${./fragments/footer.html}"; + addendum = "${./fragments/addendum.html}"; + + root = pkgs.stdenv.mkDerivation { + name = "wpcarro.dev"; + src = builtins.path { path = ./.; name = "website"; }; + installPhase = '' + mkdir -p $out + + cat ${header} \ + ${./fragments/homepage.html} \ + ${footer} \ + ${addendum} > $out/index.html + + mkdir -p $out/habits + cp -r ${wpcarro.website.habit-screens} $out/habits/index.html + + cp -r ${wpcarro.website.blog.root} $out/blog + ''; + }; } diff --git a/users/wpcarro/website/fragments/.skip-subtree b/users/wpcarro/website/fragments/.skip-subtree new file mode 100644 index 000000000..e69de29bb diff --git a/users/wpcarro/website/fragments/addendum.html b/users/wpcarro/website/fragments/addendum.html new file mode 100644 index 000000000..9623db9bf --- /dev/null +++ b/users/wpcarro/website/fragments/addendum.html @@ -0,0 +1,13 @@ + + + + diff --git a/users/wpcarro/website/fragments/footer.html b/users/wpcarro/website/fragments/footer.html new file mode 100644 index 000000000..c0c9a3d7c --- /dev/null +++ b/users/wpcarro/website/fragments/footer.html @@ -0,0 +1,20 @@ + diff --git a/users/wpcarro/website/fragments/header.html b/users/wpcarro/website/fragments/header.html new file mode 100644 index 000000000..42230ded1 --- /dev/null +++ b/users/wpcarro/website/fragments/header.html @@ -0,0 +1,57 @@ + + + + wpcarro.dev + + + + + + + +
+ +
+
diff --git a/users/wpcarro/website/fragments/homepage.html b/users/wpcarro/website/fragments/homepage.html new file mode 100644 index 000000000..54e38b990 --- /dev/null +++ b/users/wpcarro/website/fragments/homepage.html @@ -0,0 +1,20 @@ +
+

+ Hey! I'm William.👋 +

+

+ I write software. Currently I work as a Site Reliability Engineer for + Google Drive. +

+

+ I'm wpcarro on + GitHub + (and elsewhere), but if you're looking for code samples, the majority of + my open-source work resides in a magical place called the + depot. +

+

+ If I'm not coding, I'm likely meditating, training Jiu Jitsu, or + fumbling around on the piano or drums. +

+