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
|
2020-08-11 01:16:29 +02:00
|
|
|
inherit (builtins) map readFile sort;
|
2020-08-11 00:38:07 +02:00
|
|
|
inherit (lib) singleton;
|
|
|
|
inherit (pkgs) writeText;
|
|
|
|
inherit (depot.users.tazjin) atom-feed blog renderMarkdown;
|
|
|
|
|
|
|
|
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;
|
|
|
|
updated = post.date; # TODO(tazjin): this should be distinct from published
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
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";
|
2020-08-11 00:38:07 +02:00
|
|
|
# TODO(tazjin): Take the most recently updated entry time instead.
|
|
|
|
updated = builtins.currentTime;
|
|
|
|
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)
|