diff --git a/pkgs-lib.nix b/pkgs-lib.nix index 26186e3..592d351 100644 --- a/pkgs-lib.nix +++ b/pkgs-lib.nix @@ -117,6 +117,7 @@ in { then null else date; content = l.readFile (parseMarkdown id (getPath path name)); + description = args.config.descriptionsById.${id} or null; } )) (l.sort ( @@ -145,6 +146,7 @@ in { displayName = l.head (l.splitString "." name); id = l.replaceStrings [" "] ["_"] displayName; content = l.readFile (parseMarkdown id (getPath path name)); + description = args.config.descriptionsById.${id} or null; } ) (l.readDir path) diff --git a/templaters/simple/default.nix b/templaters/simple/default.nix index fe57ee6..a763a57 100644 --- a/templaters/simple/default.nix +++ b/templaters/simple/default.nix @@ -26,6 +26,7 @@ mkPage = { content, titleStr ? ctx.config.title, + description ? null, }: with html; '' @@ -33,6 +34,10 @@ (head (stylesheets ++ [ (title titleStr) + (l.optionalString (description != null) (meta { + name = "description"; + content = ctx.config.description; + })) (meta { name = "viewport"; content = "width=device-width, initial-scale=1"; @@ -118,6 +123,7 @@ l.nameValuePair post.id { content = renderPost post; name = post.displayName; + description = post.description; }) ctx.posts ); @@ -127,6 +133,7 @@ l.nameValuePair page.id { content = page.content; name = page.displayName; + description = page.description; }) ctx.pages ); @@ -156,7 +163,7 @@ ( name: value: { "index.html" = mkPage { - content = value.content; + inherit (value) content description; titleStr = "${value.name} - ${ctx.config.title}"; }; }