feat(11.1-02): add the documentation theme, chroma highlighting and docs:serve

- WinterCMS-style shell: header with search and theme toggle, grouped
  sidebar, on-page TOC, pager, page actions, callouts, heading
  permalinks, footer and a 404 page
- fenced code highlighted at build time by chroma/v2 into tok-* classes,
  with a copy button; no inline script, style or handler
- vendored DM Sans/DM Mono fonts and Lucide icons with their licences
- client-side search over search-index.json built with textContent only
- summer docs:serve builds into a temp dir, serves on loopback by default,
  returns 404.html with status 404 and rebuilds on change
This commit is contained in:
Jakub Zych
2026-09-30 21:57:55 +02:00
parent d89e18bc8e
commit dd11bdb0c7
39 changed files with 3114 additions and 145 deletions

View File

@@ -0,0 +1,43 @@
ISC License
Copyright (c) 2026 Lucide Icons and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
---
The following Lucide icons are derived from the Feather project:
airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
The MIT License (MIT) (for the icons listed above)
Copyright (c) 2013-present Cole Bemis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,93 @@
Copyright 2020 The DM Mono Project Authors (https://www.github.com/googlefonts/dm-mono) DMMono-LightItalic.ttf: Copyright 2020 The DM Mono Project Authors (https://www.github.com/googlefonts/dm-mono) DMMono-Regular.ttf: Copyright 2020 The DM Mono Project Authors (https://www.github.com/googlefonts/dm-mono) DMMono-Italic.ttf: Copyright 2020 The DM Mono Project Authors (https://www.github.com/googlefonts/dm-mono) DMMono-Medium.ttf: Copyright 2020 The DM Mono Project Authors (https://www.github.com/googlefonts/dm-mono) DMMono-MediumItalic.ttf: Copyright 2020 The DM Mono Project Authors (https://www.github.com/googlefonts/dm-mono)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@@ -0,0 +1,93 @@
Copyright 2014 The DM Sans Project Authors (https://github.com/googlefonts/dm-fonts) DMSans-Italic[opsz,wght].ttf: Copyright 2014 The DM Sans Project Authors (https://github.com/googlefonts/dm-fonts)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@@ -0,0 +1,393 @@
// SummerCMS docs: client-side search over search-index.json.
// The index is fetched lazily on the first open and cached. Result rows are
// built with createElement and textContent only; indexed text is never
// parsed as HTML.
(function () {
"use strict";
var MAX_RESULTS = 20;
var QUERY_KEY = "summer-docs-query";
var dialog = document.getElementById("search");
var input = document.getElementById("search-input");
var list = document.getElementById("search-results");
var status = document.getElementById("search-status");
var live = document.getElementById("search-live");
var trigger = document.querySelector(".search-trigger");
if (!dialog || !input || !list || !status || typeof dialog.showModal !== "function") {
return;
}
var items = null; // null until loaded
var loading = null; // the pending load promise
var loadError = ""; // "server" or "index" after a failed load
var results = [];
var activeIndex = -1;
var isMac = /mac/i.test((navigator.userAgentData && navigator.userAgentData.platform) || navigator.platform || "");
var kbd = trigger && trigger.querySelector("kbd");
if (kbd && isMac) {
kbd.textContent = "⌘ K";
}
try {
input.value = window.sessionStorage.getItem(QUERY_KEY) || "";
} catch (e) {
// No session storage: start empty.
}
function el(tag, className, text) {
var node = document.createElement(tag);
if (className) {
node.className = className;
}
if (text !== undefined) {
node.textContent = text;
}
return node;
}
// appendRich appends text in which `code spans` become <code> elements.
function appendRich(parent, text) {
var parts = text.split("`");
for (var i = 0; i < parts.length; i++) {
if (!parts[i]) {
continue;
}
parent.appendChild(i % 2 ? el("code", "", parts[i]) : document.createTextNode(parts[i]));
}
}
function setStatus(title, body) {
status.textContent = "";
if (title) {
status.appendChild(el("p", "search-status-title", title));
}
if (body) {
var p = el("p");
appendRich(p, body);
status.appendChild(p);
}
}
function announce(text) {
if (live) {
live.textContent = text;
}
}
function clearResults() {
results = [];
activeIndex = -1;
list.textContent = "";
input.setAttribute("aria-expanded", "false");
input.setAttribute("aria-activedescendant", "");
}
function load() {
if (items || loading) {
return loading || Promise.resolve();
}
setStatus("", "Loading the search index…");
loading = fetch(list.getAttribute("data-index"))
.then(
function (res) {
if (!res.ok) {
throw new Error("index");
}
return res.json().catch(function () {
throw new Error("index");
});
},
function () {
throw new Error("server");
}
)
.then(function (data) {
items = buildItems(data);
loadError = "";
})
.catch(function (err) {
loadError = err && err.message === "server" ? "server" : "index";
})
.then(function () {
loading = null;
update();
});
return loading;
}
// buildItems flattens the index: one item per page (title hit) and one
// per section entry (heading and text hits).
function buildItems(data) {
if (!data || !Array.isArray(data.p) || !Array.isArray(data.e)) {
throw new Error("index");
}
var out = [];
data.p.forEach(function (page) {
out.push({ url: page.u, title: page.t, section: page.s, heading: page.t, text: "", pageHit: true });
});
data.e.forEach(function (entry) {
var page = data.p[entry.p];
if (!page) {
return;
}
out.push({
url: page.u + (entry.a ? "#" + entry.a : ""),
title: page.t,
section: page.s,
heading: entry.h || page.t,
text: entry.x || "",
pageHit: false
});
});
return out;
}
function tokenize(q) {
return q.toLowerCase().split(/\s+/).filter(Boolean);
}
// search ranks with AND-token matching: a title hit outranks a heading
// hit, which outranks a text hit.
function search(tokens) {
var scored = [];
for (var i = 0; i < items.length; i++) {
var it = items[i];
var title = it.title.toLowerCase();
var heading = it.pageHit ? "" : it.heading.toLowerCase();
var text = it.text.toLowerCase();
var score = 0;
var all = true;
for (var j = 0; j < tokens.length; j++) {
var t = tokens[j];
var s = 0;
if (title.indexOf(t) >= 0) {
s += 100;
}
if (heading.indexOf(t) >= 0) {
s += 10;
}
if (text.indexOf(t) >= 0) {
s += 1;
}
if (!s) {
all = false;
break;
}
score += s;
}
if (all) {
if (it.pageHit) {
score += 5;
}
scored.push({ item: it, score: score, order: i });
}
}
scored.sort(function (a, b) {
return b.score - a.score || a.order - b.order;
});
return scored.slice(0, MAX_RESULTS).map(function (s) {
return s.item;
});
}
// appendMarked appends text with every token occurrence wrapped in a
// <mark> element.
function appendMarked(parent, text, tokens) {
var lower = text.toLowerCase();
var pos = 0;
while (pos < text.length) {
var best = -1;
var len = 0;
for (var i = 0; i < tokens.length; i++) {
var at = lower.indexOf(tokens[i], pos);
if (at >= 0 && (best < 0 || at < best || (at === best && tokens[i].length > len))) {
best = at;
len = tokens[i].length;
}
}
if (best < 0) {
parent.appendChild(document.createTextNode(text.slice(pos)));
return;
}
if (best > pos) {
parent.appendChild(document.createTextNode(text.slice(pos, best)));
}
parent.appendChild(el("mark", "", text.slice(best, best + len)));
pos = best + len;
}
}
// excerpt starts the text near its first match.
function excerpt(text, tokens) {
var lower = text.toLowerCase();
var first = -1;
tokens.forEach(function (t) {
var at = lower.indexOf(t);
if (at >= 0 && (first < 0 || at < first)) {
first = at;
}
});
if (first > 60) {
var start = text.lastIndexOf(" ", first - 40);
return "…" + text.slice(start > 0 ? start + 1 : first - 40);
}
return text;
}
function render(tokens) {
clearResults();
results = search(tokens);
if (!results.length) {
setStatus('No results for "' + input.value.trim() + '"', "Check the spelling, or try a shorter term such as a module or command name.");
announce("No results");
return;
}
setStatus("", "");
results.forEach(function (it, i) {
var li = el("li", "search-result");
li.id = "search-result-" + i;
li.setAttribute("role", "option");
li.setAttribute("aria-selected", "false");
li.appendChild(el("div", "search-result-path", it.section + " › " + it.title));
var heading = el("div", "search-result-heading");
appendMarked(heading, it.heading, tokens);
li.appendChild(heading);
if (it.text) {
var ex = el("div", "search-result-excerpt");
appendMarked(ex, excerpt(it.text, tokens), tokens);
li.appendChild(ex);
}
li.addEventListener("click", function () {
go(i);
});
li.addEventListener("mousemove", function () {
setActive(i);
});
list.appendChild(li);
});
input.setAttribute("aria-expanded", "true");
setActive(0);
announce(results.length === 1 ? "1 result" : results.length + " results");
}
function setActive(i) {
var rows = list.children;
if (!rows.length) {
return;
}
if (activeIndex >= 0 && rows[activeIndex]) {
rows[activeIndex].setAttribute("aria-selected", "false");
}
activeIndex = (i + rows.length) % rows.length;
var row = rows[activeIndex];
row.setAttribute("aria-selected", "true");
input.setAttribute("aria-activedescendant", row.id);
if (row.scrollIntoView) {
row.scrollIntoView({ block: "nearest" });
}
}
function go(i) {
var it = results[i];
if (!it) {
return;
}
dialog.close();
window.location.href = it.url;
}
function update() {
try {
window.sessionStorage.setItem(QUERY_KEY, input.value);
} catch (e) {
// Session-only query is optional.
}
if (loadError === "server") {
clearResults();
setStatus("", "Search needs a web server. Run `summer docs:serve` and open the address it prints.");
return;
}
if (loadError === "index") {
clearResults();
setStatus("", "The search index could not be loaded. Reload the page to try again.");
return;
}
if (!items) {
clearResults();
setStatus("", "Loading the search index…");
return;
}
var tokens = tokenize(input.value);
if (!tokens.length) {
clearResults();
setStatus("Search the documentation", "Type a module name, a command or a topic, for example `surf`, `migrate` or `relations`.");
announce("");
return;
}
render(tokens);
}
function open() {
if (dialog.open) {
return;
}
dialog.showModal();
input.focus();
input.select();
if (!items && !loadError) {
load();
}
update();
}
if (trigger) {
trigger.addEventListener("click", open);
}
dialog.addEventListener("close", function () {
if (trigger) {
trigger.focus();
}
});
// A click on the backdrop (outside the dialog box) closes the dialog.
dialog.addEventListener("click", function (e) {
if (e.target === dialog) {
dialog.close();
}
});
input.addEventListener("input", update);
input.addEventListener("keydown", function (e) {
if (e.key === "ArrowDown") {
e.preventDefault();
setActive(activeIndex + 1);
} else if (e.key === "ArrowUp") {
e.preventDefault();
setActive(activeIndex - 1);
} else if (e.key === "Enter") {
e.preventDefault();
go(activeIndex);
}
});
function inTextField(target) {
if (!target) {
return false;
}
var tag = target.tagName;
return tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || target.isContentEditable;
}
document.addEventListener("keydown", function (e) {
if ((e.metaKey || e.ctrlKey) && !e.altKey && (e.key === "k" || e.key === "K")) {
e.preventDefault();
open();
} else if (e.key === "/" && !e.metaKey && !e.ctrlKey && !e.altKey && !inTextField(e.target) && !dialog.open) {
e.preventDefault();
open();
}
});
})();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,228 @@
// SummerCMS docs: theme toggle, mobile drawer, TOC scroll spy, active
// sidebar item and copy buttons. No framework; every DOM change uses
// element APIs and textContent.
(function () {
"use strict";
var STORAGE_KEY = "summer-docs-theme";
var THEMES = ["system", "light", "dark"];
var LABELS = { system: "System", light: "Light", dark: "Dark" };
var root = document.documentElement;
var live = document.getElementById("live-region");
function announce(text) {
if (!live) {
return;
}
live.textContent = "";
window.setTimeout(function () {
live.textContent = text;
}, 50);
}
// Theme toggle: System -> Light -> Dark -> System. If storage throws the
// choice still applies for this page view and no error is shown.
function currentTheme() {
var t = root.getAttribute("data-theme");
return THEMES.indexOf(t) >= 0 ? t : "system";
}
function applyTheme(theme, button) {
root.classList.remove("light", "dark");
if (theme !== "system") {
root.classList.add(theme);
}
root.setAttribute("data-theme", theme);
if (button) {
var next = THEMES[(THEMES.indexOf(theme) + 1) % THEMES.length];
var label = "Color theme: " + LABELS[theme] + ". Switch to " + LABELS[next] + ".";
button.setAttribute("data-theme", theme);
button.setAttribute("aria-label", label);
button.setAttribute("title", label);
}
}
var toggle = document.querySelector(".theme-toggle");
if (toggle) {
applyTheme(currentTheme(), toggle);
toggle.addEventListener("click", function () {
var theme = THEMES[(THEMES.indexOf(currentTheme()) + 1) % THEMES.length];
try {
window.localStorage.setItem(STORAGE_KEY, theme);
} catch (e) {
// Session-only choice.
}
applyTheme(theme, toggle);
});
}
// Mobile drawer (below 1024px).
var menu = document.querySelector(".menu-button");
var panel = document.getElementById("sidebar");
var scrim = document.querySelector(".scrim");
function drawerOpen() {
return panel && panel.classList.contains("open");
}
function focusables() {
return panel ? Array.prototype.slice.call(panel.querySelectorAll("a[href], button:not([disabled])")) : [];
}
function openDrawer() {
if (!panel || !menu) {
return;
}
panel.classList.add("open");
if (scrim) {
scrim.hidden = false;
}
document.body.classList.add("drawer-open");
menu.setAttribute("aria-expanded", "true");
menu.setAttribute("aria-label", "Close navigation");
var items = focusables();
if (items.length) {
items[0].focus();
}
}
function closeDrawer(returnFocus) {
if (!drawerOpen()) {
return;
}
panel.classList.remove("open");
if (scrim) {
scrim.hidden = true;
}
document.body.classList.remove("drawer-open");
menu.setAttribute("aria-expanded", "false");
menu.setAttribute("aria-label", "Open navigation");
if (returnFocus) {
menu.focus();
}
}
if (menu && panel) {
menu.addEventListener("click", function () {
if (drawerOpen()) {
closeDrawer(true);
} else {
openDrawer();
}
});
if (scrim) {
scrim.addEventListener("click", function () {
closeDrawer(true);
});
}
panel.addEventListener("click", function (e) {
if (e.target.closest && e.target.closest("a")) {
closeDrawer(false);
}
});
document.addEventListener("keydown", function (e) {
if (!drawerOpen()) {
return;
}
if (e.key === "Escape") {
e.preventDefault();
closeDrawer(true);
return;
}
if (e.key !== "Tab") {
return;
}
// Keep focus inside the drawer and its close button.
var items = [menu].concat(focusables());
var first = items[0];
var last = items[items.length - 1];
if (e.shiftKey && document.activeElement === first) {
e.preventDefault();
last.focus();
} else if (!e.shiftKey && document.activeElement === last) {
e.preventDefault();
first.focus();
} else if (items.indexOf(document.activeElement) < 0) {
e.preventDefault();
first.focus();
}
});
window.matchMedia("(min-width: 1024px)").addEventListener("change", function (m) {
if (m.matches) {
closeDrawer(false);
}
});
}
// Scroll the active sidebar item into view, without animation.
var active = document.querySelector('.sidebar a[aria-current="page"]');
// The sticky sidebar is fully on screen at 1024px and up, so "nearest"
// scrolls only the sidebar, never the page (a #fragment jump is kept).
if (active && active.scrollIntoView && window.matchMedia("(min-width: 1024px)").matches) {
active.scrollIntoView({ block: "nearest" });
}
// TOC scroll spy: the heading nearest the top is current.
var tocLinks = Array.prototype.slice.call(document.querySelectorAll(".toc a"));
if (tocLinks.length && "IntersectionObserver" in window) {
var headings = [];
tocLinks.forEach(function (link) {
var id = decodeURIComponent(link.getAttribute("href").slice(1));
var h = document.getElementById(id);
if (h) {
headings.push({ el: h, link: link });
}
});
var setCurrent = function () {
var current = null;
for (var i = 0; i < headings.length; i++) {
if (headings[i].el.getBoundingClientRect().top <= 112) {
current = headings[i];
}
}
if (!current && headings.length) {
current = headings[0];
}
tocLinks.forEach(function (link) {
link.removeAttribute("aria-current");
});
if (current) {
current.link.setAttribute("aria-current", "location");
}
};
var observer = new IntersectionObserver(setCurrent, { rootMargin: "-64px 0px -60% 0px" });
headings.forEach(function (h) {
observer.observe(h.el);
});
setCurrent();
}
// Copy buttons, only when the clipboard API exists.
if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
Array.prototype.forEach.call(document.querySelectorAll("figure.code .copy-button"), function (button) {
button.hidden = false;
button.addEventListener("click", function () {
var code = button.parentNode.querySelector("pre code");
if (!code) {
return;
}
var copy = code.cloneNode(true);
Array.prototype.forEach.call(copy.querySelectorAll(".tok-prompt"), function (p) {
p.parentNode.removeChild(p);
});
navigator.clipboard.writeText(copy.textContent).then(
function () {
button.classList.add("copied");
announce("Copied");
window.setTimeout(function () {
button.classList.remove("copied");
}, 2000);
},
function () {
announce("Copy failed. Select the code and copy it manually.");
}
);
});
});
}
})();

View File

@@ -0,0 +1,22 @@
// SummerCMS docs: applies the stored colour theme before first paint.
// Loaded synchronously in <head>, before the stylesheet. "system" (the
// default) sets neither class and lets prefers-color-scheme decide.
(function () {
"use strict";
var root = document.documentElement;
var theme = "system";
try {
var stored = window.localStorage.getItem("summer-docs-theme");
if (stored === "light" || stored === "dark") {
theme = stored;
}
} catch (e) {
// Storage is unavailable (private mode, disabled): behave as system.
}
root.classList.add("js");
root.classList.remove("light", "dark");
if (theme !== "system") {
root.classList.add(theme);
}
root.setAttribute("data-theme", theme);
})();

View File

@@ -0,0 +1,22 @@
<!doctype html>
<html lang="en">
<head>
{{template "head" .}}
</head>
<body class="docs docs-404">
{{template "shell-start" .}}
<main id="content" tabindex="-1">
<div class="page">
<article class="page-body">
<h1>{{.Title}}</h1>
<p class="lead">{{.Description}}</p>
<div class="prose">
<p>Use the sidebar or search to find what you need, or go back to the <a href="{{.HomeURL}}">documentation home</a>.</p>
</div>
</article>
</div>
{{template "footer" .}}
</main>
{{template "shell-end" .}}
</body>
</html>

View File

@@ -0,0 +1,6 @@
{{define "footer" -}}
<footer class="site-footer">
<span>SummerCMS documentation</span>
<span class="footer-links"><a href="{{.LLMS}}">llms.txt</a><a href="{{.LLMSFull}}">llms-full.txt</a></span>
</footer>
{{- end}}

View File

@@ -0,0 +1,9 @@
{{define "header" -}}
<header class="site-header">
<button class="menu-button icon-button" type="button" aria-label="Open navigation" aria-expanded="false" aria-controls="sidebar">{{template "icon-menu"}}{{template "icon-x"}}</button>
<a class="wordmark" href="{{.HomeURL}}" aria-label="SummerCMS documentation home"><span class="wordmark-sun">{{template "icon-sun"}}</span><span class="wordmark-text">Summer<span class="wordmark-cms">CMS</span></span></a>
<div class="header-spacer"></div>
<button class="search-trigger" type="button" aria-label="Search docs" aria-haspopup="dialog" aria-controls="search">{{template "icon-search"}}<span class="search-trigger-label">Search docs</span><kbd>Ctrl K</kbd></button>
<button class="theme-toggle" type="button" data-theme="system" aria-label="Color theme: System. Switch to Light." title="Color theme: System. Switch to Light.">{{template "icon-monitor"}}{{template "icon-sun"}}{{template "icon-moon"}}</button>
</header>
{{- end}}

View File

@@ -0,0 +1,16 @@
{{/* Lucide 1.17.0 icons (ISC, see assets/LICENSE-lucide.txt), path data copied from @lucide/vue. */}}
{{define "icon-sun"}}<svg class="icon icon-sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></svg>{{end}}
{{define "icon-moon"}}<svg class="icon icon-moon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/></svg>{{end}}
{{define "icon-monitor"}}<svg class="icon icon-monitor" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>{{end}}
{{define "icon-search"}}<svg class="icon icon-search" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m21 21-4.34-4.34"/><circle cx="11" cy="11" r="8"/></svg>{{end}}
{{define "icon-menu"}}<svg class="icon icon-menu" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 5h16"/><path d="M4 12h16"/><path d="M4 19h16"/></svg>{{end}}
{{define "icon-x"}}<svg class="icon icon-x" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>{{end}}
{{define "icon-chevron-left"}}<svg class="icon icon-chevron-left" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg>{{end}}
{{define "icon-chevron-right"}}<svg class="icon icon-chevron-right" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg>{{end}}
{{define "icon-pencil"}}<svg class="icon icon-pencil" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/></svg>{{end}}
{{define "icon-file-text"}}<svg class="icon icon-file-text" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/></svg>{{end}}
{{define "icon-copy"}}<svg class="icon icon-copy" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>{{end}}
{{define "icon-check"}}<svg class="icon icon-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>{{end}}
{{define "icon-info"}}<svg class="icon icon-info" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>{{end}}
{{define "icon-lightbulb"}}<svg class="icon icon-lightbulb" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/></svg>{{end}}
{{define "icon-triangle-alert"}}<svg class="icon icon-triangle-alert" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>{{end}}

View File

@@ -1,32 +1,62 @@
{{define "head" -}}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark">
<title>{{.DocTitle}}</title>
<meta name="description" content="{{.Description}}">
<meta property="og:title" content="{{.Title}}">
<meta property="og:description" content="{{.Description}}">
{{- if .MarkdownURL}}
<link rel="alternate" type="text/markdown" href="{{.MarkdownURL}}">
{{- end}}
<script src="{{.Assets}}/theme-init.js"></script>
<link rel="stylesheet" href="{{.Assets}}/site.css">
<script src="{{.Assets}}/site.js" defer></script>
<script src="{{.Assets}}/search.js" defer></script>
{{- end -}}
{{define "shell-start" -}}
<a class="skip-link" href="#content">Skip to content</a>
{{template "header" .}}
<div class="layout">
{{template "sidebar" .}}
<div class="scrim" hidden></div>
{{- end -}}
{{define "shell-end" -}}
</div>
{{template "search" .}}
<div class="sr-only" id="live-region" aria-live="polite"></div>
{{- end -}}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{.DocTitle}}</title>
<meta name="description" content="{{.Description}}">
<link rel="stylesheet" href="{{.CSS}}">
{{template "head" .}}
</head>
<body class="docs">
<div class="layout">
<nav class="sidebar" aria-label="Documentation">
<a class="sidebar-home" href="{{.HomeURL}}">SummerCMS</a>
{{- range .Nav}}
<div class="sidebar-section">
<p class="sidebar-title">{{.Title}}</p>
<ul>
{{- range .Items}}
<li><a href="{{.URL}}"{{if .Current}} aria-current="page"{{end}}>{{.Title}}</a></li>
{{template "shell-start" .}}
<main id="content" tabindex="-1">
<div class="page{{if .TOC}} has-toc{{end}}">
<article class="page-body">
{{- if .Eyebrow}}
<p class="eyebrow">{{.Eyebrow}}</p>
{{- end}}
</ul>
</div>
{{- end}}
</nav>
<main id="content">
<h1>{{.Title}}</h1>
<p class="lead">{{.Description}}</p>
{{.Content}}
</main>
<div class="page-actions">
{{- if .EditURL}}
<a href="{{.EditURL}}">{{template "icon-pencil"}}<span>Edit this page</span></a>
{{- end}}
<a href="{{.MarkdownURL}}">{{template "icon-file-text"}}<span>View as Markdown</span></a>
</div>
{{template "toc-inline" .}}
<div class="prose">
{{.Content}}
</div>
{{template "pager" .}}
</article>
{{template "toc" .}}
</div>
{{template "footer" .}}
</main>
{{template "shell-end" .}}
</body>
</html>

View File

@@ -0,0 +1,14 @@
{{define "pager" -}}
{{- if or .Prev .Next}}
<nav class="pager" aria-label="Previous and next page">
{{- if .Prev}}
<a class="pager-card pager-prev" href="{{.Prev.URL}}"><span class="pager-label">{{template "icon-chevron-left"}}Previous</span><span class="pager-title">{{.Prev.Title}}</span>{{if .Prev.Section}}<span class="pager-section">{{.Prev.Section}}</span>{{end}}</a>
{{- else}}
<span class="pager-empty"></span>
{{- end}}
{{- if .Next}}
<a class="pager-card pager-next" href="{{.Next.URL}}"><span class="pager-label">Next{{template "icon-chevron-right"}}</span><span class="pager-title">{{.Next.Title}}</span>{{if .Next.Section}}<span class="pager-section">{{.Next.Section}}</span>{{end}}</a>
{{- end}}
</nav>
{{- end}}
{{- end}}

View File

@@ -0,0 +1,8 @@
{{define "search" -}}
<dialog class="search" id="search">
<div class="search-field">{{template "icon-search"}}<input class="search-input" id="search-input" type="search" placeholder="Search the docs" aria-label="Search the docs" autocomplete="off" spellcheck="false" role="combobox" aria-expanded="false" aria-controls="search-results" aria-autocomplete="list" aria-activedescendant=""></div>
<div class="search-status" id="search-status"></div>
<ul id="search-results" class="search-results" role="listbox" aria-label="Search results" data-index="{{.SearchIndex}}"></ul>
<div class="sr-only" id="search-live" aria-live="polite"></div>
</dialog>
{{- end}}

View File

@@ -0,0 +1,16 @@
{{define "sidebar" -}}
<div class="sidebar-panel" id="sidebar">
<nav class="sidebar" aria-label="Documentation">
{{- range .Nav}}
<div class="sidebar-section{{if .API}} sidebar-api{{end}}">
<p class="sidebar-title">{{.Title}}</p>
<ul>
{{- range .Items}}
<li><a href="{{.URL}}"{{if .Current}} aria-current="page"{{end}}>{{.Title}}</a></li>
{{- end}}
</ul>
</div>
{{- end}}
</nav>
</div>
{{- end}}

View File

@@ -0,0 +1,24 @@
{{define "toc" -}}
{{- if .TOC}}
<aside class="toc" aria-label="On this page">
<p class="toc-title">On this page</p>
<ul>
{{- range .TOC}}
<li class="toc-h{{.Level}}"><a href="#{{.ID}}">{{.Text}}</a></li>
{{- end}}
</ul>
</aside>
{{- end}}
{{- end}}
{{define "toc-inline" -}}
{{- if .TOC}}
<details class="toc-inline">
<summary>On this page</summary>
<ul>
{{- range .TOC}}
<li class="toc-h{{.Level}}"><a href="#{{.ID}}">{{.Text}}</a></li>
{{- end}}
</ul>
</details>
{{- end}}
{{- end}}