use document as default for metadata

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2026-03-17 00:03:01 +01:00
parent 49f457cda7
commit 73943c5022
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2

View file

@ -13,9 +13,9 @@
og-type: "website",
/// Name of the site for metadata of the page
site-name: none,
/// Description of the site for metadata #TODO default to document.description
/// Description of the site for metadata, default to document.description
description: none,
/// Author of the site for metadata #TODO default to document.author
/// Author of the site for metadata, default to document.author
author: none,
/// Additional stylesheet for the page: must be a list of url
stylesheets: (),
@ -24,7 +24,11 @@
) = {
html.head({
html.meta(charset: "utf-8")
html.title(title)
if title != none {
html.title(title)
} else { context {
html.title(document.title)
}}
// html.meta(http-equiv: "Content-Language", content: "en") Obsolet, now use the html tag attr "lang" instead
// The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device).
@ -39,7 +43,14 @@
}
// Open Graph (https://ogp.me/), used by social media for link previsualisation
chtml.meta-og(property: "og:title", content: repr(title))
if title != none {
chtml.meta-og(property: "og:title", content: title)
} else { context {
if document.title != none {
assert(document.title.has("text"), message: "document.title must be a string")
chtml.meta-og(property: "og:title", content: document.title.at("text"))
}
}}
chtml.meta-og(property: "og:type", content: og-type)
chtml.meta-og(property: "og:url", content: url)
if icon != none {
@ -61,10 +72,19 @@
}
if description != none {
html.meta(name: "description", content: description)
}
} else { context {
if document.description != none {
assert(document.description.has("text"), message: "document.description must be a string")
html.meta(name: "description", content: document.description.at("text"))
}
}}
if author != none {
html.meta(name: "author", content: author)
}
} else { context {
if document.author != () {
html.meta(name: "author", content: document.author.join(", "))
}
}}
```raw-css
:root {