fix(web/blog): make base URL configurable for atom feeds
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>
This commit is contained in:
parent
bb980158a7
commit
875ef0a605
6 changed files with 19 additions and 17 deletions
|
@ -5,8 +5,9 @@ with depot.nix.yants;
|
|||
let
|
||||
inherit (builtins) hasAttr filter;
|
||||
|
||||
blogConfig = {
|
||||
config = {
|
||||
name = "tazjin's blog";
|
||||
baseUrl = "https://tazj.in/blog";
|
||||
|
||||
footer = ''
|
||||
<p class="footer">
|
||||
|
@ -26,12 +27,12 @@ let
|
|||
mkdir -p $out
|
||||
|
||||
${lib.concatStringsSep "\n" (map (post:
|
||||
"cp ${renderPost blogConfig post} $out/${post.key}.html"
|
||||
"cp ${renderPost config post} $out/${post.key}.html"
|
||||
) posts)}
|
||||
'';
|
||||
|
||||
in {
|
||||
inherit posts rendered;
|
||||
inherit posts rendered config;
|
||||
|
||||
# Generate embeddable nginx configuration for redirects from old post URLs
|
||||
oldRedirects = lib.concatStringsSep "\n" (map (post: ''
|
||||
|
|
|
@ -22,7 +22,7 @@ let
|
|||
};
|
||||
});
|
||||
|
||||
allEntries = (map blog.toFeedEntry depot.users.tazjin.blog.posts)
|
||||
allEntries = (with depot.users.tazjin.blog; map (blog.toFeedEntry config) posts)
|
||||
++ (map pageEntryToEntry pageEntries);
|
||||
|
||||
feed = {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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
|
||||
''
|
||||
|
|
Loading…
Reference in a new issue