diff options
Diffstat (limited to 'site/common.typ')
| -rw-r--r-- | site/common.typ | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/site/common.typ b/site/common.typ index a1c2097..3f2bd61 100644 --- a/site/common.typ +++ b/site/common.typ @@ -21,7 +21,14 @@ } #let link-self(page, body) = { - link(webroot + page + ".html", body) + let parts = page.split("#") + let url = if parts.len() == 1 { + webroot + page + ".html" + } else { + webroot + parts.at(0) + ".html#" + parts.slice(1).join("#") + } + + link(url, body) } #let static(path) = { @@ -32,6 +39,10 @@ html.elem("img", attrs: (src: src, alt: "")) } +#let anchor(name) = { + html.elem("span", attrs: (id: name))[] +} + #let breadcrumbs() = { let path = sys.inputs.at("path") let parts = path.split("/") @@ -69,9 +80,7 @@ }) } -#let post(body, title: none, author: "Paweł Redman", date: none) = { - assert(date != none, message: "missing date") - +#let post(body, title: none, author: "Paweł Redman", date: none, updated: none) = { set document( title: title, author: author, @@ -93,14 +102,22 @@ } } - [ - #metadata(( - title: title, - date_year: date.year(), - date_month: date.month(), - date_day: date.day(), - )) <post-meta> - ] + if date != none { + [ + #metadata(( + title: title, + date_year: date.year(), + date_month: date.month(), + date_day: date.day(), + )) <post-meta> + ] + } else { + [ + #metadata(( + title: title, + )) <post-meta> + ] + } template( title, @@ -108,7 +125,14 @@ html.article({ html.header({ html.h1(title) - html.p(id: "author")[by #author, published on #html.time(datetime: date)[#format-date-en(date)]] + if date != none { + html.p(id: "author")[ + by #author, published on #html.time(datetime: date)[#format-date-en(date)] + #if updated != none { + [, updated on #html.time(datetime: updated)[#format-date-en(updated)]] + } + ] + } }) body }), |
