Something went wrong. Try again.
Beautiful changelogs and releases for everything
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472<script lang="ts"> import type { Snippet } from 'svelte' import { onMount } from 'svelte' import { page } from '$app/state' import { docHref, docsPages, neighbors } from './manifest' import DocsContact from './DocsContact.svelte'
// mdsvex layout: every /docs page's markdown renders through this // shell — crumb, title, sibling ledger, prose voice, prev/next, // contact footer. let { title = 'Documentation', description = '', children, }: { title?: string; description?: string; children?: Snippet } = $props()
const current = $derived(page.url.pathname) const nav = $derived(neighbors(current))
let prose: HTMLElement // The page's sections, read from the rendered headings so the rail // can nest them under the current page's row; the one being read is // tracked by observation. let sections: { id: string; text: string }[] = $state([]) let reading: string = $state('')
// Progressive enhancement: a drawn copy control on every code // block. No JS, no button — the text remains selectable either way. onMount(() => { const heads = [...prose.querySelectorAll<HTMLElement>('h2[id]')] sections = heads.map((h) => ({ id: h.id, text: h.textContent?.trim() ?? '' })) const spy = new IntersectionObserver( (entries) => { for (const e of entries) { if (e.isIntersecting) reading = e.target.id } }, { rootMargin: '0% 0% -75% 0%' }, ) heads.forEach((h) => spy.observe(h))
// The strip is server-rendered by the highlighter; JS only drops // the copy button into the waiting header — nothing shifts. for (const block of prose.querySelectorAll('.code-block')) { const head = block.querySelector('.code-head') const code = block.querySelector('code') if (!head || !code) continue const btn = document.createElement('button') btn.className = 'code-copy' btn.type = 'button' // The hollow square marks the control (the drawn-state grammar: // hollow pending, filled affirmed) and fills while copied. const sq = document.createElement('span') sq.className = 'sq hollow' sq.setAttribute('aria-hidden', 'true') const label = document.createElement('span') label.setAttribute('aria-live', 'polite') label.textContent = 'Copy' btn.append(sq, label) btn.addEventListener('click', async () => { await navigator.clipboard.writeText(code.textContent ?? '') label.textContent = 'Copied' btn.classList.add('done') setTimeout(() => { label.textContent = 'Copy' btn.classList.remove('done') }, 1600) }) head.append(btn) } })</script>
<svelte:head> <title>{title} — dist.town docs</title> {#if description}<meta name="description" content={description} />{/if}</svelte:head>
<article class="doc"> <header class="doc-head"> <p class="crumb"> <a href="/docs">docs</a><span class="crumb-sep dim">/</span><span class="dim">{title}</span> </p> <h1 class="display-sub">{title}</h1> </header>
<hr class="rule-fat" />
<div class="doc-prose prose" bind:this={prose}> {@render children?.()} </div>
{#snippet pageList()} <ul class="page-ledger"> {#each docsPages as p (p.slug)} {@const active = docHref(p) === current} <li> <a href={docHref(p)} class:active aria-current={active ? 'page' : undefined}> <!-- every row reserves the square's gutter so text never shifts between states --> <span class="sq" class:ghost={!active} aria-hidden="true"></span>{p.title} </a> {#if active && sections.length >= 3} <!-- the current page's row expands into its sections; the one in the viewport carries the ink --> <ul class="sections"> {#each sections as s (s.id)} <li> <a href="#{s.id}" class:reading={reading === s.id}>{s.text}</a> </li> {/each} </ul> {/if} </li> {/each} </ul> {/snippet}
<!-- the sibling ledger: the section's map on every page, current row carrying the filled square --> <nav class="doc-nav" aria-label="documentation pages"> <h2 class="label dim">Docs</h2> {@render pageList()} </nav>
<!-- narrow viewports fold the same map behind the release page's drawer grammar, so mid-read readers always have an exit --> <nav class="doc-nav-mobile" aria-label="documentation pages"> <details class="drawer"> <summary> <span>Docs</span> <span class="ind" aria-hidden="true"></span> </summary> <div class="drawer-body"> {@render pageList()} </div> </details> </nav>
<div class="doc-tail"> {#if nav.prev || nav.next} <nav class="prevnext" aria-label="reading order"> {#if nav.prev} <a class="pn prev" href={docHref(nav.prev)}> <span class="pn-label label dim">Previous</span> <span class="pn-title">{nav.prev.title}</span> </a> {:else}<span></span>{/if} {#if nav.next} <a class="pn next" href={docHref(nav.next)}> <span class="pn-label label dim">Next</span> <span class="pn-title">{nav.next.title}</span> </a> {/if} </nav> {/if} <DocsContact /> </div></article>
<style> .doc { display: grid; grid-template-columns: minmax(0, 1fr) 12rem; column-gap: 2.5rem; grid-template-areas: 'head head' 'rule rule' 'mnav mnav' 'prose nav' 'tail tail'; align-items: start; } /* grid items default to min-width auto: wide unbreakable content (code spans, URLs) would set a floor and force panning */ .doc > * { min-width: 0; } .doc-nav-mobile { grid-area: mnav; display: none; } .doc-head { grid-area: head; } .rule-fat { grid-area: rule; margin: 1.5rem 0; width: 100%; } .doc-prose { grid-area: prose; } .doc-nav { grid-area: nav; position: sticky; top: 1.5rem; max-height: calc(100dvh - 3rem); overflow-y: auto; } .doc-tail { grid-area: tail; } .crumb { font-weight: 700; margin-bottom: 0.5rem; } .crumb a { text-decoration: none; } .crumb a:hover { text-decoration: underline; } .crumb-sep { margin: 0 0.3rem; } .doc-nav h2 { padding-bottom: 0.4rem; border-bottom: 1px solid var(--rule); } .page-ledger { list-style: none; padding: 0; } .page-ledger > li { border-bottom: 1px solid var(--rule); } .page-ledger > li:last-child { border-bottom: 0; } .doc-nav .page-ledger > li:last-child { border-bottom: 1px solid var(--rule); } .page-ledger a { display: block; padding: 0.5rem 0; font-size: 0.875rem; font-weight: 700; text-decoration: none; color: var(--ink-dim); } .page-ledger a:hover { color: var(--ink); } .page-ledger a.active { color: var(--ink); font-weight: 800; } .page-ledger .sq.ghost { visibility: hidden; } .page-ledger .sections { list-style: none; /* indent past the square's gutter so sections read as children */ padding: 0 0 0.5rem 1.05em; } .page-ledger .sections li { border: 0; } .page-ledger .sections a { display: block; padding: 0.2rem 0; font-size: 0.8125rem; font-weight: 700; color: var(--ink-dim); text-decoration: none; } .page-ledger .sections a:hover { color: var(--ink); } .page-ledger .sections a.reading { color: var(--ink); } .prevnext { display: flex; justify-content: space-between; gap: 1.5rem; border-top: 4px solid var(--rule); margin-top: 3rem; padding-top: 1rem; max-width: var(--measure); } .pn { text-decoration: none; display: flex; flex-direction: column; gap: 0.2rem; } .pn.next { text-align: right; } .pn-title { font-weight: 800; font-size: 1.125rem; } .pn:hover .pn-title { text-decoration: underline; } /* the reading voice lives in app.css (.prose, shared with the changelog surfaces); only docs-specific furniture is styled here: anchors, the code strip, the table-scroll wrapper. */ /* linkable headings: hovering a heading reveals its anchor as a hollow drawn square that fills on hover */ .doc-prose :global(a.anchor) { display: inline-block; width: 0.5em; height: 0.5em; margin-left: 0.4em; box-shadow: inset 0 0 0 1.5px currentColor; opacity: 0; transition: opacity 120ms ease-out; position: relative; } /* the drawn square stays small; the touch target does not */ .doc-prose :global(a.anchor)::after { content: ''; position: absolute; inset: -0.55em; } .doc-prose :global(h2:hover a.anchor), .doc-prose :global(h3:hover a.anchor), .doc-prose :global(a.anchor:focus-visible) { opacity: 0.6; } .doc-prose :global(a.anchor:hover) { background: currentColor; opacity: 1; } /* two tones only: flags and comments recede, commands stay ink */ .doc-prose :global(pre .tok-dim) { color: var(--ink-dim); } /* the copy control lives in its own strip above the code — it never shares the text's plane, so overlap is impossible */ .doc-prose :global(.code-block) { background: var(--raised); margin-bottom: 1rem; } /* no rules in the strip: the raised slab bounds the block, and the copy control speaks in the dim voice until engaged */ .doc-prose :global(.code-head) { display: flex; justify-content: space-between; align-items: stretch; } .doc-prose :global(.code-lang) { font-weight: 700; font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.4rem 1rem; } .doc-prose :global(.code-block pre) { background: none; margin-bottom: 0; padding-top: 0.6rem; } .doc-prose :global(.code-copy) { font: 700 0.8125rem var(--font); letter-spacing: 0.06em; text-transform: uppercase; background: transparent; color: var(--ink-dim); border: 0; padding: 0.4rem 0.85rem; cursor: pointer; /* center the drawn square against the uppercase label optically, not on the baseline */ display: inline-flex; align-items: center; gap: 0.45em; } .doc-prose :global(.code-copy .sq) { margin-right: 0; } .doc-prose :global(.code-copy.done .sq) { background: currentColor; box-shadow: none; } .doc-prose :global(.code-copy:hover), .doc-prose :global(.code-copy.done) { background: var(--ink); color: var(--ground); } .doc-prose :global(.table-scroll) { overflow-x: auto; margin-bottom: 1rem; } .doc-prose :global(.table-scroll table) { margin-bottom: 0; } /* the release page's drawer grammar: bordered summary with the drawn plus/minus indicator, bordered body attached beneath */ .doc-nav-mobile .drawer { margin-bottom: 1.5rem; } .doc-nav-mobile summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; border: 1px solid var(--rule); padding: 0.55rem 0.8rem; font-size: 0.8125rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; transition: background 120ms ease-out, color 120ms ease-out; } .doc-nav-mobile summary::-webkit-details-marker { display: none; } .doc-nav-mobile summary:hover { background: var(--ink); color: var(--ground); } .doc-nav-mobile .ind { position: relative; width: 0.65em; height: 0.65em; flex: none; } .doc-nav-mobile .ind::before, .doc-nav-mobile .ind::after { content: ''; position: absolute; background: currentColor; } .doc-nav-mobile .ind::before { left: 0; right: 0; top: calc(50% - 0.75px); height: 1.5px; } .doc-nav-mobile .ind::after { top: 0; bottom: 0; left: calc(50% - 0.75px); width: 1.5px; transition: transform 120ms ease-out; } .doc-nav-mobile .drawer[open] .ind::after { transform: scaleY(0); } .doc-nav-mobile .drawer-body { border: 1px solid var(--rule); border-top: 0; padding: 0.2rem 0.8rem; } @media (max-width: 720px) { .doc { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'head' 'rule' 'mnav' 'prose' 'tail'; } .doc-nav { display: none; } .doc-nav-mobile { display: block; } }</style>