@cogenta/theme-canonical 0.1.0

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.
Files changed (126) hide show
  1. package/dist/src/index.d.ts +21 -0
  2. package/dist/src/index.d.ts.map +1 -0
  3. package/dist/src/index.js +21 -0
  4. package/dist/src/index.js.map +1 -0
  5. package/dist/src/render/actions.d.ts +17 -0
  6. package/dist/src/render/actions.d.ts.map +1 -0
  7. package/dist/src/render/actions.js +43 -0
  8. package/dist/src/render/actions.js.map +1 -0
  9. package/dist/src/render/blocks/collection-list.d.ts +16 -0
  10. package/dist/src/render/blocks/collection-list.d.ts.map +1 -0
  11. package/dist/src/render/blocks/collection-list.js +54 -0
  12. package/dist/src/render/blocks/collection-list.js.map +1 -0
  13. package/dist/src/render/blocks/cta.d.ts +5 -0
  14. package/dist/src/render/blocks/cta.d.ts.map +1 -0
  15. package/dist/src/render/blocks/cta.js +10 -0
  16. package/dist/src/render/blocks/cta.js.map +1 -0
  17. package/dist/src/render/blocks/embed.d.ts +5 -0
  18. package/dist/src/render/blocks/embed.d.ts.map +1 -0
  19. package/dist/src/render/blocks/embed.js +88 -0
  20. package/dist/src/render/blocks/embed.js.map +1 -0
  21. package/dist/src/render/blocks/faq.d.ts +5 -0
  22. package/dist/src/render/blocks/faq.d.ts.map +1 -0
  23. package/dist/src/render/blocks/faq.js +21 -0
  24. package/dist/src/render/blocks/faq.js.map +1 -0
  25. package/dist/src/render/blocks/feature-grid.d.ts +5 -0
  26. package/dist/src/render/blocks/feature-grid.d.ts.map +1 -0
  27. package/dist/src/render/blocks/feature-grid.js +27 -0
  28. package/dist/src/render/blocks/feature-grid.js.map +1 -0
  29. package/dist/src/render/blocks/gallery.d.ts +15 -0
  30. package/dist/src/render/blocks/gallery.d.ts.map +1 -0
  31. package/dist/src/render/blocks/gallery.js +28 -0
  32. package/dist/src/render/blocks/gallery.js.map +1 -0
  33. package/dist/src/render/blocks/hero.d.ts +12 -0
  34. package/dist/src/render/blocks/hero.d.ts.map +1 -0
  35. package/dist/src/render/blocks/hero.js +25 -0
  36. package/dist/src/render/blocks/hero.js.map +1 -0
  37. package/dist/src/render/blocks/logos.d.ts +5 -0
  38. package/dist/src/render/blocks/logos.d.ts.map +1 -0
  39. package/dist/src/render/blocks/logos.js +25 -0
  40. package/dist/src/render/blocks/logos.js.map +1 -0
  41. package/dist/src/render/blocks/media-figure.d.ts +15 -0
  42. package/dist/src/render/blocks/media-figure.d.ts.map +1 -0
  43. package/dist/src/render/blocks/media-figure.js +30 -0
  44. package/dist/src/render/blocks/media-figure.js.map +1 -0
  45. package/dist/src/render/blocks/prose.d.ts +10 -0
  46. package/dist/src/render/blocks/prose.d.ts.map +1 -0
  47. package/dist/src/render/blocks/prose.js +11 -0
  48. package/dist/src/render/blocks/prose.js.map +1 -0
  49. package/dist/src/render/blocks/quote.d.ts +14 -0
  50. package/dist/src/render/blocks/quote.d.ts.map +1 -0
  51. package/dist/src/render/blocks/quote.js +25 -0
  52. package/dist/src/render/blocks/quote.js.map +1 -0
  53. package/dist/src/render/blocks/stats.d.ts +5 -0
  54. package/dist/src/render/blocks/stats.d.ts.map +1 -0
  55. package/dist/src/render/blocks/stats.js +23 -0
  56. package/dist/src/render/blocks/stats.js.map +1 -0
  57. package/dist/src/render/entry.d.ts +7 -0
  58. package/dist/src/render/entry.d.ts.map +1 -0
  59. package/dist/src/render/entry.js +35 -0
  60. package/dist/src/render/entry.js.map +1 -0
  61. package/dist/src/render/heading.d.ts +14 -0
  62. package/dist/src/render/heading.d.ts.map +1 -0
  63. package/dist/src/render/heading.js +34 -0
  64. package/dist/src/render/heading.js.map +1 -0
  65. package/dist/src/render/html.d.ts +44 -0
  66. package/dist/src/render/html.d.ts.map +1 -0
  67. package/dist/src/render/html.js +96 -0
  68. package/dist/src/render/html.js.map +1 -0
  69. package/dist/src/render/media.d.ts +32 -0
  70. package/dist/src/render/media.d.ts.map +1 -0
  71. package/dist/src/render/media.js +42 -0
  72. package/dist/src/render/media.js.map +1 -0
  73. package/dist/src/render/render-block.d.ts +26 -0
  74. package/dist/src/render/render-block.d.ts.map +1 -0
  75. package/dist/src/render/render-block.js +66 -0
  76. package/dist/src/render/render-block.js.map +1 -0
  77. package/dist/src/render/rich-text.d.ts +5 -0
  78. package/dist/src/render/rich-text.d.ts.map +1 -0
  79. package/dist/src/render/rich-text.js +105 -0
  80. package/dist/src/render/rich-text.js.map +1 -0
  81. package/dist/src/theme-contract.d.ts +165 -0
  82. package/dist/src/theme-contract.d.ts.map +1 -0
  83. package/dist/src/theme-contract.js +21 -0
  84. package/dist/src/theme-contract.js.map +1 -0
  85. package/dist/theme.config.d.ts +31 -0
  86. package/dist/theme.config.d.ts.map +1 -0
  87. package/dist/theme.config.js +42 -0
  88. package/dist/theme.config.js.map +1 -0
  89. package/package.json +57 -0
  90. package/src/blocks/CollectionList.astro +20 -0
  91. package/src/blocks/Cta.astro +11 -0
  92. package/src/blocks/Embed.astro +18 -0
  93. package/src/blocks/Faq.astro +16 -0
  94. package/src/blocks/FeatureGrid.astro +11 -0
  95. package/src/blocks/Gallery.astro +17 -0
  96. package/src/blocks/Hero.astro +25 -0
  97. package/src/blocks/Logos.astro +11 -0
  98. package/src/blocks/MediaFigure.astro +11 -0
  99. package/src/blocks/Prose.astro +11 -0
  100. package/src/blocks/Quote.astro +11 -0
  101. package/src/blocks/Stats.astro +11 -0
  102. package/src/components/BlockZone.astro +62 -0
  103. package/src/index.ts +20 -0
  104. package/src/layouts/Base.astro +63 -0
  105. package/src/render/actions.ts +57 -0
  106. package/src/render/blocks/collection-list.ts +98 -0
  107. package/src/render/blocks/cta.ts +17 -0
  108. package/src/render/blocks/embed.ts +111 -0
  109. package/src/render/blocks/faq.ts +42 -0
  110. package/src/render/blocks/feature-grid.ts +54 -0
  111. package/src/render/blocks/gallery.ts +49 -0
  112. package/src/render/blocks/hero.ts +42 -0
  113. package/src/render/blocks/logos.ts +45 -0
  114. package/src/render/blocks/media-figure.ts +42 -0
  115. package/src/render/blocks/prose.ts +17 -0
  116. package/src/render/blocks/quote.ts +39 -0
  117. package/src/render/blocks/stats.ts +41 -0
  118. package/src/render/entry.ts +40 -0
  119. package/src/render/heading.ts +44 -0
  120. package/src/render/html.ts +122 -0
  121. package/src/render/media.ts +62 -0
  122. package/src/render/render-block.ts +97 -0
  123. package/src/render/rich-text.ts +150 -0
  124. package/src/styles/theme.css +606 -0
  125. package/src/theme-contract.ts +159 -0
  126. package/tokens.json +36 -0
@@ -0,0 +1,30 @@
1
+ import { h } from '../html.js';
2
+ import { aspectRatio, image } from '../media.js';
3
+ /**
4
+ * `<figure>`/`<figcaption>` rather than a div and a paragraph: the association
5
+ * between the picture and its caption is then in the markup, and a screen
6
+ * reader announces the caption as belonging to the image instead of as loose
7
+ * text after it.
8
+ *
9
+ * `align` is written as a data attribute, never as a class: contract B's values
10
+ * are `start`/`end`, an intent that mirrors in right-to-left locales, and the
11
+ * skin decides what it means.
12
+ */
13
+ export function renderMediaFigure(block, ctx) {
14
+ const ratio = aspectRatio(block.ratio);
15
+ const hasCaption = block.caption !== undefined || block.credit !== undefined;
16
+ return h('figure', {
17
+ class: 'cg-block cg-figure',
18
+ 'data-block': 'mediaFigure',
19
+ 'data-align': block.align ?? 'center',
20
+ style: ratio === undefined ? undefined : `--cg-ratio:${ratio}`,
21
+ }, image(ctx, block.media, {
22
+ className: 'cg-figure__media',
23
+ sizes: '(min-width: 45rem) 40rem, 100vw',
24
+ }), hasCaption
25
+ ? h('figcaption', { class: 'cg-figure__caption' }, block.caption, block.credit === undefined
26
+ ? null
27
+ : h('span', { class: 'cg-figure__credit' }, block.credit))
28
+ : null);
29
+ }
30
+ //# sourceMappingURL=media-figure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-figure.js","sourceRoot":"","sources":["../../../../src/render/blocks/media-figure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,CAAC,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEhD;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAuB,EAAE,GAAkB;IAC3E,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACtC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,CAAA;IAC5E,OAAO,CAAC,CACN,QAAQ,EACR;QACE,KAAK,EAAE,oBAAoB;QAC3B,YAAY,EAAE,aAAa;QAC3B,YAAY,EAAE,KAAK,CAAC,KAAK,IAAI,QAAQ;QACrC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,EAAE;KAC/D,EACD,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE;QACtB,SAAS,EAAE,kBAAkB;QAC7B,KAAK,EAAE,iCAAiC;KACzC,CAAC,EACF,UAAU;QACR,CAAC,CAAC,CAAC,CACC,YAAY,EACZ,EAAE,KAAK,EAAE,oBAAoB,EAAE,EAC/B,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,MAAM,KAAK,SAAS;YACxB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,CAC5D;QACH,CAAC,CAAC,IAAI,CACT,CAAA;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ProseBlock } from '@cogenta/blocks';
2
+ import type { RenderContext } from '../../theme-contract.js';
3
+ import { type HtmlElement } from '../html.js';
4
+ /**
5
+ * `prose` declares `headingLevel: 'none'`: it contributes no heading of its
6
+ * own. Whatever headings appear come from the rich text document, whose
7
+ * vocabulary starts at `h2`.
8
+ */
9
+ export declare function renderProse(block: ProseBlock, ctx: RenderContext): HtmlElement;
10
+ //# sourceMappingURL=prose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prose.d.ts","sourceRoot":"","sources":["../../../../src/render/blocks/prose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAK,MAAM,YAAY,CAAA;AAGhD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,GAAG,WAAW,CAM9E"}
@@ -0,0 +1,11 @@
1
+ import { h } from '../html.js';
2
+ import { renderRichText } from '../rich-text.js';
3
+ /**
4
+ * `prose` declares `headingLevel: 'none'`: it contributes no heading of its
5
+ * own. Whatever headings appear come from the rich text document, whose
6
+ * vocabulary starts at `h2`.
7
+ */
8
+ export function renderProse(block, ctx) {
9
+ return h('div', { class: 'cg-block cg-prose', 'data-block': 'prose' }, renderRichText(ctx, block.body));
10
+ }
11
+ //# sourceMappingURL=prose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prose.js","sourceRoot":"","sources":["../../../../src/render/blocks/prose.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,CAAC,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAiB,EAAE,GAAkB;IAC/D,OAAO,CAAC,CACN,KAAK,EACL,EAAE,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,OAAO,EAAE,EACrD,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAChC,CAAA;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { QuoteBlock } from '@cogenta/blocks';
2
+ import type { RenderContext } from '../../theme-contract.js';
3
+ import { type HtmlElement } from '../html.js';
4
+ /**
5
+ * `<figure><blockquote>…</blockquote><figcaption>` is the attribution pattern
6
+ * the HTML spec prescribes: putting the author inside the `<blockquote>` would
7
+ * claim the author's name is part of what was said.
8
+ *
9
+ * The avatar is decorative here — the name is right beside it in text — so its
10
+ * media entity's alt text is expected to be empty. `image` still writes the
11
+ * attribute either way.
12
+ */
13
+ export declare function renderQuote(block: QuoteBlock, ctx: RenderContext): HtmlElement;
14
+ //# sourceMappingURL=quote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../../../src/render/blocks/quote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAK,MAAM,YAAY,CAAA;AAGhD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,GAAG,WAAW,CAwB9E"}
@@ -0,0 +1,25 @@
1
+ import { h } from '../html.js';
2
+ import { image } from '../media.js';
3
+ /**
4
+ * `<figure><blockquote>…</blockquote><figcaption>` is the attribution pattern
5
+ * the HTML spec prescribes: putting the author inside the `<blockquote>` would
6
+ * claim the author's name is part of what was said.
7
+ *
8
+ * The avatar is decorative here — the name is right beside it in text — so its
9
+ * media entity's alt text is expected to be empty. `image` still writes the
10
+ * attribute either way.
11
+ */
12
+ export function renderQuote(block, ctx) {
13
+ const hasAttribution = block.author !== undefined || block.role !== undefined || block.avatar !== undefined;
14
+ return h('figure', { class: 'cg-block cg-quote', 'data-block': 'quote' }, h('blockquote', { class: 'cg-quote__text' }, h('p', {}, block.text)), hasAttribution
15
+ ? h('figcaption', { class: 'cg-quote__attribution' }, block.avatar === undefined
16
+ ? null
17
+ : image(ctx, block.avatar, {
18
+ className: 'cg-quote__avatar',
19
+ variant: { width: 96, height: 96, fit: 'cover' },
20
+ }), block.author === undefined
21
+ ? null
22
+ : h('span', { class: 'cg-quote__author' }, block.author), block.role === undefined ? null : h('span', { class: 'cg-quote__role' }, block.role))
23
+ : null);
24
+ }
25
+ //# sourceMappingURL=quote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quote.js","sourceRoot":"","sources":["../../../../src/render/blocks/quote.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,CAAC,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,KAAiB,EAAE,GAAkB;IAC/D,MAAM,cAAc,GAClB,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,CAAA;IACtF,OAAO,CAAC,CACN,QAAQ,EACR,EAAE,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,OAAO,EAAE,EACrD,CAAC,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,EACpE,cAAc;QACZ,CAAC,CAAC,CAAC,CACC,YAAY,EACZ,EAAE,KAAK,EAAE,uBAAuB,EAAE,EAClC,KAAK,CAAC,MAAM,KAAK,SAAS;YACxB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,EAAE;gBACvB,SAAS,EAAE,kBAAkB;gBAC7B,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;aACjD,CAAC,EACN,KAAK,CAAC,MAAM,KAAK,SAAS;YACxB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,EAC1D,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CACrF;QACH,CAAC,CAAC,IAAI,CACT,CAAA;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { StatsBlock } from '@cogenta/blocks';
2
+ import type { RenderContext } from '../../theme-contract.js';
3
+ import { type HtmlElement } from '../html.js';
4
+ export declare function renderStats(block: StatsBlock, _ctx: RenderContext): HtmlElement;
5
+ //# sourceMappingURL=stats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../../src/render/blocks/stats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAE5D,OAAO,EAAE,KAAK,WAAW,EAAK,MAAM,YAAY,CAAA;AA4BhD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,GAAG,WAAW,CAS/E"}
@@ -0,0 +1,23 @@
1
+ import { blockHeadingTag, heading } from '../heading.js';
2
+ import { h } from '../html.js';
3
+ /**
4
+ * A description list: each figure is the description of its label, which is
5
+ * exactly what `<dt>`/`<dd>` mean, and it survives being read linearly.
6
+ *
7
+ * The label comes first in the markup and the skin puts the figure above it —
8
+ * reading order and visual order stay independent, which is what WCAG 1.3.2
9
+ * asks for. A `<div>` wrapper around each pair is valid inside `<dl>` and is
10
+ * what makes that reordering possible without breaking the association.
11
+ *
12
+ * The unit is a separate span so the skin can size it apart, and the pair is
13
+ * announced as one string either way.
14
+ */
15
+ function renderItem(item) {
16
+ return h('div', { class: 'cg-stat' }, h('dt', { class: 'cg-stat__label' }, item.label), h('dd', { class: 'cg-stat__value' }, item.value, item.unit === undefined ? null : h('span', { class: 'cg-stat__unit' }, item.unit)));
17
+ }
18
+ export function renderStats(block, _ctx) {
19
+ return h('section', { class: 'cg-block cg-stats', 'data-block': 'stats' }, block.title === undefined
20
+ ? null
21
+ : heading(blockHeadingTag('stats') ?? 'h2', { class: 'cg-stats__title' }, block.title), h('dl', { class: 'cg-stats__items' }, block.items.map(renderItem)));
22
+ }
23
+ //# sourceMappingURL=stats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../../../src/render/blocks/stats.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAoB,CAAC,EAAE,MAAM,YAAY,CAAA;AAEhD;;;;;;;;;;;GAWG;AACH,SAAS,UAAU,CAAC,IAAc;IAChC,OAAO,CAAC,CACN,KAAK,EACL,EAAE,KAAK,EAAE,SAAS,EAAE,EACpB,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,EAChD,CAAC,CACC,IAAI,EACJ,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAC3B,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAClF,CACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAiB,EAAE,IAAmB;IAChE,OAAO,CAAC,CACN,SAAS,EACT,EAAE,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,OAAO,EAAE,EACrD,KAAK,CAAC,KAAK,KAAK,SAAS;QACvB,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,EACxF,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CACnE,CAAA;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ContentEntry, RenderContext } from '../theme-contract.js';
2
+ export declare function entryTitle(entry: ContentEntry, ctx: RenderContext): string;
3
+ export declare function entryExcerpt(entry: ContentEntry): string | undefined;
4
+ /** ISO 8601, for `<time datetime>`. Anything else is not a date this can use. */
5
+ export declare function entryDate(entry: ContentEntry): string | undefined;
6
+ export declare function entryHref(entry: ContentEntry, ctx: RenderContext): string;
7
+ //# sourceMappingURL=entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../../src/render/entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAavE,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,aAAa,GAAG,MAAM,CAM1E;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAMpE;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAGjE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,aAAa,GAAG,MAAM,CAEzE"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Contract A fixes the system fields but not the schema-defined ones: which
3
+ * fields an entry has depends on its collection, and a theme that assumes
4
+ * `title` exists breaks on the first collection that calls it `name`.
5
+ *
6
+ * So every read of an unknown field goes through here, returns a fallback the
7
+ * visitor can live with, and never renders `undefined`.
8
+ */
9
+ const TITLE_FIELDS = ['title', 'name', 'label'];
10
+ export function entryTitle(entry, ctx) {
11
+ for (const field of TITLE_FIELDS) {
12
+ const value = entry[field];
13
+ if (typeof value === 'string' && value.trim() !== '')
14
+ return value;
15
+ }
16
+ return ctx.t('entry.untitled');
17
+ }
18
+ const EXCERPT_FIELDS = ['excerpt', 'summary', 'description'];
19
+ export function entryExcerpt(entry) {
20
+ for (const field of EXCERPT_FIELDS) {
21
+ const value = entry[field];
22
+ if (typeof value === 'string' && value.trim() !== '')
23
+ return value;
24
+ }
25
+ return undefined;
26
+ }
27
+ /** ISO 8601, for `<time datetime>`. Anything else is not a date this can use. */
28
+ export function entryDate(entry) {
29
+ const value = entry.publishedAt ?? entry.createdAt;
30
+ return typeof value === 'string' && !Number.isNaN(Date.parse(value)) ? value : undefined;
31
+ }
32
+ export function entryHref(entry, ctx) {
33
+ return ctx.link({ collection: entry.collection, id: entry.id });
34
+ }
35
+ //# sourceMappingURL=entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../src/render/entry.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAU,CAAA;AAExD,MAAM,UAAU,UAAU,CAAC,KAAmB,EAAE,GAAkB;IAChE,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,KAAK,CAAA;IACpE,CAAC;IACD,OAAO,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAA;AAChC,CAAC;AAED,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,aAAa,CAAU,CAAA;AAErE,MAAM,UAAU,YAAY,CAAC,KAAmB;IAC9C,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,KAAK,CAAA;IACpE,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,SAAS,CAAC,KAAmB;IAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,SAAS,CAAA;IAClD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1F,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAmB,EAAE,GAAkB;IAC/D,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;AACjE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type Child, type HtmlElement } from './html.js';
2
+ export type HeadingTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
3
+ /** The level a block's own title is rendered at, or `null` if it carries none. */
4
+ export declare function blockHeadingTag(blockName: string): HeadingTag | null;
5
+ /**
6
+ * The level for a title *inside* a block — a feature's name, a listed entry.
7
+ *
8
+ * One below the block's own heading when the block renders one, and at the
9
+ * block's declared level when it does not: a `featureGrid` without a title must
10
+ * not start its items at `h3`, which would skip a level.
11
+ */
12
+ export declare function nestedHeadingTag(blockName: string, blockRendersHeading: boolean): HeadingTag;
13
+ export declare function heading(tag: HeadingTag, attrs: Readonly<Record<string, string | number | boolean | undefined>>, ...children: readonly Child[]): HtmlElement;
14
+ //# sourceMappingURL=heading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../../src/render/heading.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,WAAW,EAAK,MAAM,WAAW,CAAA;AAY3D,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAEhE,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAIpE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO,GAAG,UAAU,CAK5F;AAED,wBAAgB,OAAO,CACrB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC,EACtE,GAAG,QAAQ,EAAE,SAAS,KAAK,EAAE,GAC5B,WAAW,CAEb"}
@@ -0,0 +1,34 @@
1
+ import { VOCABULARY } from '@cogenta/blocks';
2
+ import { h } from './html.js';
3
+ /**
4
+ * The heading level of a block is **not** a theme decision: contract B fixes it
5
+ * in each block's `a11y.headingLevel`, and the theme reads it from there rather
6
+ * than restating it. Restating it is how an outline drifts — one block gets
7
+ * promoted in the theme, the page grows a second `h1`, and nothing fails.
8
+ */
9
+ const DECLARED_LEVELS = new Map(VOCABULARY.map((block) => [block.name, block.a11y.headingLevel]));
10
+ /** The level a block's own title is rendered at, or `null` if it carries none. */
11
+ export function blockHeadingTag(blockName) {
12
+ const level = DECLARED_LEVELS.get(blockName);
13
+ if (level === undefined || level === 'none')
14
+ return null;
15
+ return level;
16
+ }
17
+ /**
18
+ * The level for a title *inside* a block — a feature's name, a listed entry.
19
+ *
20
+ * One below the block's own heading when the block renders one, and at the
21
+ * block's declared level when it does not: a `featureGrid` without a title must
22
+ * not start its items at `h3`, which would skip a level.
23
+ */
24
+ export function nestedHeadingTag(blockName, blockRendersHeading) {
25
+ const own = blockHeadingTag(blockName) ?? 'h2';
26
+ if (!blockRendersHeading)
27
+ return own;
28
+ const next = Number(own.slice(1)) + 1;
29
+ return `h${Math.min(next, 6)}`;
30
+ }
31
+ export function heading(tag, attrs, ...children) {
32
+ return h(tag, attrs, ...children);
33
+ }
34
+ //# sourceMappingURL=heading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading.js","sourceRoot":"","sources":["../../../src/render/heading.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAgC,CAAC,EAAE,MAAM,WAAW,CAAA;AAE3D;;;;;GAKG;AACH,MAAM,eAAe,GAAsC,IAAI,GAAG,CAChE,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CACjE,CAAA;AAID,kFAAkF;AAClF,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,MAAM,KAAK,GAAG,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IAC5C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,IAAI,CAAA;IACxD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB,EAAE,mBAA4B;IAC9E,MAAM,GAAG,GAAG,eAAe,CAAC,SAAS,CAAC,IAAI,IAAI,CAAA;IAC9C,IAAI,CAAC,mBAAmB;QAAE,OAAO,GAAG,CAAA;IACpC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IACrC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAgB,CAAA;AAC9C,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,GAAe,EACf,KAAsE,EACtE,GAAG,QAA0B;IAE7B,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAA;AACnC,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * A minimal, dependency-free HTML tree and serialiser.
3
+ *
4
+ * Why the theme's markup is built here rather than written inline in the
5
+ * `.astro` files:
6
+ *
7
+ * 1. It is testable without an Astro toolchain — the twelve blocks get real
8
+ * snapshot tests, and the heading outline and the `alt` rule get asserted on
9
+ * the actual output rather than on a reading of the source.
10
+ * 2. There is **no way to emit raw HTML**. A block stores semantic data only
11
+ * (rule R3); with no `raw()` escape hatch, a string that arrives in a block
12
+ * field cannot become markup, whatever it contains.
13
+ *
14
+ * The `.astro` components in `src/blocks/` are the contract-D entry points and
15
+ * stay thin on purpose: one call each, so the two never drift.
16
+ */
17
+ export type AttributeValue = string | number | boolean | undefined;
18
+ export type Attributes = Readonly<Record<string, AttributeValue>>;
19
+ export interface HtmlElement {
20
+ readonly kind: 'element';
21
+ readonly tag: string;
22
+ readonly attrs: Attributes;
23
+ readonly children: readonly HtmlNode[];
24
+ }
25
+ export interface HtmlText {
26
+ readonly kind: 'text';
27
+ readonly value: string;
28
+ }
29
+ export type HtmlNode = HtmlElement | HtmlText;
30
+ /** Anything a caller may pass as a child. `null`/`false` drop out, so a
31
+ * conditional child reads as `condition && node` without a wrapper. */
32
+ export type Child = HtmlNode | string | null | false | undefined | readonly Child[];
33
+ export declare function text(value: string): HtmlText;
34
+ export declare function h(tag: string, attrs?: Attributes, ...children: readonly Child[]): HtmlElement;
35
+ /**
36
+ * `&` first, or every following replacement would be escaped twice.
37
+ * `<` and `>` cover text; the quotes are escaped in attributes only, where they
38
+ * are the ones that can break out.
39
+ */
40
+ export declare function escapeText(value: string): string;
41
+ export declare function escapeAttribute(value: string): string;
42
+ export declare function serialize(node: HtmlNode): string;
43
+ export declare function serializeAll(nodes: readonly HtmlNode[]): string;
44
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/render/html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;AAElE,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;AAEjE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,SAAS,QAAQ,EAAE,CAAA;CACvC;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAA;AAE7C;uEACuE;AACvE,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,KAAK,EAAE,CAAA;AAsBnF,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAE5C;AAiBD,wBAAgB,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,UAAe,EAAE,GAAG,QAAQ,EAAE,SAAS,KAAK,EAAE,GAAG,WAAW,CAIjG;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAiBD,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAKhD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CAE/D"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * A minimal, dependency-free HTML tree and serialiser.
3
+ *
4
+ * Why the theme's markup is built here rather than written inline in the
5
+ * `.astro` files:
6
+ *
7
+ * 1. It is testable without an Astro toolchain — the twelve blocks get real
8
+ * snapshot tests, and the heading outline and the `alt` rule get asserted on
9
+ * the actual output rather than on a reading of the source.
10
+ * 2. There is **no way to emit raw HTML**. A block stores semantic data only
11
+ * (rule R3); with no `raw()` escape hatch, a string that arrives in a block
12
+ * field cannot become markup, whatever it contains.
13
+ *
14
+ * The `.astro` components in `src/blocks/` are the contract-D entry points and
15
+ * stay thin on purpose: one call each, so the two never drift.
16
+ */
17
+ /**
18
+ * Elements that carry no children and no closing tag. Serialising `<img>` with
19
+ * one would produce markup no parser agrees on.
20
+ */
21
+ const VOID_ELEMENTS = new Set([
22
+ 'area',
23
+ 'base',
24
+ 'br',
25
+ 'col',
26
+ 'embed',
27
+ 'hr',
28
+ 'img',
29
+ 'input',
30
+ 'link',
31
+ 'meta',
32
+ 'source',
33
+ 'track',
34
+ 'wbr',
35
+ ]);
36
+ export function text(value) {
37
+ return { kind: 'text', value };
38
+ }
39
+ function flatten(children, into) {
40
+ for (const child of children) {
41
+ if (child === null || child === false || child === undefined)
42
+ continue;
43
+ if (typeof child === 'string') {
44
+ into.push(text(child));
45
+ continue;
46
+ }
47
+ if (Array.isArray(child)) {
48
+ flatten(child, into);
49
+ continue;
50
+ }
51
+ into.push(child);
52
+ }
53
+ }
54
+ export function h(tag, attrs = {}, ...children) {
55
+ const collected = [];
56
+ flatten(children, collected);
57
+ return { kind: 'element', tag, attrs, children: collected };
58
+ }
59
+ /**
60
+ * `&` first, or every following replacement would be escaped twice.
61
+ * `<` and `>` cover text; the quotes are escaped in attributes only, where they
62
+ * are the ones that can break out.
63
+ */
64
+ export function escapeText(value) {
65
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
66
+ }
67
+ export function escapeAttribute(value) {
68
+ return escapeText(value).replace(/"/g, '&quot;').replace(/'/g, '&#39;');
69
+ }
70
+ function serializeAttributes(attrs) {
71
+ let out = '';
72
+ // Insertion order, not sorted: it is deterministic already, and an author
73
+ // reading a snapshot expects the order they wrote.
74
+ for (const [name, value] of Object.entries(attrs)) {
75
+ if (value === undefined || value === false)
76
+ continue;
77
+ if (value === true) {
78
+ out += ` ${name}`;
79
+ continue;
80
+ }
81
+ out += ` ${name}="${escapeAttribute(String(value))}"`;
82
+ }
83
+ return out;
84
+ }
85
+ export function serialize(node) {
86
+ if (node.kind === 'text')
87
+ return escapeText(node.value);
88
+ const open = `<${node.tag}${serializeAttributes(node.attrs)}>`;
89
+ if (VOID_ELEMENTS.has(node.tag))
90
+ return open;
91
+ return `${open}${node.children.map(serialize).join('')}</${node.tag}>`;
92
+ }
93
+ export function serializeAll(nodes) {
94
+ return nodes.map(serialize).join('');
95
+ }
96
+ //# sourceMappingURL=html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.js","sourceRoot":"","sources":["../../../src/render/html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAwBH;;;GAGG;AACH,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC;IACjD,MAAM;IACN,MAAM;IACN,IAAI;IACJ,KAAK;IACL,OAAO;IACP,IAAI;IACJ,KAAK;IACL,OAAO;IACP,MAAM;IACN,MAAM;IACN,QAAQ;IACR,OAAO;IACP,KAAK;CACN,CAAC,CAAA;AAEF,MAAM,UAAU,IAAI,CAAC,KAAa;IAChC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AAChC,CAAC;AAED,SAAS,OAAO,CAAC,QA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,CAAA;IACZ,0EAA0E;IAC1E,mDAAmD;IACnD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK;YAAE,SAAQ;QACpD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,GAAG,IAAI,IAAI,IAAI,EAAE,CAAA;YACjB,SAAQ;QACV,CAAC;QACD,GAAG,IAAI,IAAI,IAAI,KAAK,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAA;IACvD,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAA;IAC9D,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAA;IAC5C,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,GAAG,CAAA;AACxE,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAA0B;IACrD,OAAO,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACtC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { ImageOptions, MediaReference, RenderContext } from '../theme-contract.js';
2
+ import { type HtmlElement } from './html.js';
3
+ export interface ImageRenderOptions {
4
+ /** The `sizes` hint. Layout knowledge, so it belongs to the theme, not the block. */
5
+ readonly sizes?: string;
6
+ /** `eager` only for what is above the fold — the hero, and nothing else. */
7
+ readonly loading?: 'lazy' | 'eager';
8
+ readonly className?: string;
9
+ /**
10
+ * An accessible name the *block* provides — a logo's organisation name, for
11
+ * instance. It never invents alt text: it is used only where contract B says
12
+ * the block already carries the name.
13
+ */
14
+ readonly altFrom?: string;
15
+ readonly variant?: ImageOptions;
16
+ }
17
+ /**
18
+ * The only place the theme emits an `<img>`.
19
+ *
20
+ * `alt` is always written, never omitted: an image with no `alt` attribute is
21
+ * announced by its file name, while `alt=""` is announced as decorative. The
22
+ * difference is the whole of WCAG 1.1.1 here, and it cannot be left to whether
23
+ * a caller remembered.
24
+ *
25
+ * The alt text itself comes from the media entity through `ctx.image` — the
26
+ * theme has no business inventing one, and correcting it in the media library
27
+ * must fix every page at once.
28
+ */
29
+ export declare function image(ctx: RenderContext, media: MediaReference, options?: ImageRenderOptions): HtmlElement;
30
+ /** Contract B's framing values, as a CSS `aspect-ratio`. `original` means none. */
31
+ export declare function aspectRatio(ratio: string | undefined): string | undefined;
32
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/render/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACvF,OAAO,EAAE,KAAK,WAAW,EAAK,MAAM,WAAW,CAAA;AAE/C,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAA;CAChC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CACnB,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,cAAc,EACrB,OAAO,GAAE,kBAAuB,GAC/B,WAAW,CAmBb;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKzE"}
@@ -0,0 +1,42 @@
1
+ import { h } from './html.js';
2
+ /**
3
+ * The only place the theme emits an `<img>`.
4
+ *
5
+ * `alt` is always written, never omitted: an image with no `alt` attribute is
6
+ * announced by its file name, while `alt=""` is announced as decorative. The
7
+ * difference is the whole of WCAG 1.1.1 here, and it cannot be left to whether
8
+ * a caller remembered.
9
+ *
10
+ * The alt text itself comes from the media entity through `ctx.image` — the
11
+ * theme has no business inventing one, and correcting it in the media library
12
+ * must fix every page at once.
13
+ */
14
+ export function image(ctx, media, options = {}) {
15
+ const source = ctx.image(media, options.variant);
16
+ return h('img', {
17
+ class: options.className,
18
+ src: source.src,
19
+ srcset: source.srcset === '' ? undefined : source.srcset,
20
+ sizes: options.sizes,
21
+ width: source.width,
22
+ height: source.height,
23
+ alt: source.alt !== '' ? source.alt : (options.altFrom ?? ''),
24
+ loading: options.loading ?? 'lazy',
25
+ decoding: 'async',
26
+ // The focal point is content data, not a style value: it says which part of
27
+ // the picture must survive a crop. Nothing else can carry it per-image.
28
+ style: source.focal === null
29
+ ? undefined
30
+ : `object-position:${source.focal.x * 100}% ${source.focal.y * 100}%`,
31
+ });
32
+ }
33
+ /** Contract B's framing values, as a CSS `aspect-ratio`. `original` means none. */
34
+ export function aspectRatio(ratio) {
35
+ if (ratio === undefined || ratio === 'original')
36
+ return undefined;
37
+ const [width, height] = ratio.split(':');
38
+ if (width === undefined || height === undefined)
39
+ return undefined;
40
+ return `${width} / ${height}`;
41
+ }
42
+ //# sourceMappingURL=media.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.js","sourceRoot":"","sources":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AAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACxC,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACjE,OAAO,GAAG,KAAK,MAAM,MAAM,EAAE,CAAA;AAC/B,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { VocabularyBlock } from '@cogenta/blocks';
2
+ import type { ContentEntry, RenderContext } from '../theme-contract.js';
3
+ import { type HtmlElement } from './html.js';
4
+ /**
5
+ * Entries already fetched for the `collectionList` blocks on the page, by the
6
+ * block's `_key`. Fetching happens in the Astro frontmatter, once per block,
7
+ * before any markup is built — a renderer that could await would make the
8
+ * number of round trips depend on the markup.
9
+ */
10
+ export type FetchedEntries = Readonly<Record<string, readonly ContentEntry[]>>;
11
+ export declare function renderBlock(block: VocabularyBlock, ctx: RenderContext, entries?: FetchedEntries): HtmlElement | null;
12
+ export interface PageContent {
13
+ /** The entry's title. Rendered as the `h1` unless a hero already carries one. */
14
+ readonly title: string;
15
+ readonly blocks: readonly VocabularyBlock[];
16
+ }
17
+ /**
18
+ * A page has exactly one `h1`.
19
+ *
20
+ * A `hero` declares `headingLevel: 'h1'` and renders the title itself, so the
21
+ * layout must not render a second one; without a hero, nothing else on the page
22
+ * would — `prose` starts at `h2` — and the page would have no `h1` at all.
23
+ */
24
+ export declare function pageHasOwnHeading(blocks: readonly VocabularyBlock[]): boolean;
25
+ export declare function renderPage(page: PageContent, ctx: RenderContext, entries?: FetchedEntries): HtmlElement;
26
+ //# sourceMappingURL=render-block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-block.d.ts","sourceRoot":"","sources":["../../../src/render/render-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAavE,OAAO,EAAE,KAAK,WAAW,EAAK,MAAM,WAAW,CAAA;AAE/C;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC,CAAC,CAAA;AAE9E,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,aAAa,EAClB,OAAO,GAAE,cAAmB,GAC3B,WAAW,GAAG,IAAI,CAsCpB;AAED,MAAM,WAAW,WAAW;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAA;CAC5C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,GAAG,OAAO,CAE7E;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,aAAa,EAClB,OAAO,GAAE,cAAmB,GAC3B,WAAW,CAOb"}
@@ -0,0 +1,66 @@
1
+ import { renderCollectionList } from './blocks/collection-list.js';
2
+ import { renderCta } from './blocks/cta.js';
3
+ import { renderEmbed } from './blocks/embed.js';
4
+ import { renderFaq } from './blocks/faq.js';
5
+ import { renderFeatureGrid } from './blocks/feature-grid.js';
6
+ import { renderGallery } from './blocks/gallery.js';
7
+ import { renderHero } from './blocks/hero.js';
8
+ import { renderLogos } from './blocks/logos.js';
9
+ import { renderMediaFigure } from './blocks/media-figure.js';
10
+ import { renderProse } from './blocks/prose.js';
11
+ import { renderQuote } from './blocks/quote.js';
12
+ import { renderStats } from './blocks/stats.js';
13
+ import { h } from './html.js';
14
+ export function renderBlock(block, ctx, entries = {}) {
15
+ switch (block._type) {
16
+ case 'hero':
17
+ return renderHero(block, ctx);
18
+ case 'prose':
19
+ return renderProse(block, ctx);
20
+ case 'mediaFigure':
21
+ return renderMediaFigure(block, ctx);
22
+ case 'featureGrid':
23
+ return renderFeatureGrid(block, ctx);
24
+ case 'cta':
25
+ return renderCta(block, ctx);
26
+ case 'gallery':
27
+ return renderGallery(block, ctx);
28
+ case 'quote':
29
+ return renderQuote(block, ctx);
30
+ case 'faq':
31
+ return renderFaq(block, ctx);
32
+ case 'stats':
33
+ return renderStats(block, ctx);
34
+ case 'logos':
35
+ return renderLogos(block, ctx);
36
+ case 'collectionList':
37
+ return renderCollectionList(block, ctx, entries[block._key] ?? []);
38
+ case 'embed':
39
+ return renderEmbed(block, ctx);
40
+ default: {
41
+ // Exhaustive over contract B's twelve: `block` is `never` here, so a
42
+ // thirteenth block stops this package compiling until it is implemented.
43
+ // Returning null rather than throwing is deliberate — a theme has no
44
+ // access to `@cogenta/core`'s error types (contract D refuses the import),
45
+ // and choosing a fallback block is the render layer's job, not the
46
+ // theme's.
47
+ const unreachable = block;
48
+ void unreachable;
49
+ return null;
50
+ }
51
+ }
52
+ }
53
+ /**
54
+ * A page has exactly one `h1`.
55
+ *
56
+ * A `hero` declares `headingLevel: 'h1'` and renders the title itself, so the
57
+ * layout must not render a second one; without a hero, nothing else on the page
58
+ * would — `prose` starts at `h2` — and the page would have no `h1` at all.
59
+ */
60
+ export function pageHasOwnHeading(blocks) {
61
+ return blocks.some((block) => block._type === 'hero');
62
+ }
63
+ export function renderPage(page, ctx, entries = {}) {
64
+ return h('main', { class: 'cg-main', id: 'cg-main' }, pageHasOwnHeading(page.blocks) ? null : h('h1', { class: 'cg-page__title' }, page.title), page.blocks.map((block) => renderBlock(block, ctx, entries)));
65
+ }
66
+ //# sourceMappingURL=render-block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-block.js","sourceRoot":"","sources":["../../../src/render/render-block.ts"],"names":[],"mappings":"AAEA,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,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
2
+ import type { RenderContext } from '../theme-contract.js';
3
+ import { type HtmlNode } from './html.js';
4
+ export declare function renderRichText(ctx: RenderContext, document: RichTextDocument): readonly HtmlNode[];
5
+ //# sourceMappingURL=rich-text.d.ts.map