@cogenta/theme-docs 0.3.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/render/blocks/accordion.d.ts +8 -0
- package/dist/src/render/blocks/accordion.d.ts.map +1 -1
- package/dist/src/render/blocks/accordion.js +10 -10
- package/dist/src/render/blocks/accordion.js.map +1 -1
- package/dist/src/render/blocks/collection-list.d.ts +3 -11
- package/dist/src/render/blocks/collection-list.d.ts.map +1 -1
- package/dist/src/render/blocks/collection-list.js +69 -68
- package/dist/src/render/blocks/collection-list.js.map +1 -1
- package/dist/src/render/blocks/cta.d.ts +6 -0
- package/dist/src/render/blocks/cta.d.ts.map +1 -1
- package/dist/src/render/blocks/cta.js +9 -4
- package/dist/src/render/blocks/cta.js.map +1 -1
- package/dist/src/render/blocks/embed.d.ts.map +1 -1
- package/dist/src/render/blocks/embed.js +14 -13
- package/dist/src/render/blocks/embed.js.map +1 -1
- package/dist/src/render/blocks/faq.d.ts +7 -0
- package/dist/src/render/blocks/faq.d.ts.map +1 -1
- package/dist/src/render/blocks/faq.js +10 -10
- package/dist/src/render/blocks/faq.js.map +1 -1
- package/dist/src/render/blocks/feature-grid.d.ts.map +1 -1
- package/dist/src/render/blocks/feature-grid.js +19 -19
- package/dist/src/render/blocks/feature-grid.js.map +1 -1
- package/dist/src/render/blocks/gallery.d.ts +8 -4
- package/dist/src/render/blocks/gallery.d.ts.map +1 -1
- package/dist/src/render/blocks/gallery.js +19 -13
- package/dist/src/render/blocks/gallery.js.map +1 -1
- package/dist/src/render/blocks/hero.d.ts +12 -9
- package/dist/src/render/blocks/hero.d.ts.map +1 -1
- package/dist/src/render/blocks/hero.js +22 -20
- package/dist/src/render/blocks/hero.js.map +1 -1
- package/dist/src/render/blocks/logo-strip.d.ts +6 -0
- package/dist/src/render/blocks/logo-strip.d.ts.map +1 -1
- package/dist/src/render/blocks/logo-strip.js +6 -10
- package/dist/src/render/blocks/logo-strip.js.map +1 -1
- package/dist/src/render/blocks/logos.d.ts +10 -0
- package/dist/src/render/blocks/logos.d.ts.map +1 -1
- package/dist/src/render/blocks/logos.js +20 -17
- package/dist/src/render/blocks/logos.js.map +1 -1
- package/dist/src/render/blocks/media-figure.d.ts +0 -6
- package/dist/src/render/blocks/media-figure.d.ts.map +1 -1
- package/dist/src/render/blocks/media-figure.js +28 -16
- package/dist/src/render/blocks/media-figure.js.map +1 -1
- package/dist/src/render/blocks/pricing-table.d.ts.map +1 -1
- package/dist/src/render/blocks/pricing-table.js +16 -20
- package/dist/src/render/blocks/pricing-table.js.map +1 -1
- package/dist/src/render/blocks/prose.d.ts +13 -1
- package/dist/src/render/blocks/prose.d.ts.map +1 -1
- package/dist/src/render/blocks/prose.js +12 -31
- package/dist/src/render/blocks/prose.js.map +1 -1
- package/dist/src/render/blocks/quote.d.ts +5 -3
- package/dist/src/render/blocks/quote.d.ts.map +1 -1
- package/dist/src/render/blocks/quote.js +10 -14
- package/dist/src/render/blocks/quote.js.map +1 -1
- package/dist/src/render/blocks/stat-counter.d.ts +5 -0
- package/dist/src/render/blocks/stat-counter.d.ts.map +1 -1
- package/dist/src/render/blocks/stat-counter.js +6 -10
- package/dist/src/render/blocks/stat-counter.js.map +1 -1
- package/dist/src/render/blocks/stats.d.ts +10 -0
- package/dist/src/render/blocks/stats.d.ts.map +1 -1
- package/dist/src/render/blocks/stats.js +13 -8
- package/dist/src/render/blocks/stats.js.map +1 -1
- package/dist/src/render/blocks/testimonial.d.ts +4 -5
- package/dist/src/render/blocks/testimonial.d.ts.map +1 -1
- package/dist/src/render/blocks/testimonial.js +9 -13
- package/dist/src/render/blocks/testimonial.js.map +1 -1
- package/dist/src/render/chrome.d.ts +36 -1
- package/dist/src/render/chrome.d.ts.map +1 -1
- package/dist/src/render/chrome.js +122 -80
- package/dist/src/render/chrome.js.map +1 -1
- package/dist/src/render/doc-index.d.ts +25 -0
- package/dist/src/render/doc-index.d.ts.map +1 -0
- package/dist/src/render/doc-index.js +49 -0
- package/dist/src/render/doc-index.js.map +1 -0
- package/dist/src/render/doc-page.d.ts +6 -0
- package/dist/src/render/doc-page.d.ts.map +1 -0
- package/dist/src/render/doc-page.js +127 -0
- package/dist/src/render/doc-page.js.map +1 -0
- package/dist/src/render/layout.d.ts +23 -0
- package/dist/src/render/layout.d.ts.map +1 -0
- package/dist/src/render/layout.js +40 -0
- package/dist/src/render/layout.js.map +1 -0
- package/dist/src/render/render-block.d.ts +9 -6
- package/dist/src/render/render-block.d.ts.map +1 -1
- package/dist/src/render/render-block.js +47 -100
- package/dist/src/render/render-block.js.map +1 -1
- package/dist/src/render/rich-text.d.ts +26 -0
- package/dist/src/render/rich-text.d.ts.map +1 -0
- package/dist/src/render/rich-text.js +325 -0
- package/dist/src/render/rich-text.js.map +1 -0
- package/dist/src/render/search.d.ts +15 -0
- package/dist/src/render/search.d.ts.map +1 -0
- package/dist/src/render/search.js +31 -0
- package/dist/src/render/search.js.map +1 -0
- package/dist/src/render/strings.d.ts +51 -0
- package/dist/src/render/strings.d.ts.map +1 -0
- package/dist/src/render/strings.js +60 -0
- package/dist/src/render/strings.js.map +1 -0
- package/dist/src/render/term-archive.d.ts +5 -5
- package/dist/src/render/term-archive.d.ts.map +1 -1
- package/dist/src/render/term-archive.js +27 -16
- package/dist/src/render/term-archive.js.map +1 -1
- package/dist/src/render/widget-areas.d.ts +22 -0
- package/dist/src/render/widget-areas.d.ts.map +1 -0
- package/dist/src/render/widget-areas.js +29 -0
- package/dist/src/render/widget-areas.js.map +1 -0
- package/package.json +4 -4
- package/src/index.ts +2 -0
- package/src/render/blocks/accordion.ts +31 -42
- package/src/render/blocks/collection-list.ts +132 -123
- package/src/render/blocks/cta.ts +23 -18
- package/src/render/blocks/embed.ts +37 -28
- package/src/render/blocks/faq.ts +26 -37
- package/src/render/blocks/feature-grid.ts +34 -42
- package/src/render/blocks/gallery.ts +33 -29
- package/src/render/blocks/hero.ts +41 -45
- package/src/render/blocks/logo-strip.ts +21 -21
- package/src/render/blocks/logos.ts +32 -42
- package/src/render/blocks/media-figure.ts +47 -25
- package/src/render/blocks/pricing-table.ts +34 -41
- package/src/render/blocks/prose.ts +25 -40
- package/src/render/blocks/quote.ts +25 -19
- package/src/render/blocks/stat-counter.ts +27 -29
- package/src/render/blocks/stats.ts +35 -32
- package/src/render/blocks/testimonial.ts +18 -19
- package/src/render/chrome.ts +170 -83
- package/src/render/doc-index.ts +65 -0
- package/src/render/doc-page.ts +303 -0
- package/src/render/layout.ts +73 -0
- package/src/render/render-block.ts +67 -191
- package/src/render/rich-text.ts +446 -0
- package/src/render/search.ts +41 -0
- package/src/render/strings.ts +67 -0
- package/src/render/term-archive.ts +62 -38
- package/src/render/widget-areas.ts +33 -0
- package/src/styles/archive.css +21 -27
- package/src/styles/base.css +438 -838
- package/src/styles/blocks.css +658 -916
- package/src/styles/chrome.css +439 -0
- package/src/styles/docs.css +404 -0
- package/src/styles/rich.css +337 -0
- package/src/styles/theme.css +28 -23
- package/src/styles/tokens.css +209 -215
- package/src/styles/widgets.css +890 -0
- package/tokens.json +15 -15
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The documentation's own order, shared by the sidebar, the home page index
|
|
3
|
+
* and previous/next.
|
|
4
|
+
*
|
|
5
|
+
* A doc page carries two plain fields: `section` (the group it belongs to)
|
|
6
|
+
* and `order` (its place in that group). Neither is a sort field contract B
|
|
7
|
+
* allows a `collectionList` to ask for (`id`/`createdAt`/`updatedAt` only),
|
|
8
|
+
* so the list is fetched by creation date and ordered here: pages within a
|
|
9
|
+
* section by `order`, then by the order they were fetched in; sections by the
|
|
10
|
+
* smallest `order` they hold, then by the order they first appear. Two pages
|
|
11
|
+
* created in the same millisecond can come back in either order, so the
|
|
12
|
+
* documentation never depends on creation time alone.
|
|
13
|
+
*/
|
|
14
|
+
export const DOC_PAGE_COLLECTION = 'doc_page';
|
|
15
|
+
export function isDocIndexBlock(block) {
|
|
16
|
+
return block._type === 'collectionList' && block.collection === DOC_PAGE_COLLECTION;
|
|
17
|
+
}
|
|
18
|
+
export function groupDocPages(entries, ctx) {
|
|
19
|
+
const groups = new Map();
|
|
20
|
+
entries.forEach((entry, position) => {
|
|
21
|
+
const section = typeof entry.section === 'string' && entry.section.trim() !== ''
|
|
22
|
+
? entry.section.trim()
|
|
23
|
+
: ctx.t('entry.untitled');
|
|
24
|
+
const list = groups.get(section) ?? [];
|
|
25
|
+
list.push({ entry, position });
|
|
26
|
+
groups.set(section, list);
|
|
27
|
+
});
|
|
28
|
+
const orderOf = (entry) => typeof entry.order === 'number' ? entry.order : Number.POSITIVE_INFINITY;
|
|
29
|
+
return [...groups.entries()]
|
|
30
|
+
.map(([section, list], appearance) => ({
|
|
31
|
+
section,
|
|
32
|
+
appearance,
|
|
33
|
+
first: Math.min(...list.map((item) => orderOf(item.entry))),
|
|
34
|
+
entries: [...list]
|
|
35
|
+
.sort((a, b) => {
|
|
36
|
+
const orderA = orderOf(a.entry);
|
|
37
|
+
const orderB = orderOf(b.entry);
|
|
38
|
+
return orderA === orderB ? a.position - b.position : orderA - orderB;
|
|
39
|
+
})
|
|
40
|
+
.map((item) => item.entry),
|
|
41
|
+
}))
|
|
42
|
+
.sort((a, b) => (a.first === b.first ? a.appearance - b.appearance : a.first - b.first))
|
|
43
|
+
.map(({ section, entries }) => ({ section, entries }));
|
|
44
|
+
}
|
|
45
|
+
/** The reading order of the whole documentation: every group, in turn. */
|
|
46
|
+
export function readingOrder(groups) {
|
|
47
|
+
return groups.flatMap((group) => group.entries);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=doc-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-index.js","sourceRoot":"","sources":["../../../src/render/doc-index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AAEH,M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AC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3D,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;aACf,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACb,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;YAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;YAC/B,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,CAAA;QACtE,CAAC,CAAC;aACD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;KAC7B,CAAC,CAAC;SACF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;SACvF,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAAC,MAA2B;IACtD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AACjD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BlockRegistry, CollectionListBlock, VocabularyBlock } from '@cogenta/blocks';
|
|
2
|
+
import { type FetchedEntries, type HtmlElement, type PageContent, type RenderContext } from '@cogenta/theme-kit';
|
|
3
|
+
import { type HeadingAnchors } from './rich-text.js';
|
|
4
|
+
export type BlockRenderer = (block: VocabularyBlock, ctx: RenderContext, entries: FetchedEntries, registry: BlockRegistry | undefined, anchors: HeadingAnchors) => HtmlElement | null;
|
|
5
|
+
export declare function renderDocPage(page: PageContent, ctx: RenderContext, sidebarBlock: CollectionListBlock, entries: FetchedEntries, registry: BlockRegistry | undefined, renderOne: BlockRenderer): HtmlElement;
|
|
6
|
+
//# sourceMappingURL=doc-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-page.d.ts","sourceRoot":"","sources":["../../../src/render/doc-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC1F,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,WAAW,EAEhB,KAAK,WAAW,EAEhB,KAAK,aAAa,EAEnB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAsB,KAAK,cAAc,EAAkB,MAAM,gBAAgB,CAAA;AA6NxF,MAAM,MAAM,aAAa,GAAG,CAC1B,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,aAAa,GAAG,SAAS,EACnC,OAAO,EAAE,cAAc,KACpB,WAAW,GAAG,IAAI,CAAA;AAEvB,wBAAgB,aAAa,CAC3B,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,aAAa,EAClB,YAAY,EAAE,mBAAmB,EACjC,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,aAAa,GAAG,SAAS,EACnC,SAAS,EAAE,aAAa,GACvB,WAAW,CAmDb"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { entryHref, entryTitle, h, pageHasOwnHeading, withBlockKey, } from '@cogenta/theme-kit';
|
|
2
|
+
import { groupDocPages, readingOrder } from './doc-index.js';
|
|
3
|
+
import { longDate } from './layout.js';
|
|
4
|
+
import { headingAnchors } from './rich-text.js';
|
|
5
|
+
import { word } from './strings.js';
|
|
6
|
+
/**
|
|
7
|
+
* A documentation page: navigation, the reading column, the table of
|
|
8
|
+
* contents.
|
|
9
|
+
*
|
|
10
|
+
* The navigation comes from the page's own first block, a `collectionList` on
|
|
11
|
+
* `doc_page` that the documentation blueprint seeds on every page for this
|
|
12
|
+
* purpose (contract B has no "this block is chrome" flag, and inventing one
|
|
13
|
+
* would be a contract change for one theme's layout). It is rendered as the
|
|
14
|
+
* sidebar and dropped from the stream of content blocks.
|
|
15
|
+
*
|
|
16
|
+
* Three columns on a wide screen: the sidebar held in view as the page
|
|
17
|
+
* scrolls, the article on its measure, and "On this page" built from the
|
|
18
|
+
* article's own `h2`/`h3`. The table of contents has no scroll spy (that
|
|
19
|
+
* would need a script); it is a plain list of links that stays in view. Two
|
|
20
|
+
* columns on a laptop (the table of contents goes), one on a phone, where the
|
|
21
|
+
* navigation folds into a `<details>` disclosure at the top of the article.
|
|
22
|
+
*
|
|
23
|
+
* The sidebar is in two copies: a plain `<nav>` for wide screens, and the
|
|
24
|
+
* same links inside the disclosure for narrow ones. A closed `<details>`
|
|
25
|
+
* hides its content through the browser's own `::details-content` box, which
|
|
26
|
+
* a stylesheet cannot reliably reopen on a wide screen (verified in Chrome in
|
|
27
|
+
* L25), so the desktop column is never a disclosure. Exactly one copy is
|
|
28
|
+
* displayed at any width, so a screen reader is never offered two.
|
|
29
|
+
*
|
|
30
|
+
* Under the article: the date the page last changed, and links to the
|
|
31
|
+
* previous and next pages in the documentation's reading order. No comment
|
|
32
|
+
* form and no "was this helpful" widget: neither could be answered honestly
|
|
33
|
+
* by a static page.
|
|
34
|
+
*/
|
|
35
|
+
function sidebarLinks(groups, ctx, current) {
|
|
36
|
+
return groups.map((group) => h('div', { class: 'cd-sidenav__group' }, h('p', { class: 'cd-sidenav__heading' }, group.section), h('ul', { class: 'cd-sidenav__links' }, group.entries.map((entry) => {
|
|
37
|
+
const target = entryHref(entry, ctx);
|
|
38
|
+
return h('li', { class: 'cd-sidenav__item' }, h('a', {
|
|
39
|
+
class: 'cd-sidenav__link',
|
|
40
|
+
href: target,
|
|
41
|
+
'aria-current': target === current ? 'page' : undefined,
|
|
42
|
+
}, entryTitle(entry, ctx)));
|
|
43
|
+
}))));
|
|
44
|
+
}
|
|
45
|
+
function renderSidebar(groups, ctx, current, currentEntry, title) {
|
|
46
|
+
const label = word(ctx.locale, 'documentation');
|
|
47
|
+
const section = typeof currentEntry?.section === 'string' ? currentEntry.section : undefined;
|
|
48
|
+
return [
|
|
49
|
+
h('nav', { class: 'cd-sidenav cd-sidenav--wide', 'aria-label': label }, sidebarLinks(groups, ctx, current)),
|
|
50
|
+
h('details', { class: 'cd-sidenav-disclosure' }, h('summary', { class: 'cd-sidenav-disclosure__summary' }, h('span', { class: 'cd-sidenav-disclosure__label' }, word(ctx.locale, 'menu')), h('span', { class: 'cd-sidenav-disclosure__where' }, section === undefined ? title : `${section} / ${title}`)), h('nav', { class: 'cd-sidenav cd-sidenav--narrow', 'aria-label': label }, sidebarLinks(groups, ctx, current))),
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
function renderBreadcrumb(ctx, section, title) {
|
|
54
|
+
return h('nav', { class: 'cd-breadcrumb', 'aria-label': word(ctx.locale, 'breadcrumb') }, h('ol', { class: 'cd-breadcrumb__items' }, h('li', {}, h('a', { href: ctx.link('/') }, word(ctx.locale, 'docsHome'))), section === undefined ? null : h('li', {}, section), h('li', { 'aria-current': 'page' }, title)));
|
|
55
|
+
}
|
|
56
|
+
function renderToc(ctx, anchors) {
|
|
57
|
+
const list = [...anchors.values()];
|
|
58
|
+
if (list.length < 2)
|
|
59
|
+
return null;
|
|
60
|
+
const items = [];
|
|
61
|
+
let children = [];
|
|
62
|
+
let parent;
|
|
63
|
+
const close = () => {
|
|
64
|
+
if (parent === undefined) {
|
|
65
|
+
for (const orphan of children)
|
|
66
|
+
items.push(tocItem(orphan, []));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
items.push(tocItem(parent, children));
|
|
70
|
+
}
|
|
71
|
+
children = [];
|
|
72
|
+
parent = undefined;
|
|
73
|
+
};
|
|
74
|
+
for (const anchor of list) {
|
|
75
|
+
if (anchor.level === 2) {
|
|
76
|
+
close();
|
|
77
|
+
parent = anchor;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
children.push(anchor);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
close();
|
|
84
|
+
return h('nav', { class: 'cd-toc', 'aria-labelledby': 'cd-toc-label' }, h('p', { class: 'cd-toc__label', id: 'cd-toc-label' }, word(ctx.locale, 'onThisPage')), h('ol', { class: 'cd-toc__items' }, items));
|
|
85
|
+
}
|
|
86
|
+
function tocItem(anchor, children) {
|
|
87
|
+
return h('li', { class: 'cd-toc__item', 'data-level': String(anchor.level) }, h('a', { class: 'cd-toc__link', href: `#${anchor.id}` }, anchor.text), children.length === 0
|
|
88
|
+
? null
|
|
89
|
+
: h('ol', { class: 'cd-toc__items' }, children.map((child) => tocItem(child, []))));
|
|
90
|
+
}
|
|
91
|
+
function pagerLink(ctx, entry, direction) {
|
|
92
|
+
if (entry === undefined)
|
|
93
|
+
return null;
|
|
94
|
+
return h('a', {
|
|
95
|
+
class: 'cd-pager__link',
|
|
96
|
+
'data-direction': direction,
|
|
97
|
+
href: entryHref(entry, ctx),
|
|
98
|
+
rel: direction === 'previous' ? 'prev' : 'next',
|
|
99
|
+
}, h('span', { class: 'cd-pager__label' }, word(ctx.locale, direction)), h('span', { class: 'cd-pager__title' }, entryTitle(entry, ctx)));
|
|
100
|
+
}
|
|
101
|
+
function renderFoot(page, ctx, order, currentIndex) {
|
|
102
|
+
const updated = page.entry?.updatedAt;
|
|
103
|
+
const previous = currentIndex > 0 ? order[currentIndex - 1] : undefined;
|
|
104
|
+
const next = currentIndex >= 0 ? order[currentIndex + 1] : undefined;
|
|
105
|
+
const pager = previous === undefined && next === undefined
|
|
106
|
+
? null
|
|
107
|
+
: h('nav', { class: 'cd-pager', 'aria-label': word(ctx.locale, 'pager') }, pagerLink(ctx, previous, 'previous'), pagerLink(ctx, next, 'next'));
|
|
108
|
+
return h('footer', { class: 'cd-doc__foot' }, updated === undefined
|
|
109
|
+
? null
|
|
110
|
+
: h('p', { class: 'cd-doc__updated' }, `${word(ctx.locale, 'lastUpdated')} `, h('time', { datetime: updated }, longDate(updated, ctx.locale))), pager);
|
|
111
|
+
}
|
|
112
|
+
export function renderDocPage(page, ctx, sidebarBlock, entries, registry, renderOne) {
|
|
113
|
+
const groups = groupDocPages(entries[sidebarBlock._key] ?? [], ctx);
|
|
114
|
+
const order = readingOrder(groups);
|
|
115
|
+
const current = ctx.url.pathname;
|
|
116
|
+
const currentIndex = order.findIndex((entry) => entryHref(entry, ctx) === current);
|
|
117
|
+
const currentEntry = currentIndex >= 0 ? order[currentIndex] : undefined;
|
|
118
|
+
const section = typeof currentEntry?.section === 'string' ? currentEntry.section : undefined;
|
|
119
|
+
const content = page.blocks.slice(1);
|
|
120
|
+
const anchors = headingAnchors(content);
|
|
121
|
+
const ownHeading = pageHasOwnHeading(content);
|
|
122
|
+
const toc = renderToc(ctx, anchors);
|
|
123
|
+
return h('main', { class: 'cg-main cd-doc', id: 'cg-main', 'data-toc': toc === null ? 'false' : 'true' }, h('div', { class: 'cd-doc__layout' }, withBlockKey(h('div', { class: 'cd-doc__sidebar' }, renderSidebar(groups, ctx, current, currentEntry, page.title)), sidebarBlock._key), h('article', { class: 'cd-doc__article' }, h('header', { class: 'cd-doc__head' }, renderBreadcrumb(ctx, section, page.title), ownHeading ? null : h('h1', { class: 'cd-doc__title' }, page.title), page.entry?.excerpt === undefined
|
|
124
|
+
? null
|
|
125
|
+
: h('p', { class: 'cd-doc__lede' }, page.entry.excerpt)), h('div', { class: 'cd-doc__body' }, content.map((block) => withBlockKey(renderOne(block, ctx, entries, registry, anchors), block._key))), renderFoot(page, ctx, order, currentIndex)), toc === null ? null : h('div', { class: 'cd-doc__toc' }, toc)));
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=doc-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-page.js","sourceRoot":"","sources":["../../../src/render/doc-page.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,SAAS,EACT,UAAU,EAGV,CAAC,EAED,iBAAiB,EAEjB,YAAY,GACb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAiB,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAA2C,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACxF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,SAAS,YAAY,CACnB,MAA2B,EAC3B,GAAkB,EAClB,OAAe;IAEf,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1B,CAAC,CACC,KAAK,EACL,EAAE,KAAK,EAAE,mBAAmB,EAAE,EAC9B,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EACvD,CAAC,CACC,IAAI,EACJ,EAAE,KAAK,EAAE,mBAAmB,EAAE,EAC9B,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QACpC,OAAO,CAAC,CACN,IAAI,EACJ,EAAE,KAAK,EAAE,kBAAkB,EAAE,EAC7B,CAAC,CACC,GAAG,EACH;YACE,KAAK,EAAE,kBAAkB;YACzB,IAAI,EAAE,MAAM;YACZ,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,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EAAE,KAAK,EAAE,cAAc,EAAE,EACzB,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACpB,YAAY,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAC5E,CACF,EACD,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,CAAC,CAC3C,EACD,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,GAAG,CAAC,CAC9D,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Attributes, type Child, type HtmlElement } from '@cogenta/theme-kit';
|
|
2
|
+
/**
|
|
3
|
+
* The frame every block of this theme renders into.
|
|
4
|
+
*
|
|
5
|
+
* The outer element carries the one section rhythm (`--cd-section`, the same
|
|
6
|
+
* for every block) and paints edge to edge when a variant asks for a band.
|
|
7
|
+
* The inner element is the twelve-column container, so a section title, a
|
|
8
|
+
* link, a figure and a caption all start on the same left edge. Inside a
|
|
9
|
+
* documentation page the same markup is laid out in the reading column
|
|
10
|
+
* instead (`docs.css`), so a block placed in an article needs nothing extra.
|
|
11
|
+
*
|
|
12
|
+
* `inner` is `figure` for a block whose semantics are a figure (a quotation
|
|
13
|
+
* and its attribution, an image and its caption): `<figcaption>` must be a
|
|
14
|
+
* direct child of its `<figure>`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function section(outer: 'section' | 'div', block: string, className: string, attrs: Attributes, inner: 'div' | 'figure', ...children: readonly Child[]): HtmlElement;
|
|
17
|
+
/** A titled block's heading, from the first column, left-aligned with the content under it. */
|
|
18
|
+
export declare function sectionHead(blockName: string, title: string | undefined): HtmlElement | null;
|
|
19
|
+
/** A paragraph that renders only when the text is there: no empty `<p>` on the page. */
|
|
20
|
+
export declare function optionalText(tag: string, className: string, value: string | undefined, attrs?: Attributes): HtmlElement | null;
|
|
21
|
+
/** `Intl.DateTimeFormat`'s long date in the page's locale: "September 14, 2026". */
|
|
22
|
+
export declare function longDate(iso: string, locale: string): string;
|
|
23
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/render/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,KAAK,EACV,KAAK,WAAW,EAGjB,MAAM,oBAAoB,CAAA;AAE3B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,SAAS,GAAG,KAAK,EACxB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,KAAK,GAAG,QAAQ,EACvB,GAAG,QAAQ,EAAE,SAAS,KAAK,EAAE,GAC5B,WAAW,CAMb;AAED,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,IAAI,CAW5F;AAED,wFAAwF;AACxF,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,GAAE,UAAe,GACrB,WAAW,GAAG,IAAI,CAGpB;AAED,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQ5D"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { blockHeadingTag, h, heading, } from '@cogenta/theme-kit';
|
|
2
|
+
/**
|
|
3
|
+
* The frame every block of this theme renders into.
|
|
4
|
+
*
|
|
5
|
+
* The outer element carries the one section rhythm (`--cd-section`, the same
|
|
6
|
+
* for every block) and paints edge to edge when a variant asks for a band.
|
|
7
|
+
* The inner element is the twelve-column container, so a section title, a
|
|
8
|
+
* link, a figure and a caption all start on the same left edge. Inside a
|
|
9
|
+
* documentation page the same markup is laid out in the reading column
|
|
10
|
+
* instead (`docs.css`), so a block placed in an article needs nothing extra.
|
|
11
|
+
*
|
|
12
|
+
* `inner` is `figure` for a block whose semantics are a figure (a quotation
|
|
13
|
+
* and its attribution, an image and its caption): `<figcaption>` must be a
|
|
14
|
+
* direct child of its `<figure>`.
|
|
15
|
+
*/
|
|
16
|
+
export function section(outer, block, className, attrs, inner, ...children) {
|
|
17
|
+
return h(outer, { class: `cd-section ${className}`, 'data-block': block, ...attrs }, h(inner, { class: `cd-container ${className}__inner` }, ...children));
|
|
18
|
+
}
|
|
19
|
+
/** A titled block's heading, from the first column, left-aligned with the content under it. */
|
|
20
|
+
export function sectionHead(blockName, title) {
|
|
21
|
+
if (title === undefined || title.trim() === '')
|
|
22
|
+
return null;
|
|
23
|
+
return h('div', { class: 'cd-head' }, heading(blockHeadingTag(blockName) ?? 'h2', { class: 'cd-head__title', 'data-field': 'title' }, title));
|
|
24
|
+
}
|
|
25
|
+
/** A paragraph that renders only when the text is there: no empty `<p>` on the page. */
|
|
26
|
+
export function optionalText(tag, className, value, attrs = {}) {
|
|
27
|
+
if (value === undefined || value.trim() === '')
|
|
28
|
+
return null;
|
|
29
|
+
return h(tag, { class: className, ...attrs }, value);
|
|
30
|
+
}
|
|
31
|
+
/** `Intl.DateTimeFormat`'s long date in the page's locale: "September 14, 2026". */
|
|
32
|
+
export function longDate(iso, locale) {
|
|
33
|
+
try {
|
|
34
|
+
return new Intl.DateTimeFormat(locale, { dateStyle: 'long', timeZone: 'UTC' }).format(new Date(iso));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return iso.slice(0, 10);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +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AED,oFAAoF;AACpF,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,MAAc;IAClD,IAAI,CAAC;QACH,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CACnF,IAAI,IAAI,CAAC,GAAG,CAAC,CACd,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -3,13 +3,16 @@ import { type FetchedEntries, type HtmlElement, type PageContent, type RenderCon
|
|
|
3
3
|
export type { FetchedEntries, PageContent };
|
|
4
4
|
export declare function renderBlock(block: VocabularyBlock, ctx: RenderContext, entries?: FetchedEntries, registry?: BlockRegistry): HtmlElement | null;
|
|
5
5
|
/**
|
|
6
|
-
* `<main id="cg-main">` is mandatory: it is the skip
|
|
7
|
-
*
|
|
6
|
+
* `<main id="cg-main">` is mandatory: it is the skip link's target, written
|
|
7
|
+
* by the host outside any theme's control.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* A page whose first block is the documentation's own index on `doc_page` is
|
|
10
|
+
* a documentation page (`doc-page.ts`); every other page is laid out on the
|
|
11
|
+
* twelve-column grid. Exactly one `h1` on every page: a hero carries it when
|
|
12
|
+
* there is one, the page head otherwise.
|
|
13
|
+
*
|
|
14
|
+
* `withBlockKey` stamps every rendered block with its contract-B `_key`, so
|
|
15
|
+
* the visual page builder (L16) can map a clicked element back to its block.
|
|
13
16
|
*/
|
|
14
17
|
export declare function renderPage(page: PageContent, ctx: RenderContext, entries?: FetchedEntries, registry?: BlockRegistry): HtmlElement;
|
|
15
18
|
//# sourceMappingURL=render-block.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-block.d.ts","sourceRoot":"","sources":["../../../src/render/render-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAoB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC5F,OAAO,
|
|
1
|
+
{"version":3,"file":"render-block.d.ts","sourceRoot":"","sources":["../../../src/render/render-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAoB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC5F,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAEhB,KAAK,WAAW,EAGhB,KAAK,aAAa,EAInB,MAAM,oBAAoB,CAAA;AAuB3B,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,CAAA;AAoB3C,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,aAAa,EAClB,OAAO,GAAE,cAAmB,EAC5B,QAAQ,CAAC,EAAE,aAAa,GACvB,WAAW,GAAG,IAAI,CAOpB;AAiFD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,aAAa,EAClB,OAAO,GAAE,cAAmB,EAC5B,QAAQ,CAAC,EAAE,aAAa,GACvB,WAAW,CAeb"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VOCABULARY_NAMES } from '@cogenta/blocks';
|
|
2
|
-
import {
|
|
2
|
+
import { h, pageHasOwnHeading, providedBlockNode, resolveBlockForRender, withBlockKey, withBlockVariant, } from '@cogenta/theme-kit';
|
|
3
3
|
import { renderAccordion } from './blocks/accordion.js';
|
|
4
4
|
import { renderCollectionList } from './blocks/collection-list.js';
|
|
5
5
|
import { renderCta } from './blocks/cta.js';
|
|
@@ -17,19 +17,37 @@ import { renderQuote } from './blocks/quote.js';
|
|
|
17
17
|
import { renderStatCounter } from './blocks/stat-counter.js';
|
|
18
18
|
import { renderStats } from './blocks/stats.js';
|
|
19
19
|
import { renderTestimonial } from './blocks/testimonial.js';
|
|
20
|
-
|
|
20
|
+
import { isDocIndexBlock } from './doc-index.js';
|
|
21
|
+
import { renderDocPage } from './doc-page.js';
|
|
22
|
+
import { longDate } from './layout.js';
|
|
23
|
+
import { headingAnchors } from './rich-text.js';
|
|
24
|
+
function renderResolved(block, ctx, entries, registry, anchors) {
|
|
25
|
+
// A stored block is not always literally one of the shared vocabulary:
|
|
26
|
+
// resolving here turns an unimplemented theme-private block into its
|
|
27
|
+
// declared fallback instead of a silently blank slot.
|
|
21
28
|
const resolved = resolveBlockForRender(block, VOCABULARY_NAMES, registry);
|
|
22
29
|
if (resolved === null)
|
|
23
30
|
return null;
|
|
24
31
|
const known = resolved;
|
|
25
|
-
|
|
32
|
+
// `variant` is envelope data every block carries identically, applied once
|
|
33
|
+
// here rather than by each of the seventeen renderers.
|
|
34
|
+
return withBlockVariant(renderKnownBlock(known, ctx, entries, anchors), known.variant);
|
|
35
|
+
}
|
|
36
|
+
export function renderBlock(block, ctx, entries = {}, registry) {
|
|
37
|
+
// A block a plugin provides arrives already rendered by the host, in a
|
|
38
|
+
// process of its own (contract D theme@1.7). Nothing else in this theme
|
|
39
|
+
// needs to know such blocks exist.
|
|
40
|
+
const provided = providedBlockNode(block, ctx);
|
|
41
|
+
if (provided !== null)
|
|
42
|
+
return withBlockVariant(provided, block.variant);
|
|
43
|
+
return renderResolved(block, ctx, entries, registry, headingAnchors([block]));
|
|
26
44
|
}
|
|
27
|
-
function renderKnownBlock(known, ctx, entries) {
|
|
45
|
+
function renderKnownBlock(known, ctx, entries, anchors) {
|
|
28
46
|
switch (known._type) {
|
|
29
47
|
case 'hero':
|
|
30
48
|
return renderHero(known, ctx);
|
|
31
49
|
case 'prose':
|
|
32
|
-
return renderProse(known, ctx);
|
|
50
|
+
return renderProse(known, ctx, anchors);
|
|
33
51
|
case 'mediaFigure':
|
|
34
52
|
return renderMediaFigure(known, ctx);
|
|
35
53
|
case 'featureGrid':
|
|
@@ -61,6 +79,9 @@ function renderKnownBlock(known, ctx, entries) {
|
|
|
61
79
|
case 'logoStrip':
|
|
62
80
|
return renderLogoStrip(known, ctx);
|
|
63
81
|
default: {
|
|
82
|
+
// Exhaustive over contract B: `known` is `never` here, so a block this
|
|
83
|
+
// package does not implement stops it compiling until it is. `null`
|
|
84
|
+
// rather than a throw: choosing a fallback is the render layer's job.
|
|
64
85
|
const unreachable = known;
|
|
65
86
|
void unreachable;
|
|
66
87
|
return null;
|
|
@@ -68,109 +89,35 @@ function renderKnownBlock(known, ctx, entries) {
|
|
|
68
89
|
}
|
|
69
90
|
}
|
|
70
91
|
/**
|
|
71
|
-
* The
|
|
72
|
-
*
|
|
73
|
-
* by any flag on the block, because contract B carries no "this is chrome,
|
|
74
|
-
* not content" bit and inventing one would be a contract change for a
|
|
75
|
-
* single theme's layout choice.
|
|
76
|
-
*/
|
|
77
|
-
const DOC_PAGE_COLLECTION = 'doc_page';
|
|
78
|
-
function isDocSidebarBlock(block) {
|
|
79
|
-
return block._type === 'collectionList' && block.collection === DOC_PAGE_COLLECTION;
|
|
80
|
-
}
|
|
81
|
-
/** The sidebar entry whose own link resolves to the page being rendered — the "current page" the brief asks the sidebar to highlight and the breadcrumb to name. */
|
|
82
|
-
function findCurrentEntry(entries, ctx) {
|
|
83
|
-
return entries.find((entry) => entryHref(entry, ctx) === ctx.url.pathname);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* The doc-page sidebar — grouped by each entry's own `section` field, in the
|
|
87
|
-
* order the entries were fetched (the blueprint seeds them in `order`
|
|
88
|
-
* within a section already; `collectionList.sort` cannot name `section`/
|
|
89
|
-
* `order`, so an editor who reorders sections relies on the fetch order,
|
|
90
|
-
* exactly like the "All guides" index on the home page does).
|
|
92
|
+
* The opening of a page outside the documentation that has no hero: its
|
|
93
|
+
* title, its summary, and the date it was published when it has one.
|
|
91
94
|
*/
|
|
92
|
-
function
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
list.push(entry);
|
|
100
|
-
groups.set(section, list);
|
|
101
|
-
}
|
|
102
|
-
return h('nav', { class: 'cg-docs__nav-panel', 'aria-label': 'Documentation' }, [...groups.entries()].map(([section, sectionEntries]) => h('div', { class: 'cg-docs__nav-group' }, h('p', { class: 'cg-docs__nav-heading' }, section), h('ul', { class: 'cg-docs__nav-items' }, sectionEntries.map((entry) => {
|
|
103
|
-
const href = entryHref(entry, ctx);
|
|
104
|
-
const isCurrent = href === currentHref;
|
|
105
|
-
return h('li', {}, h('a', {
|
|
106
|
-
class: 'cg-docs__nav-link',
|
|
107
|
-
href,
|
|
108
|
-
'aria-current': isCurrent ? 'page' : undefined,
|
|
109
|
-
}, entryTitle(entry, ctx)));
|
|
110
|
-
})))));
|
|
95
|
+
function renderPageHead(page, ctx) {
|
|
96
|
+
const published = page.entry?.publishedAt;
|
|
97
|
+
return h('header', { class: 'cd-page-head' }, h('div', { class: 'cd-container cd-page-head__inner' }, h('h1', { class: 'cd-page-head__title' }, page.title), page.entry?.excerpt === undefined
|
|
98
|
+
? null
|
|
99
|
+
: h('p', { class: 'cd-page-head__lead' }, page.entry.excerpt), published === undefined
|
|
100
|
+
? null
|
|
101
|
+
: h('p', { class: 'cd-page-head__meta' }, h('time', { datetime: published }, longDate(published, ctx.locale)))));
|
|
111
102
|
}
|
|
112
103
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* every other engine implementing the current HTML rendering rules) hides a
|
|
116
|
-
* closed `<details>`'s non-summary content through its own internal
|
|
117
|
-
* `::details-content` box, not through the plain CSS `display: none` the spec
|
|
118
|
-
* text describes — so a stylesheet rule that sets `display: block` on that
|
|
119
|
-
* content, however specific, does not reliably bring it back while the
|
|
120
|
-
* element itself stays closed. Verified live: a build with a single
|
|
121
|
-
* `<details>` forced open only above the two-column breakpoint rendered an
|
|
122
|
-
* empty sidebar column at 1280px in a real Chrome tab, despite every
|
|
123
|
-
* computed style reporting `display: block`.
|
|
104
|
+
* `<main id="cg-main">` is mandatory: it is the skip link's target, written
|
|
105
|
+
* by the host outside any theme's control.
|
|
124
106
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* two is ever `display: block` at a given viewport width (`base.css`), so a
|
|
130
|
-
* screen reader is never offered two "Documentation" navigations at once,
|
|
131
|
-
* matching the header's own accessibility guarantee.
|
|
132
|
-
*/
|
|
133
|
-
function renderSidebar(entries, ctx, currentHref) {
|
|
134
|
-
return h('div', { class: 'cg-docs__nav-desktop' }, renderSidebarPanel(entries, ctx, currentHref));
|
|
135
|
-
}
|
|
136
|
-
function renderSidebarMobile(entries, ctx, currentHref) {
|
|
137
|
-
return h('details', { class: 'cg-docs__nav-mobile' }, h('summary', { class: 'cg-docs__nav-toggle' }, 'On this site'), renderSidebarPanel(entries, ctx, currentHref));
|
|
138
|
-
}
|
|
139
|
-
function renderBreadcrumb(section, title) {
|
|
140
|
-
return h('nav', { class: 'cg-docs__breadcrumb', 'aria-label': 'Breadcrumb' }, h('ol', {}, section === undefined ? null : h('li', {}, section), h('li', { 'aria-current': 'page' }, title)));
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* A doc page: two columns, CSS-only. The sidebar comes from the page's own
|
|
144
|
-
* *first* block — a `collectionList` on `doc_page` the blueprint seeds on
|
|
145
|
-
* every doc page for exactly this purpose — rendered as navigation rather
|
|
146
|
-
* than as a card list, and dropped from the ordinary block stream so it
|
|
147
|
-
* never also appears as content. The remaining blocks render in the content
|
|
148
|
-
* column, unchanged.
|
|
149
|
-
*/
|
|
150
|
-
function renderDocPage(page, ctx, sidebarBlock, entries, registry) {
|
|
151
|
-
const sidebarEntries = entries[sidebarBlock._key] ?? [];
|
|
152
|
-
const currentHref = ctx.url.pathname;
|
|
153
|
-
const current = findCurrentEntry(sidebarEntries, ctx);
|
|
154
|
-
const section = typeof current?.section === 'string' ? current.section : undefined;
|
|
155
|
-
const contentBlocks = page.blocks.slice(1);
|
|
156
|
-
const hasOwnHeading = pageHasOwnHeading(contentBlocks);
|
|
157
|
-
const entryHeader = renderEntryHeader(page, ctx);
|
|
158
|
-
return h('main', { class: 'cg-main cg-docs', id: 'cg-main' }, withBlockKey(h('div', { class: 'cg-docs__nav' }, renderSidebar(sidebarEntries, ctx, currentHref), renderSidebarMobile(sidebarEntries, ctx, currentHref)), sidebarBlock._key), h('div', { class: 'cg-docs__content' }, renderBreadcrumb(section, page.title), entryHeader ?? (hasOwnHeading ? null : h('h1', { class: 'cg-docs__title' }, page.title)), contentBlocks.map((block) => withBlockKey(renderBlock(block, ctx, entries, registry), block._key))));
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* `<main id="cg-main">` is mandatory: it is the skip-link's target, written
|
|
162
|
-
* once by `@cogenta/cli`'s own render path.
|
|
107
|
+
* A page whose first block is the documentation's own index on `doc_page` is
|
|
108
|
+
* a documentation page (`doc-page.ts`); every other page is laid out on the
|
|
109
|
+
* twelve-column grid. Exactly one `h1` on every page: a hero carries it when
|
|
110
|
+
* there is one, the page head otherwise.
|
|
163
111
|
*
|
|
164
|
-
* `withBlockKey` stamps every rendered block with its contract-B `_key`,
|
|
165
|
-
*
|
|
166
|
-
* builder maps a clicked element back to the block that produced it, for
|
|
167
|
-
* this theme exactly as for every other one.
|
|
112
|
+
* `withBlockKey` stamps every rendered block with its contract-B `_key`, so
|
|
113
|
+
* the visual page builder (L16) can map a clicked element back to its block.
|
|
168
114
|
*/
|
|
169
115
|
export function renderPage(page, ctx, entries = {}, registry) {
|
|
170
116
|
const first = page.blocks[0];
|
|
171
|
-
if (first !== undefined &&
|
|
172
|
-
return renderDocPage(page, ctx, first, entries, registry);
|
|
117
|
+
if (first !== undefined && isDocIndexBlock(first)) {
|
|
118
|
+
return renderDocPage(page, ctx, first, entries, registry, renderResolved);
|
|
173
119
|
}
|
|
174
|
-
|
|
120
|
+
const anchors = headingAnchors(page.blocks);
|
|
121
|
+
return h('main', { class: 'cg-main cd-main', id: 'cg-main' }, pageHasOwnHeading(page.blocks) ? null : renderPageHead(page, ctx), page.blocks.map((block) => withBlockKey(renderResolved(block, ctx, entries, registry, anchors), block._key)));
|
|
175
122
|
}
|
|
176
123
|
//# sourceMappingURL=render-block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-block.js","sourceRoot":"","sources":["../../../src/render/render-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAwB,MAAM,iBAAiB,CAAA;AAC5F,OAAO,
|
|
1
|
+
{"version":3,"file":"render-block.js","sourceRoot":"","sources":["../../../src/render/render-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAwB,MAAM,iBAAiB,CAAA;AAC5F,OAAO,EAGL,CAAC,EAED,iBAAiB,EACjB,iBAAiB,EAEjB,qBAAqB,EACrB,YAAY,EACZ,gBAAgB,GACjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AA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AAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CACpE,CACN,CACF,CAAA;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CACxB,IAAiB,EACjB,GAAkB,EAClB,OAAO,GAAmB,EAAE,EAC5B,QAAwB;IAExB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAC5B,IAAI,KAAK,KAAK,SAAS,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAA;IAC3E,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3C,OAAO,CAAC,CACN,MAAM,EACN,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,EAAE,SAAS,EAAE,EAC3C,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,EACjE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACxB,YAAY,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CACjF,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RichTextDocument, VocabularyBlock } from '@cogenta/blocks';
|
|
2
|
+
import { type HtmlNode, type RenderContext } from '@cogenta/theme-kit';
|
|
3
|
+
export interface HeadingAnchor {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly text: string;
|
|
6
|
+
readonly level: 2 | 3;
|
|
7
|
+
}
|
|
8
|
+
/** Anchors by `${blockKey}:${nodeKey}`, in reading order. */
|
|
9
|
+
export type HeadingAnchors = ReadonlyMap<string, HeadingAnchor>;
|
|
10
|
+
export declare function slugify(value: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* One id per `h2`/`h3` of every `prose` block on a page, unique across the
|
|
13
|
+
* page: a second "Examples" becomes `examples-2`. Computed once for the whole
|
|
14
|
+
* page, so the table of contents and the headings always agree.
|
|
15
|
+
*/
|
|
16
|
+
export declare function headingAnchors(blocks: readonly VocabularyBlock[]): HeadingAnchors;
|
|
17
|
+
export declare function keyChord(value: string): readonly string[] | null;
|
|
18
|
+
export interface DocsRichTextOptions {
|
|
19
|
+
/** The block the document belongs to, and the page's anchors. Absent: headings get no id (a FAQ answer, say). */
|
|
20
|
+
readonly anchors?: {
|
|
21
|
+
readonly blockKey: string;
|
|
22
|
+
readonly map: HeadingAnchors;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare function renderDocsRichText(ctx: RenderContext, document: RichTextDocument, options?: DocsRichTextOptions): readonly HtmlNode[];
|
|
26
|
+
//# sourceMappingURL=rich-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text.d.ts","sourceRoot":"","sources":["../../../src/render/rich-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAsB,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC5F,OAAO,EAEL,KAAK,QAAQ,EAEb,KAAK,aAAa,EAGnB,MAAM,oBAAoB,CAAA;AA6C3B,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;CACtB;AAED,6DAA6D;AAC7D,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;AAW/D,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ7C;AAUD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,GAAG,cAAc,CAsBjF;AAyND,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAYhE;AAyBD,MAAM,WAAW,mBAAmB;IAClC,iHAAiH;IACjH,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAA;KAAE,CAAA;CAC/E;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,GAAE,mBAAwB,GAChC,SAAS,QAAQ,EAAE,CAkErB"}
|