141 lines
6.3 KiB
Typst
141 lines
6.3 KiB
Typst
#let pages = json(bytes(sys.inputs.at("pages", default: bytes("[]"))))
|
|
#let static = json(bytes(sys.inputs.at("static", default: bytes("[]"))))
|
|
#let data = json(bytes(sys.inputs.at("data", default: bytes("[]"))))
|
|
#let site-name = "Annwan’s Wiki"
|
|
#let site-root = "https://wiki.annwan.me/"
|
|
|
|
#for page in pages [
|
|
#let page-slug = page.replace("/", "-")
|
|
#import "pages/" + page + ".typ": opts, doc
|
|
#metadata((path: page, tags: opts.at("tags", default: ""), title: opts.title)) <page>
|
|
#document(page + ".html", title: site-name + "—" + opts.title)[
|
|
#show raw.where(block: true): it => {
|
|
html.pre(html.code(class:"language-" + it.lang, it.text))
|
|
}
|
|
#show raw.where(block: false): it => {
|
|
html.code(class:"language-" + it.lang, it.text)
|
|
}
|
|
#context {
|
|
import html: *
|
|
html(
|
|
head({
|
|
meta(charset: "utf-8")
|
|
meta(name: "viewport", content: "width=device-width, initial-scale=1")
|
|
meta(name: "authors", content: opts.at("authors", default: ("Annwan",)).join(", "))
|
|
link(rel: "stylesheet", href: "/assets/style/style.css")
|
|
link(rel: "stylesheet", href: "/assets/style/highlight.css")
|
|
script(src: "/assets/scripts/highlight.js")
|
|
script(`hljs.highlightAll();`.text)
|
|
script(src: "/assets/scripts/common.js")
|
|
if opts.at("has-page-js", default: false) {
|
|
script(src: "/static/scripts/"+page+".js")
|
|
}
|
|
title(site-name + "—" + opts.title)
|
|
})
|
|
+ body({
|
|
header({
|
|
h1(a(href: "/", site-name))
|
|
nav({
|
|
input(id: "searchbox", type: "text", placeholder: "Search...")
|
|
})
|
|
})
|
|
div(id: "results")[]
|
|
div(id: "main-body", {
|
|
[#metadata(none) #std.label(page-slug + "--start")]
|
|
counter(heading).update((0,))
|
|
counter(std.figure.where(kind: table)).update((0,))
|
|
counter(std.figure.where(kind: image)).update((0,))
|
|
counter(std.figure.where(kind: raw)).update((0,))
|
|
counter(std.figure.where(kind: "gloss")).update((0,))
|
|
main({
|
|
h1(opts.title);
|
|
doc(page-slug + "--")
|
|
})
|
|
[#metadata(none) #std.label(page-slug + "--end")]
|
|
if not opts.at("no-toc", default: false) {
|
|
aside(details(open: true, {
|
|
summary(strong[Contents])
|
|
outline(title: none,
|
|
target: heading.where(level: 1)
|
|
.or(heading.where(level: 2))
|
|
.or(heading.where(level: 3))
|
|
.or(heading.where(level: 4))
|
|
.or(heading.where(level: 5))
|
|
.after(std.label(page-slug + "--start"))
|
|
.before(std.label(page-slug + "--end")))
|
|
}))
|
|
}
|
|
})
|
|
if not opts.at("no-foot", default: false) {
|
|
footer[
|
|
#import sym: *
|
|
#if opts.at("make-pdf", default: false) {
|
|
std.link(std.label("pdf-" + page-slug))[Download this page as PDF]
|
|
}
|
|
|
|
#opts.title on #site-name #copyright Annwan. This work is
|
|
licensed under the terms of the #std.link(
|
|
"https://creativecommons.org/licenses/by-sa/4.0/",
|
|
)[CC BY-SA 4.0 #cc #cc.by #cc.sa] license.
|
|
|
|
Source code available on #std.link(
|
|
"https://git.annwan.me/worldbuilding/wiki"
|
|
)[my gitea instance].
|
|
]
|
|
}
|
|
})
|
|
)}
|
|
] #label(page)
|
|
|
|
|
|
#if opts.at("make-pdf", default: false) [
|
|
#document("pdf/" + page + ".pdf", title: opts.title)[
|
|
#set text(font: "Iosevka Aile", features: (cv47: 10), hyphenate: false);
|
|
#set par(justify: true)
|
|
#show table: set par(justify: false)
|
|
#show raw: set text(font: "Iosevka Slab", size: 1em / 0.8)
|
|
This document is the PDF version of
|
|
#link(site-root + page + ".html", raw(page)) on #site-name as of
|
|
#datetime.today().display("[year]-[month]-[day]").
|
|
#show figure.where(kind: table): set figure(placement: bottom )
|
|
#show strong: set text(weight: 900)
|
|
#show heading: set text(weight: 900)
|
|
#show table.header: set text(weight: 900)
|
|
#line(length: 100%, stroke: gray)
|
|
|
|
#title()
|
|
#metadata(none) #label(page-slug + "--startpdf")
|
|
#counter(figure.where(kind: table)).update((0,))
|
|
#counter(figure.where(kind: image)).update((0,))
|
|
#counter(figure.where(kind: raw)).update((0,))
|
|
#counter(figure.where(kind: "gloss")).update((0,))
|
|
#counter(heading).update((0,))
|
|
#doc(page-slug)
|
|
#metadata(none) #label(page + "--endpdf")
|
|
#if not opts.at("no-toc", default: false) {
|
|
outline(
|
|
target: heading.where(level: 1)
|
|
.or(heading.where(level: 2))
|
|
.or(heading.where(level: 3))
|
|
.or(heading.where(level: 4))
|
|
.or(heading.where(level: 5))
|
|
.after(label(page-slug + "--startpdf"))
|
|
.before(label(page-slug + "--endpdf"))
|
|
)}
|
|
] #label("pdf-" + page-slug)
|
|
|
|
]
|
|
]
|
|
|
|
|
|
#for file in data {
|
|
asset(file + ".json",
|
|
bytes(json.encode(pretty: false, toml(file + ".toml"))))
|
|
}
|
|
|
|
#context asset("index.json", bytes(json.encode(query(<page>).map(it => it.value), pretty: false)))
|
|
#asset("favicon.ico", read("/static/favicon.ico", encoding: none)) <favicon.ico>
|
|
#for file in static [
|
|
#asset("assets/" + file, read("static/" + file, encoding: none)) #label(file)
|
|
]
|