extract file processing

This commit is contained in:
Valentin Gagarin 2024-10-11 13:28:15 +02:00
parent 5b81645f57
commit e2416403a3

27
lib.nix
View file

@ -23,17 +23,24 @@ rec {
cmark ${builtins.toFile "${name}.md" markdown} > $out cmark ${builtins.toFile "${name}.md" markdown} > $out
''; '';
files = dir: lib.mapAttrs' /**
Get documents from a flat directory of files
*/
documents = dir: lib.mapAttrs'
( (
attrname: value: attrname: value: {
let name = lib.removeSuffix ".nix" attrname;
document = import (dir + "/${attrname}"); value = import (dir + "/${attrname}");
name = lib.removeSuffix ".nix" attrname; }
in
{
name = "${name}.html";
value = html document "${name}.html";
}
) )
(builtins.readDir dir); (builtins.readDir dir);
files = dir: lib.mapAttrs'
(
name: document: {
name = document.outPath;
value = html document "${name}.html";
}
)
(documents dir);
} }