md to page callback

This commit is contained in:
tristan 2024-02-11 08:12:00 +00:00
parent 3c82f5f9bc
commit 62f3749709

View file

@ -7,13 +7,13 @@ in rec {
then processStr (builtins.readFile md)
else processStr md;
recReadMd = root:
recReadMd = toPage: root:
assert builtins.isPath root;
builtins.mapAttrs (path: type:
if type == "directory"
then recReadMd (root + (/. + path))
else if type == "regular"
then mdToPage (root + (/. + path))
then toPage (processMd (root + (/. + path)))
else throw "Cannot read ${path}, file type ${type}") (builtins.readDir root);
recFixAppendix = site:
@ -28,13 +28,7 @@ in rec {
fixAppendix = builtins.replaceStrings [".md"] [".html"];
readDir = root: recFixAppendix (recReadMd root);
mdToPage = md:
html.document {
head = [];
body = elems.main (elems.article (processMd md));
};
readDir = toPage: root: recFixAppendix (recReadMd toPage root);
splitList = block:
map listItem (builtins.filter (s: builtins.isString s && s != "")