generate the summary and the document objects from inside the webpage() function

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2026-06-17 23:25:39 +02:00
parent 500a6ad181
commit f7db139b0d
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
10 changed files with 234 additions and 144 deletions

View file

@ -81,18 +81,18 @@
```
chtml.summary-card({
chtml.summary-card-preview({
link(summ.template-args.page-label, summ.preview-image)
link(summ.page-label, summ.preview-image)
if summ.img-copyright != none {
html.small[Image: #sym.copyright #summ.img-copyright]
}
})
chtml.summary-card-description({
heading(level: 2, link(summ.template-args.page-label, summ.document-args.title))
heading(level: 2, link(summ.page-label, summ.title))
link(summ.template-args.page-label, summ.document-args.description)
link(summ.page-label, summ.description)
chtml.summary-card-details(summ.document-args.date.display())
chtml.tag-box(for tag in summ.template-args.tags { html.span(class: ("tag",), "#" + tag) })
chtml.summary-card-details(summ.date.display())
chtml.tag-box(for tag in summ.tags { html.span(class: ("tag",), "#" + tag) })
})
})
}
@ -101,10 +101,8 @@
/// Store data form `set document(...)` and `show: webpage.with(...)` in `summ.document-args` and `summ.template-args`,
/// and generate a summary card that can be used as a link for the page.
#let summary(
/// The base url of the site (eg: "http://test.example.com")
base-url: none,
/// The url path of the page (full url of the page is base-url + path), eg: "/index.html"
path: none,
/// The url of the page
url: none,
/// The title of the page
title: none,
/// The image preview of the page.
@ -124,31 +122,24 @@
/// Label of the page (for links)
page-label: none,
) = {
assert(type(base-url) == str, message: "summary() must have a base url")
assert(type(path) == str, message: "summary() must have a path")
assert(type(url) == str, message: "summary() must have an url")
assert(type(title) == str or type(title) == content, message: "summary() must have title")
assert(type(preview-image) != none, message: "summary() must have a preview-image")
assert(type(author) != none, message: "summary() must have at least one author")
assert(type(description) != none, message: "summary() must have a description")
assert(type(date) != none, message: "summary() must have a date")
assert(author != none, message: "summary() must have at least one author")
assert(description != none, message: "summary() must have a description")
assert(date != none, message: "summary() must have a date")
if page-label == none {
page-label = label(path)
}
let summ = (
document-args: (
title: title,
author: author,
description: description,
date: date,
),
template-args: (
base-url: base-url,
path: path,
tags: tags,
page-label: page-label,
),
url: url,
title: title,
description: description,
date: date,
tags: tags,
page-label: page-label,
path: path,
preview-image: preview-image,
img-copyright: img-copyright,
@ -159,9 +150,9 @@
}
#let summary-sort-key(summ) = -(
summ.document-args.date.day()-1 + 31 * (
(summ.document-args.date.month()-1) +
12 * summ.document-args.date.year()
summ.date.day()-1 + 31 * (
(summ.date.month()-1) +
12 * summ.date.year()
)
)