diff options
Diffstat (limited to 'site/common.typ')
| -rw-r--r-- | site/common.typ | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/site/common.typ b/site/common.typ new file mode 100644 index 0000000..f7a12b3 --- /dev/null +++ b/site/common.typ @@ -0,0 +1,95 @@ + +#let webroot = "/" + +#let format-date-en(date) = { + let months = ( + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December", + ) + + [#months.at(date.month() - 1) #date.day(), #date.year()] +} + +#let link-self(page, body) = { + link(webroot + page + ".html", body) +} + +#let static(path) = { + webroot + "static/" + path +} + +#let img(src) = { + html.elem("img", attrs: (src: src, alt: "")) +} + +#let post(body, title: none, author: "Paweł Redman", date: none) = { + assert(date != none, message: "missing date") + + set document( + title: title, + author: "Paweł Redman", + ) + + set text(lang: "en") + set heading(numbering: "1.1.") + set math.equation(numbering: "(1.)") + + // As of 0.14, equations aren't supported in HTML. Emit them as SVG instead. + show math.equation: it => context { + if target() == "html" { + show: if it.block { it => it } else { box } + html.frame(it) + } else { + it + } + } + + [ + #metadata(( + title: title, + date_year: date.year(), + date_month: date.month(), + date_day: date.day(), + )) <post-meta> + ] + + html.html({ + html.head({ + html.meta(charset: "utf-8") + html.meta(name: "viewport", content: "width=device-width, initial-scale=1") + html.title(title) + html.link(rel: "stylesheet", href: static("style.css")) + }) + + html.header({ + html.nav[ + (nav element) // TODO when there's an index page + ] + }) + + html.main({ + html.article({ + html.header({ + html.h1(title) + html.p(id: "author")[by #author, published on #html.time(datetime: date)[#format-date-en(date)]] + }) + + body + }) + }) + + html.footer[ + footer goes here + ] + }) +}
\ No newline at end of file |
