67 lines
2.2 KiB
Typst
67 lines
2.2 KiB
Typst
#let tag = tagname => [ #metadata(tagname) <tag> ]
|
|
#let wl(path, txt, frag) = {
|
|
let fragtext = if frag == none {""} else {"#" + frag}
|
|
let texttext = if txt == none {
|
|
path.split("/").at(-1)
|
|
} else {txt}
|
|
link(path + ".html" + fragtext, texttext)
|
|
}
|
|
#let conf(
|
|
page-title: "",
|
|
title-override: none,
|
|
subtitle: none,
|
|
doc,
|
|
) = {
|
|
let sitename = [Annwan's Wiki]
|
|
// matches [[path|text!fragments]] with opt texts and fragment
|
|
let link-re = regex(
|
|
"\\[\\[([^\\]\\|!]+)(?:\\|([^\\]\\|!]+))?(?:!([^\\]\\|!]+))?\\]\\]"
|
|
)
|
|
show figure.where(kind: "gloss"): set figure(supplement: [Example])
|
|
show figure.where(kind: "gloss"): set figure.caption(position: top)
|
|
show figure: it => {
|
|
html.details(open: it.kind == image or it.kind == table, {
|
|
html.summary[*#it.caption.supplement #it.caption.counter.display(it.numbering)*: #it.caption.body]
|
|
it.body
|
|
})
|
|
}
|
|
show regex("%[a-z0-9/]+"): it => tag(it.text.slice(1))
|
|
show link-re: it => wl(..it.text.match(link-re).captures)
|
|
set table(stroke: none)
|
|
html.head({
|
|
html.link(rel: "stylesheet", href: "/assets/style/common.css")
|
|
html.meta(charset: "utf-8")
|
|
html.meta(name: "viewport", content: "width=device-width, initial-scale=1")
|
|
html.meta(name: "search-title", content: if title-override != none {title-override} else {page-title}, id: "search-title")
|
|
context html.meta(content: { let t = query(<tag>).map(it => it.value).join(" "); if type(t) != str {""} else {t}}, name: "search-tags", id: "search-tags")
|
|
|
|
if title-override != none {
|
|
html.title(sitename + " — " + title-override)
|
|
} else {
|
|
html.title(sitename + " — " + page-title)
|
|
}
|
|
html.script(src:"/assets/scripts/fuse.min.js")
|
|
html.script(src: "/assets/scripts/search.js")
|
|
})
|
|
|
|
html.header({
|
|
html.h1(html.a(href: "/", sitename))
|
|
html.nav(html.input(id: "searchbox", type: "text", placeholder: "Search..."))
|
|
})
|
|
html.div(id: "results")[]
|
|
html.div(id: "main-body", {
|
|
html.main({
|
|
html.h1(page-title)
|
|
html.hr()
|
|
doc
|
|
|
|
})
|
|
html.aside(outline())
|
|
})
|
|
}
|
|
#let sitename = [Annwan's Wiki]
|
|
#let s(script, body) = {
|
|
html.span(class: "scr-"+script, body)
|
|
}
|
|
#let sc = smallcaps
|