diff options
Diffstat (limited to 'web/blog/default.nix')
-rw-r--r-- | web/blog/default.nix | 10 |
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)); } |