add meta descriptions

This commit is contained in:
dusk 2023-04-06 07:52:11 +03:00
parent ef1ad056ac
commit 62dcbd7298
Signed by: dusk
GPG Key ID: 1D8F8FAF2294D6EA
2 changed files with 10 additions and 1 deletions

View File

@ -117,6 +117,7 @@ in {
then null then null
else date; else date;
content = l.readFile (parseMarkdown id (getPath path name)); content = l.readFile (parseMarkdown id (getPath path name));
description = args.config.descriptionsById.${id} or null;
} }
)) ))
(l.sort ( (l.sort (
@ -145,6 +146,7 @@ in {
displayName = l.head (l.splitString "." name); displayName = l.head (l.splitString "." name);
id = l.replaceStrings [" "] ["_"] displayName; id = l.replaceStrings [" "] ["_"] displayName;
content = l.readFile (parseMarkdown id (getPath path name)); content = l.readFile (parseMarkdown id (getPath path name));
description = args.config.descriptionsById.${id} or null;
} }
) )
(l.readDir path) (l.readDir path)

View File

@ -26,6 +26,7 @@
mkPage = { mkPage = {
content, content,
titleStr ? ctx.config.title, titleStr ? ctx.config.title,
description ? null,
}: }:
with html; '' with html; ''
<!DOCTYPE html> <!DOCTYPE html>
@ -33,6 +34,10 @@
(head (stylesheets (head (stylesheets
++ [ ++ [
(title titleStr) (title titleStr)
(l.optionalString (description != null) (meta {
name = "description";
content = ctx.config.description;
}))
(meta { (meta {
name = "viewport"; name = "viewport";
content = "width=device-width, initial-scale=1"; content = "width=device-width, initial-scale=1";
@ -118,6 +123,7 @@
l.nameValuePair post.id { l.nameValuePair post.id {
content = renderPost post; content = renderPost post;
name = post.displayName; name = post.displayName;
description = post.description;
}) })
ctx.posts ctx.posts
); );
@ -127,6 +133,7 @@
l.nameValuePair page.id { l.nameValuePair page.id {
content = page.content; content = page.content;
name = page.displayName; name = page.displayName;
description = page.description;
}) })
ctx.pages ctx.pages
); );
@ -156,7 +163,7 @@
( (
name: value: { name: value: {
"index.html" = mkPage { "index.html" = mkPage {
content = value.content; inherit (value) content description;
titleStr = "${value.name} - ${ctx.config.title}"; titleStr = "${value.name} - ${ctx.config.title}";
}; };
} }