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
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)

View File

@ -26,6 +26,7 @@
mkPage = {
content,
titleStr ? ctx.config.title,
description ? null,
}:
with html; ''
<!DOCTYPE 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}";
};
}