// The website: one Typst bundle run writes every page, the stylesheet, the // fonts and the media. Pages come from `chapters` in ../typ/style.typ, so a // new chapter is a new page; the only prose of its own is the landing page. // typst compile --root . --format bundle --features bundle,html docs/site/site.typ OUT // Every link is relative and every page sits at the top of OUT, so the site // works from file:// and from any static server. #import "../typ/style.typ": chapters, tutor-path, doc-links, project #let clips = toml("media/clips.toml").clip #let casts = toml("casts/casts.toml").cast #let themes = toml("media/themes/themes.toml") /// The version, from build.zig.zon: 0.23.0 reads 0.23. #let version = { let v = read("/build.zig.zon").match(regex("\\.version\\s*=\\s*\"([^\"]+)\"")).captures.first() if v.ends-with(".0") and v.split(".").len() == 3 { v.slice(0, -2) } else { v } } // --- the landing page's own words: everything a visitor reads first ---------- // Change the landing here; the rest of the site is the chapters. #let landing = ( lead: [pardes is a text environment, after acme and helix, where any text is live: right-click looks at it (opens the file at that line, the URL, or finds the word) and middle-click runs it (a builtin or a shell command). Read PDFs and source, edit code and use terminals with it, in a terminal or in its own window.], status: [Linux; macOS in progress. Version #version.], terminal: [In a terminal], window: [In its own window], start: ( (id: "guide", label: [Start: the guide], note: [about 15 min]), (id: "tutor", label: [Hands on: the tutor], note: [run `Tutor` inside pardes]), ), install: [Install], ) #let pages = ( (id: "index", title: "pardes"), ..chapters.filter(c => c.file != none).map(c => (id: c.id, title: c.title, file: c.file)), (id: "tutor", title: "The tutor"), ) #let href(id) = id + ".html" // --- the files that are not pages -------------------------------------------- #asset("site.css", read("site.css", encoding: none)) #for f in ("DepartureMono-Regular.woff2", "CrimsonPro-VF-normal.woff2", "CrimsonPro-VF-italic.woff2", "LICENSE-DepartureMono.txt", "LICENSE-CrimsonPro.txt") { asset("fonts/" + f, read("fonts/" + f, encoding: none)) } #asset("media/placeholder.svg", read("media/placeholder.svg", encoding: none)) #for f in ("asciinema-player.min.js", "asciinema-player.css", "LICENSE-asciinema-player.txt") { asset("player/" + f, read("player/" + f, encoding: none)) } #if themes.at("ready", default: true) { for t in themes.theme { asset("media/themes/" + t.file, read("media/themes/" + t.file, encoding: none)) } } #for c in clips.filter(c => c.ready) { for ext in ("webm", "mp4", "png") { asset("media/" + c.name + "." + ext, read("media/" + c.name + "." + ext, encoding: none)) } } // --- the shell every page sits in --------------------------------------------- /// An HTML element: el("a", (href: "x.html"))[text], or el("li")[text]. #let el(tag, ..args) = { let p = args.pos() html.elem(tag, attrs: if p.len() > 1 { p.first() } else { (:) }, p.last()) } /// The running head: a tagline, the way a pane's tag reads, with the path /// of this page and the chapters as its words. #let trail(id, title) = el("header", (class: "trail"))[ #el("span", (class: "grip", "aria-hidden": "true"))[] #el("a", (class: "home", href: href("index")))[pardes] #if id != "index" { el("span", (class: "sep", "aria-hidden": "true"))[/] el("span", (class: "here", "aria-current": "page"))[#title] } #el("nav", (class: "words", "aria-label": "Chapters"))[ #for p in pages.slice(1) { if p.id == id { el("a", (href: href(p.id), "aria-current": "page"))[#p.title] } else { el("a", (href: href(p.id)))[#p.title] } } ] ] #let shell(id, title, body) = html.html(lang: "en", { html.head({ html.meta(charset: "utf-8") el("meta", (name: "viewport", content: "width=device-width, initial-scale=1"))[] el("meta", (name: "color-scheme", content: "dark light"))[] html.title(if id == "index" { "pardes" } else { title + " · pardes" }) el("link", (rel: "stylesheet", href: "site.css"))[] }) html.body({ el("div", (class: "shell"))[ #trail(id, title) #el("main", (class: "panel", "data-page": id))[ #el("article", (class: "content"))[#body] ] #el("footer", (class: "colophon"))[ pardes #version · source: #project.mirrors.map(m => el("a", (href: m.web))[#m.name]).join(", ") · #if project.license != none [#project.license license · ] built from `docs/typ` with Typst · #el("a", (href: "fonts/LICENSE-DepartureMono.txt"))[fonts] (OFL) · #el("a", (href: "player/LICENSE-asciinema-player.txt"))[asciinema-player] (Apache-2.0) ] ] }) }) /// The headings of this page only, as a contents list, when there are /// enough of them to need one. #let toc(id) = context { let hs = query(selector(heading.where(level: 2)).after(label("start-" + id)).before(label("end-" + id))) if hs.len() >= 4 { el("nav", (class: "toc", "aria-label": "On this page"))[ #el("div", (class: "toc-bar"))[#el("span")[On this page]] #el("ol")[#for h in hs { el("li")[#link(h.location(), h.body)] }] ] } } // --- the pages ------------------------------------------------------------------ #doc-links.update(true) #let video(c) = el("video", (poster: "media/" + c.name + ".png", muted: "", loop: "", playsinline: "", controls: "", preload: "none"))[ #el("source", (src: "media/" + c.name + ".webm", type: "video/webm"))[] #el("source", (src: "media/" + c.name + ".mp4", type: "video/mp4"))[] ] #let placeholder = el("img", (src: "media/placeholder.svg", alt: "", width: "640", height: "400"))[] /// A terminal recording: a box the player fills, its data inline (so it /// plays from file://), its caption under it. The first ready one plays. #let ready-casts = casts.filter(c => c.ready) #let cast(c, i) = el("figure", (class: if i == 0 { "clip cast first" } else { "clip cast" }))[ #if c.ready { el("div", (class: "player", id: "cast-" + c.name, "aria-label": c.title))[] } else { placeholder } #el("figcaption")[#el("strong")[#c.title.] #c.caption] ] #let player-script = { let list = ready-casts.enumerate().map(((i, c)) => ( id: "cast-" + c.name, data: read("casts/" + c.name + ".cast"), cols: c.cols, rows: c.rows, autoPlay: i == 0, )) // " p.id not in landing.start.map(s => s.id)) { el("a", (href: href(p.id)))[#p.title] } ] #el("h2", (class: "shelf"))[#landing.terminal] #el("div", (class: "casts"))[#for (i, c) in casts.enumerate() { cast(c, i) }] #el("h2", (class: "shelf"))[#landing.window] #el("div", (class: "clips"))[ #for c in clips { el("figure", (class: "clip"))[ #if c.ready { video(c) } else { placeholder } #el("figcaption")[#c.caption] ] } ] #el("h2", (class: "install"))[#landing.install] #include "../typ/install.typ" #if ready-casts.len() > 0 { el("link", (rel: "stylesheet", href: "player/asciinema-player.css"))[] player-script } ]) #for p in pages.slice(1, -1) { document(href(p.id), title: p.title, shell(p.id, p.title)[ #metadata(none) #label("start-" + p.id) #heading(level: 1, p.title) #label("ch-" + p.id) #toc(p.id) #{ set heading(offset: 1) include "../typ/" + p.file } #metadata(none) #label("end-" + p.id) ]) } #document(href("tutor"), title: "The tutor", shell("tutor", "The tutor")[ #heading(level: 1)[The tutor] The tutor as the editor shows it (#raw("Tutor"), or #raw("SPC h t")). #el("pre", (class: "tutor"))[#read(tutor-path)] ])