diff options
author | Vincent Ambo <mail@tazj.in> | 2021-11-05T13·19+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2021-11-08T10·39+0000 |
commit | 875ef0a605c298e3033ef950119092d09e21f306 (patch) | |
tree | d81aaa06061953fad90a5b8f165cd31d023c5eb9 /web | |
parent | bb980158a785b0ce23d25fa0f74c996311df7a67 (diff) |
fix(web/blog): make base URL configurable for atom feeds r/3025
This was previously hardcoded to tazj.in, which is not going to work of course. Instead it now takes the blog config which has a new baseUrl parameter. For ease of use, the configs of my and the TVL blog have been moved into a location that is accessible in the tree for reuse. Change-Id: I94e71aaa7859db4380eb7013740a17f6b6a02620 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3777 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'web')
-rw-r--r-- | web/blog/default.nix | 5 | ||||
-rw-r--r-- | web/blog/fragments.nix | 2 | ||||
-rw-r--r-- | web/tvl/blog/default.nix | 6 | ||||
-rw-r--r-- | web/tvl/default.nix | 14 |
4 files changed, 14 insertions, 13 deletions
diff --git a/web/blog/default.nix b/web/blog/default.nix index fd8f7dc9fc55..ec386a217766 100644 --- a/web/blog/default.nix +++ b/web/blog/default.nix @@ -40,8 +40,8 @@ let fragments = import ./fragments.nix args; # Functions for generating feeds for these blogs using //web/atom-feed. - toFeedEntry = defun [ post atom-feed.entry ] (post: rec { - id = "https://tazj.in/blog/${post.key}"; + toFeedEntry = { baseUrl, ...}: defun [ post atom-feed.entry ] (post: rec { + id = "${baseUrl}/${post.key}"; title = post.title; content = readFile (renderMarkdown post.content); published = post.date; @@ -52,7 +52,6 @@ let href = id; }; }); - in { inherit post toFeedEntry; inherit (fragments) renderPost; diff --git a/web/blog/fragments.nix b/web/blog/fragments.nix index f95c0f17a5fe..9a4446324e57 100644 --- a/web/blog/fragments.nix +++ b/web/blog/fragments.nix @@ -59,7 +59,7 @@ let <hr> ''; - renderPost = { name, footer }: post: runCommandNoCC "${post.key}.html" {} '' + renderPost = { name, footer, ... }: post: runCommandNoCC "${post.key}.html" {} '' cat ${writeText "header.html" (header name post.title)} > $out # Write the post title & date diff --git a/web/tvl/blog/default.nix b/web/tvl/blog/default.nix index fac627a94099..cedfc6b41787 100644 --- a/web/tvl/blog/default.nix +++ b/web/tvl/blog/default.nix @@ -1,6 +1,12 @@ { depot, ... }: { + config = { + name = "TVL's blog"; + footer = depot.web.tvl.footer {}; + baseUrl = "https://tvl.fyi/blog"; + }; + posts = [ { key = "kicking-off-tvix"; diff --git a/web/tvl/default.nix b/web/tvl/default.nix index c40335003139..4a3688bf3177 100644 --- a/web/tvl/default.nix +++ b/web/tvl/default.nix @@ -4,16 +4,12 @@ with depot.nix.yants; let inherit (pkgs) graphviz runCommandNoCC writeText; - inherit (depot.web) blog atom-feed; + inherit (depot.web) atom-feed blog tvl; - blogConfig = { - name = "TVL's blog"; - footer = depot.web.tvl.footer {}; - }; postRenderingCommands = defun [ (list blog.post) string ] (posts: lib.concatStringsSep "\n" - (map (p: "cp ${blog.renderPost blogConfig p} $out/blog/${p.key}.html") posts) + (map (p: "cp ${blog.renderPost tvl.blog.config p} $out/blog/${p.key}.html") posts) ); tvlGraph = runCommandNoCC "tvl.svg" { @@ -33,12 +29,12 @@ let href = "https://tvl.fyi/feed.atom"; }; - entries = map blog.toFeedEntry depot.web.tvl.blog.posts; + entries = map (blog.toFeedEntry tvl.blog.config) tvl.blog.posts; }; atomFeed = writeText "feed.atom" (atom-feed.renderFeed feed); - homepage = depot.web.tvl.template { + homepage = tvl.template { title = "The Virus Lounge"; content = '' The Virus Lounge @@ -109,6 +105,6 @@ let in runCommandNoCC "website" {} '' mkdir -p $out/blog cp ${homepage} $out/index.html - ${postRenderingCommands depot.web.tvl.blog.posts} + ${postRenderingCommands tvl.blog.posts} cp ${atomFeed} $out/feed.atom '' |