about summary refs log tree commit diff
path: root/web/blog
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-02-11T19·31+0000
committerVincent Ambo <tazjin@google.com>2020-02-11T19·31+0000
commitb5c50f4699ad5dd18b247b77719aa188b0003430 (patch)
tree99c61b3c4b1876d8f3fde79f3e7e1b042fa92e2a /web/blog
parent2e958227122717ae5a013fd4656664d28d20f00d (diff)
refactor(web): Let //web/ derivations build static pages only r/539
Removes nginx configuration built by the web targets (with the
exception of the includable block used to set up redirects for old
blog URLs).
Diffstat (limited to 'web/blog')
-rw-r--r--web/blog/default.nix10
1 files changed, 9 insertions, 1 deletions
diff --git a/web/blog/default.nix b/web/blog/default.nix
index 5f97c00bc985..a8e48a9d6888 100644
--- a/web/blog/default.nix
+++ b/web/blog/default.nix
@@ -7,7 +7,7 @@
 with pkgs.nix.yants;
 
 let
-  inherit (builtins) filter;
+  inherit (builtins) filter hasAttr map;
 
   # Type definition for a single blog post.
   post = struct "blog-post" {
@@ -48,4 +48,12 @@ in {
 
   # Only include listed posts
   posts = filter includePost posts;
+
+  # Generate embeddable nginx configuration for redirects from old post URLs
+  oldRedirects = lib.concatStringsSep "\n" (map (post: ''
+    location ~* ^(/en)?/${post.oldKey} {
+      # TODO(tazjin): 301 once this works
+      return 302 https://tazj.in/blog/${post.key};
+    }
+  '') (filter (hasAttr "oldKey") posts));
 }