1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
#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 breadcrumbs() = {
let path = sys.inputs.at("path")
let parts = path.split("/")
link(webroot)[redman.xyz]
for (i, part) in parts.enumerate() {
let is_last = i == parts.len() - 1
let url = parts.slice(0, i + 1).join("/") + "/index.html"
if is_last {
" / "
part
} else {
" / "
link(webroot + url, part)
}
}
}
#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 {
show: if it.block { it => it } else { box }
if it.block {
html.elem("div", attrs: (class: "block-math"))[
#html.frame(it)
]
} else {
html.frame(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(breadcrumbs())
})
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
]
})
}
|