2020-08-11 00:38:07 +02:00
|
|
|
# Creates the Atom feed for my homepage.
|
2020-08-11 01:16:29 +02:00
|
|
|
{ depot, lib, pkgs, entry, pageEntries, ... }:
|
2020-08-11 00:38:07 +02:00
|
|
|
|
|
|
|
with depot.nix.yants;
|
|
|
|
|
|
|
|
let
|
2021-04-02 15:40:41 +02:00
|
|
|
inherit (builtins) map readFile sort foldl';
|
|
|
|
inherit (lib) max singleton;
|
2020-08-11 00:38:07 +02:00
|
|
|
inherit (pkgs) writeText;
|
2021-10-16 16:30:41 +02:00
|
|
|
inherit (depot.nix) renderMarkdown;
|
|
|
|
inherit (depot.users.tazjin) blog;
|
2021-10-15 13:44:49 +02:00
|
|
|
inherit (depot.web) atom-feed;
|
2020-08-11 00:38:07 +02:00
|
|
|
|
|
|
|
postToEntry = defun [ blog.post atom-feed.entry ] (post: rec {
|
|
|
|
id = "https://tazj.in/blog/${post.key}";
|
|
|
|
title = post.title;
|
|
|
|
content = readFile (renderMarkdown post.content);
|
|
|
|
published = post.date;
|
2021-04-02 15:35:35 +02:00
|
|
|
updated = post.updated or post.date;
|
2020-08-11 00:38:07 +02:00
|
|
|
|
|
|
|
links = singleton {
|
|
|
|
rel = "alternate";
|
|
|
|
href = id;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2020-08-11 01:16:29 +02:00
|
|
|
pageEntryToEntry = defun [ entry atom-feed.entry ] (e: {
|
|
|
|
id = "tazjin:${e.class}:${toString e.date}";
|
|
|
|
updated = e.date;
|
|
|
|
published = e.date;
|
|
|
|
title = e.title;
|
|
|
|
summary = e.description;
|
|
|
|
|
|
|
|
links = singleton {
|
|
|
|
rel = "alternate";
|
|
|
|
href = e.url;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
allEntries = (map postToEntry blog.posts) ++ (map pageEntryToEntry pageEntries);
|
|
|
|
|
2021-04-02 15:40:41 +02:00
|
|
|
mostRecentlyUpdated = foldl' max 0 (map (e: e.updated) allEntries);
|
|
|
|
|
2020-08-11 00:38:07 +02:00
|
|
|
feed = {
|
|
|
|
id = "https://tazj.in/";
|
|
|
|
title = "tazjin's interblag";
|
2020-08-11 01:16:29 +02:00
|
|
|
subtitle = "my posts, projects and other interesting things";
|
2021-04-02 15:40:41 +02:00
|
|
|
updated = mostRecentlyUpdated;
|
2020-08-11 00:38:07 +02:00
|
|
|
rights = "© 2020 tazjin";
|
|
|
|
authors = [ "tazjin" ];
|
|
|
|
|
|
|
|
links = singleton {
|
|
|
|
rel = "self";
|
|
|
|
href = "https://tazjin/feed.atom";
|
|
|
|
};
|
|
|
|
|
2020-08-11 01:16:29 +02:00
|
|
|
entries = sort (a: b: a.published > b.published) allEntries;
|
2020-08-11 00:38:07 +02:00
|
|
|
};
|
|
|
|
in writeText "feed.atom" (atom-feed.renderFeed feed)
|