From 9f5e0095a4e13cd0e88aa7973b46ee526dd8eace Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Sat, 30 Jul 2022 13:29:56 +0300 Subject: [PATCH] implement indexContent and resources support --- templaters/basic.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/templaters/basic.nix b/templaters/basic.nix index 07e4527..91902c9 100644 --- a/templaters/basic.nix +++ b/templaters/basic.nix @@ -9,7 +9,7 @@ ... } @ context: let inherit (utils) readFile mapAttrsToList mapAttrs tags fetchGit map elemAt foldl' concatStrings genAttrs toString; - inherit (pkgs.lib) optional length splitString nameValuePair toInt range mapAttrs'; + inherit (pkgs.lib) optionalAttrs optional length splitString nameValuePair toInt range mapAttrs'; stylesheets = map tags.mkStylesheet [ "https://unpkg.com/purecss@2.0.6/build/pure-min.css" @@ -86,6 +86,8 @@ ]} ''; + indexPage = mkPage (context.indexContent or postsSectionContent); + stylesheet = with utils.css; let marginMobile = { margin-left = "3%"; @@ -157,9 +159,10 @@ in { site = site // { - "index.html" = mkPage postsSectionContent; + "index.html" = indexPage; "404.html" = mkPage (tags.h1 "No such page"); "site.css" = stylesheet; } - // (mapAttrs (name: value: {"index.html" = mkPage value;}) pages); + // (mapAttrs (name: value: {"index.html" = mkPage value;}) pages) + // optionalAttrs (context ? resources) {inherit (context) resources;}; }