diff --git a/content/00-index.typ b/content/00-index.typ index f3e813a..4e0e59c 100644 --- a/content/00-index.typ +++ b/content/00-index.typ @@ -1,4 +1,4 @@ -#let warn = block +#import "/lib.typ": warn #title() diff --git a/docs.typ b/docs.typ deleted file mode 100644 index ca53154..0000000 --- a/docs.typ +++ /dev/null @@ -1,120 +0,0 @@ -#let site-title = [The Wireless Masterclass] - -#import "/static/index.typ": stylesheets - -#let chapter-title = state("chapter-title", context document.title) - -#let docs-page(path, header: auto, footer: auto) = main => document(path, html.html( - lang: "en_US", - { - context chapter-title.update(old => context { - let head = query(heading.where(level: 1).after(here())).first(default: none) - return head.body - }) - - html.head({ - html.meta(charset: "utf-8") - html.meta(name: "viewport", content: "width=device-width, initial-scale=1") - html.meta(name: "color-scheme", content: "dark light") - for stylesheet in stylesheets { html.link(rel: "stylesheet", href: stylesheet) } - html.title(context document.title) - }) - html.body({ - if (header != none) { - html.header(if (header == auto) { - context { - let doc = query(document).first() - link(doc.location(), doc.title) - title(chapter-title.get()) - } - - context { - let doc = query(selector(document).before(here())).last() - outline(title: none, target: selector(heading).within(doc.location())) - } - - html.nav(aria-label: "Page Navigation", context { - html.ol(style: "list-style-type: none", { - let nexts = query(selector(document).after(here())) - if (nexts.len() > 0) { - html.li( - link(nexts.at(0).location(), [Next: #nexts.at(0).title]), - ) - } - - let prevs = query(selector(document).before(here())) - if (prevs.len() > 1) { - html.li( - link(prevs.at(-2).location(), [Previous: #prevs.at(-1).title]), - ) - } - }) - }) - } else { - header - }) - } - html.main(main) - if (footer != none) { - divider() - - html.footer({ - if (footer == auto) { - html.nav(aria-label: "Page Navigation", context { - html.ol(style: "list-style-type: none", { - let nexts = query(selector(document).after(here())) - if (nexts.len() > 0) { - html.li( - link(nexts.at(0).location(), [Next: #nexts.at(0).title]), - ) - } - - let prevs = query(selector(document).before(here())) - if (prevs.len() > 1) { - html.li( - link(prevs.at(-2).location(), [Previous: #prevs.at(-1).title]), - ) - } - }) - }) - } else { - footer - } - }) - } - }) - }, -)) - -#let callout(kind: str, label: str, body) = html.section(class: kind + " callout", context { - let depth = counter(heading).at(here()).len() + 1 - heading( - depth: depth, - outlined: false, - numbering: none, - label, - ) - " " - body -}) - -#let note = callout.with(kind: "note", label: "Note:") -#let warn = callout.with(kind: "warn", label: "Warning:") -#let tip = callout.with(kind: "tip", label: "Tip:") - - -#let callout(kind: str, label: str, body) = html.section(class: kind + " callout", context { - let depth = counter(heading).at(here()).len() + 1 - heading( - depth: depth, - outlined: false, - numbering: none, - label, - ) - " " - body -}) - -#let note = callout.with(kind: "note", label: "Note:") -#let warn = callout.with(kind: "warn", label: "Warning:") -#let tip = callout.with(kind: "tip", label: "Tip:") diff --git a/lib.typ b/lib.typ new file mode 100644 index 0000000..55c4bf1 --- /dev/null +++ b/lib.typ @@ -0,0 +1,15 @@ +#let callout(kind: str, label: str, body) = html.section(class: kind + " callout", context { + let depth = counter(heading).at(here()).len() + 1 + heading( + depth: depth, + outlined: false, + numbering: none, + label, + ) + " " + body +}) + +#let note = callout.with(kind: "note", label: "Note:") +#let warn = callout.with(kind: "warn", label: "Warning:") +#let tip = callout.with(kind: "tip", label: "Tip:") \ No newline at end of file diff --git a/main.typ b/main.typ index 4d49eb7..51f11a9 100644 --- a/main.typ +++ b/main.typ @@ -1,9 +1,11 @@ #set heading(numbering: "1.1 -") #set document(title: [The EID Wireless Masterclass]) +#asset("/mojangles-ascii.woff2", read("static/mojangles-ascii.woff2", encoding: none)) #asset("/style.css", read("static/style.css", encoding: none)) -#let html-title = state("html-title", context document.title) +#let index() = query(document).first() +#let chapter = state("chapter", context (doc: index(), top: none, loc: index().location())) #let rawdoc(path, body) = document(path, html.html({ html.head({ @@ -11,49 +13,42 @@ html.meta(name: "viewport", content: "width=device-width, initial-scale=1") html.meta(name: "color-scheme", content: "dark light") html.link(rel: "stylesheet", href: "/style.css") - html.title(context html-title.get()) + html.title(context document.title) + }) + html.body({ + body }) - html.body({ body }) })) #show document: it => { - html-title.update(old => context { + set document(title: context { let top = query(selector(heading.where(level: 1, outlined: true)).within(it.location())).first(default: none) - if top != none { return [#top.body - #document.title] } else { return old } + chapter.update(old => (doc: it, top: top, loc: it.location())) + if top != none { + [#top.body - #it.title] + } else { + [#it.title] + } }) it } #let doc(path, main) = rawdoc(path, { - html.header() + html.header(context { + link(index().location(), title(index().title)) + let target = selector(heading).within(chapter.get().loc).or(heading.where(level: 1)) + outline(title: none, target: target) + }) html.main(id: "main", main) - html.footer() -}) + html.footer(context { + let next = query(selector(heading.where(level: 1, outlined: true)).after(here())).first(default: none) -// #let doc(path, main) = rawdoc(path, ..args, html.html({ -// html.head({ -// html.meta(charset: "utf-8") -// html.meta(name: "viewport", content: "width=device-width, initial-scale=1") -// html.meta(name: "color-scheme", content: "dark light") -// html.link(rel: "stylesheet", href: "/style.css") -// html.title(context document.title) -// }) -// html.body({ -// html.header(context { -// let doc = query(document).first() -// par(link(doc.location(), doc.title)) -// -// let doc = query(selector(document).before(here())).last() -// let ch = query(selector(heading.where(level: 1, outlined: true)).within(doc.location())).first() -// outline(title: none, target: selector(heading).within(doc.location())) -// -// let next = query(selector(document).after(doc.location(), inclusive: false)).first(default: none) -// let prev = query(selector(document).before(doc.location(), inclusive: false)).last(default: none) -// }) -// html.main(id: "main", { main }) -// html.footer({}) -// }) -// })) + if next != none { + show outline.entry: it => [Next: #it] + outline(title: none, target: next.location()) + } + }) +}) #{ rawdoc("/index.html", include "content/00-index.typ")