add index content

This commit is contained in:
dusk 2023-04-06 07:07:05 +03:00
parent 9c6c7d39dc
commit f2b5bc28a9
Signed by: dusk
GPG Key ID: 1D8F8FAF2294D6EA

View File

@ -91,6 +91,12 @@ in {
name = l.strings.sanitizeDerivationName name; name = l.strings.sanitizeDerivationName name;
path = "${toString from}/${name}"; path = "${toString from}/${name}";
}; };
indexRendered = let
path = "${toString src}/index.md";
in
if l.pathExists path
then l.readFile (parseMarkdown "index.html" path)
else null;
postsRendered = let postsRendered = let
path = "${toString src}/posts"; path = "${toString src}/posts";
in in
@ -148,18 +154,22 @@ in {
then "http://localhost:8080" then "http://localhost:8080"
else args.config.baseurl or (throw "Need baseurl"); else args.config.baseurl or (throw "Need baseurl");
context = { context =
inherit lib baseurl; {
inherit (args) config; inherit lib baseurl;
posts = postsRendered; inherit (args) config;
pages = pagesRendered; posts = postsRendered;
site = { pages = pagesRendered;
"robots.txt" = '' site = {
User-agent: * "robots.txt" = ''
Allow: / User-agent: *
''; Allow: /
'';
};
}
// l.optionalAttrs (indexRendered != null) {
indexContent = indexRendered;
}; };
};
in in
(templater context).site; (templater context).site;
}; };