@sinnstack/ui 0.2.0 → 0.3.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 (138) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +6 -4
  3. package/docs/blocks.md +373 -364
  4. package/docs/data.md +128 -128
  5. package/docs/finishes.md +165 -0
  6. package/docs/primitives.md +4 -4
  7. package/docs/seo.md +191 -187
  8. package/package.json +15 -24
  9. package/src/blocks/BlockRenderer.astro +13 -7
  10. package/src/blocks/CTABanner.astro +8 -8
  11. package/src/blocks/CTAPair.astro +9 -9
  12. package/src/blocks/CardGrid.astro +7 -7
  13. package/src/blocks/ConsentEmbed.astro +1 -1
  14. package/src/blocks/ConsentManager.astro +1 -1
  15. package/src/blocks/ContactCard.astro +14 -14
  16. package/src/blocks/ContactForm.astro +4 -4
  17. package/src/blocks/ErrorPage.astro +1 -1
  18. package/src/blocks/FAQ.astro +9 -9
  19. package/src/blocks/FeatureGrid.astro +7 -7
  20. package/src/blocks/Hero.astro +11 -11
  21. package/src/blocks/HeroCarousel.astro +11 -11
  22. package/src/blocks/HighlightCards.astro +10 -10
  23. package/src/blocks/LocationHours.astro +14 -14
  24. package/src/blocks/LogoCloud.astro +7 -7
  25. package/src/blocks/MaintenancePage.astro +8 -3
  26. package/src/blocks/MediaText.astro +12 -12
  27. package/src/blocks/PageHeader.astro +9 -9
  28. package/src/blocks/ProseSection.astro +8 -8
  29. package/src/blocks/Reviews.astro +11 -11
  30. package/src/blocks/RichText.astro +58 -57
  31. package/src/blocks/StatsBand.astro +117 -117
  32. package/src/blocks/Steps.astro +9 -9
  33. package/src/blocks/Testimonials.astro +13 -13
  34. package/src/blocks/cms/card-grid.ts +48 -80
  35. package/src/blocks/cms/consent.ts +1 -30
  36. package/src/blocks/cms/contact-card.ts +4 -46
  37. package/src/blocks/cms/contact-form.ts +2 -20
  38. package/src/blocks/cms/cta-banner.ts +2 -23
  39. package/src/blocks/cms/cta-pair.ts +4 -37
  40. package/src/blocks/cms/data-base.ts +2 -4
  41. package/src/blocks/cms/data.ts +19 -19
  42. package/src/blocks/cms/faq.ts +4 -36
  43. package/src/blocks/cms/feature-grid.ts +47 -80
  44. package/src/blocks/cms/fixtures.ts +591 -599
  45. package/src/blocks/cms/hero-carousel.ts +4 -48
  46. package/src/blocks/cms/hero.ts +2 -46
  47. package/src/blocks/cms/highlight-cards.ts +4 -39
  48. package/src/blocks/cms/images.ts +1 -2
  49. package/src/blocks/cms/index.ts +59 -87
  50. package/src/blocks/cms/location-hours.ts +3 -85
  51. package/src/blocks/cms/logo-cloud.ts +36 -62
  52. package/src/blocks/cms/media-text.ts +2 -20
  53. package/src/blocks/cms/page-header.ts +27 -49
  54. package/src/blocks/cms/pages.ts +35 -81
  55. package/src/blocks/cms/prose-section.ts +2 -22
  56. package/src/blocks/cms/reviews.ts +5 -56
  57. package/src/blocks/cms/schema-dsl.ts +134 -0
  58. package/src/blocks/cms/schema.ts +794 -0
  59. package/src/blocks/cms/shared.ts +63 -115
  60. package/src/blocks/cms/stats-band.ts +35 -61
  61. package/src/blocks/cms/steps.ts +4 -31
  62. package/src/blocks/cms/testimonials.ts +4 -38
  63. package/src/blocks/cms/topbar.ts +4 -41
  64. package/src/blocks/cms/types.ts +1 -37
  65. package/src/blocks/consent.ts +2 -2
  66. package/src/blocks/index.ts +2 -2
  67. package/src/blocks/internal/Actions.astro +11 -5
  68. package/src/blocks/internal/BlockHeader.astro +7 -7
  69. package/src/blocks/internal/Placeholder.astro +3 -3
  70. package/src/blocks/internal/fields.ts +18 -0
  71. package/src/blocks/internal/registry-contract.ts +67 -0
  72. package/src/blocks/internal/util.ts +4 -4
  73. package/src/blocks/lib/contact.ts +10 -4
  74. package/src/blocks/lib/faq.ts +1 -1
  75. package/src/blocks/lib/markdown.ts +350 -0
  76. package/src/blocks/lib/rich-text.ts +132 -143
  77. package/src/blocks/scripts/consent-manager.ts +1 -1
  78. package/src/blocks/scripts/consent-store.ts +1 -1
  79. package/src/blocks/scripts/hours.ts +3 -2
  80. package/src/blocks/types.ts +33 -23
  81. package/src/data/ChartContainer.astro +2 -1
  82. package/src/data/cms.ts +130 -190
  83. package/src/data/lib/chart.ts +13 -4
  84. package/src/data/schema.ts +65 -0
  85. package/src/finishes/aurora.css +75 -0
  86. package/src/finishes/autumn.css +87 -0
  87. package/src/finishes/blueprint.css +69 -0
  88. package/src/finishes/brutalist.css +55 -0
  89. package/src/finishes/clay.css +48 -0
  90. package/src/finishes/day-cycle.css +46 -0
  91. package/src/finishes/fog.css +71 -0
  92. package/src/finishes/glass.css +149 -0
  93. package/src/finishes/holographic.css +91 -0
  94. package/src/finishes/night.css +77 -0
  95. package/src/finishes/paper.css +58 -0
  96. package/src/finishes/polished-glass.css +159 -0
  97. package/src/finishes/rain.css +84 -0
  98. package/src/finishes/scripts/day-cycle.ts +30 -0
  99. package/src/finishes/scripts/holographic.ts +37 -0
  100. package/src/finishes/scripts/spotlight.ts +30 -0
  101. package/src/finishes/spotlight.css +41 -0
  102. package/src/finishes/spring.css +80 -0
  103. package/src/finishes/terminal.css +49 -0
  104. package/src/primitives/Divider.astro +1 -1
  105. package/src/primitives/FocusRing.astro +1 -1
  106. package/src/primitives/FormField.astro +2 -2
  107. package/src/primitives/Image.astro +3 -3
  108. package/src/primitives/Input.astro +4 -2
  109. package/src/primitives/MetricCard.astro +3 -1
  110. package/src/primitives/Picture.astro +3 -3
  111. package/src/primitives/Prose.astro +1 -1
  112. package/src/primitives/Select.astro +4 -2
  113. package/src/primitives/Slider.astro +1 -1
  114. package/src/primitives/Table.astro +1 -1
  115. package/src/primitives/Textarea.astro +4 -2
  116. package/src/primitives/Thumbnail.astro +2 -2
  117. package/src/primitives/index.ts +4 -4
  118. package/src/primitives/internal/ChoiceField.astro +4 -2
  119. package/src/primitives/scripts/slider.ts +1 -1
  120. package/src/primitives/scripts/table-sort.ts +2 -2
  121. package/src/seo/cms.ts +59 -80
  122. package/src/seo/index.ts +1 -1
  123. package/src/seo/integration.ts +40 -3
  124. package/src/seo/lib/jsonld.ts +10 -2
  125. package/src/seo/lib/meta.ts +2 -2
  126. package/src/seo/lib/redirects.ts +14 -4
  127. package/src/seo/lib/rss.ts +1 -1
  128. package/src/seo/lib/sitemap.ts +1 -1
  129. package/src/seo/schema.ts +43 -0
  130. package/src/blocks/internal/tina.ts +0 -19
  131. /package/src/blocks/{lib → internal}/consent.ts +0 -0
  132. /package/src/blocks/{lib → internal}/reviews.ts +0 -0
  133. /package/src/blocks/{lib → internal}/slug.ts +0 -0
  134. /package/src/data/{lib → internal}/scale.ts +0 -0
  135. /package/src/primitives/{lib → internal}/image-plan.ts +0 -0
  136. /package/src/primitives/{lib → internal}/image.ts +0 -0
  137. /package/src/primitives/{lib → internal}/slider.ts +0 -0
  138. /package/src/seo/{lib → internal}/url.ts +0 -0
package/docs/seo.md CHANGED
@@ -1,187 +1,191 @@
1
- # @sinnstack/ui/seo
2
-
3
- SEO for Sinnstack sites, all server-rendered and CSP-safe:
4
-
5
- | Piece | What it is | Import |
6
- | --- | --- | --- |
7
- | **SEOHead** | Title, description, canonical, robots, hreflang, Open Graph, Twitter/X, feeds | `@sinnstack/ui/seo` |
8
- | **JSONLD** | Structured data, with typed builders and checks | `@sinnstack/ui/seo` + `@sinnstack/ui/seo/jsonld` |
9
- | **Sitemap / RSS** | Sitemaps built from your pages, RSS feeds and robots.txt | `@sinnstack/ui/seo/integration`, `/rss`, `/sitemap` |
10
- | **RedirectMap** | Redirects from old URLs, checked and exported to Astro or your host | `@sinnstack/ui/seo/redirects` |
11
-
12
- ```js
13
- // astro.config.mjs
14
- import sinnSeo from '@sinnstack/ui/seo/integration';
15
- import { redirects } from './src/data/redirects.mjs';
16
- export default defineConfig({
17
- site: 'https://championhealthcare.com', // required: canonicals, sitemaps and share URLs use it
18
- integrations: [sinnSeo({ redirects, robots: { production: process.env.DEPLOY_ENV === 'production' } })],
19
- });
20
- ```
21
-
22
- ## SEOHead
23
-
24
- Place it in your layout's `<head>`:
25
-
26
- ```astro
27
- <SEOHead title={title} titleTemplate="%s | Champion Healthcare" defaultTitle="Champion Healthcare"
28
- description={description} siteName="Champion Healthcare" locale="en_US"
29
- image={{ src: cover, alt: 'A nurse reviewing a care plan with a patient' }}
30
- noindex={noindex} feeds={[{ title: 'Blog', href: '/blog/rss.xml' }]} />
31
- ```
32
-
33
- **Canonical URL**
34
- - Built from the current URL, but always on your production `site` origin, so preview deploys never claim to be the real page.
35
- - The hash and every query parameter are dropped (UTM tags, for example), except those you list in `keepQuery`, such as `page`.
36
- - `index.html` is removed and your `trailingSlash` setting is applied (the integration passes it in).
37
- - An explicit `canonical` can be relative (resolved on the site) or absolute (for content syndicated from elsewhere).
38
-
39
- **Title:** `titleTemplate` is skipped when the title already contains the site name. `og:title` uses the bare page title.
40
-
41
- **Share image:** an imported image is cropped to a 1200×630 JPEG, the size Facebook, LinkedIn, Slack and X show large. URL strings are used as given. With an image, the Twitter card is `summary_large_image`; without one it's `summary`.
42
-
43
- **Robots:** indexable pages get `max-image-preview:large`, so Google can show big image previews. `noindex` also keeps the page out of the sitemap.
44
-
45
- **Development warnings** (`warn`, on by default in dev):
46
- - a missing title or description, or one that's too long or too short;
47
- - no share image, a share image smaller than 1200×630, or missing image alt text;
48
- - `noindex` while the canonical points elsewhere;
49
- - duplicate hreflang values, or hreflang alternates that don't include the page itself;
50
- - no `site` set.
51
-
52
- **Safety:** every value is escaped (tested with `</title><script>` in a title).
53
-
54
- Without Astro, `buildHead(input)` returns the tags plus warnings, and `renderHead(tags)` returns HTML.
55
-
56
- ## JSONLD
57
-
58
- ```astro
59
- ---
60
- import { breadcrumbList, article } from '@sinnstack/ui/seo/jsonld';
61
- ---
62
- <JSONLD data={[breadcrumbList([{ name: 'Home', url: '/' }, { name: 'Blog', url: '/blog/' }, { name: post.title }], { site: Astro.site }),
63
- article({ type: 'BlogPosting', url, headline: post.title, images: [cover], datePublished: post.date, authors: [{ name: post.author }] })]} />
64
- ```
65
-
66
- **Builders:**
67
-
68
- | Builder | Notes |
69
- | --- | --- |
70
- | `organization` | Any type, e.g. `MedicalOrganization` |
71
- | `localBusiness` | `MedicalClinic`, `Physician`, `Dentist`, `Pharmacy`… Includes opening hours from `{ days: ['Mo','Fr'], opens, closes }`, geo, area served, medical specialty and the parent organization |
72
- | `website` | Includes the site search action |
73
- | `webPage` | |
74
- | `breadcrumbList` | Positions added automatically, URLs made absolute |
75
- | `article` / `BlogPosting` / `NewsArticle` | |
76
- | `faqPage` | Google currently shows FAQ rich results mainly for authoritative health and government sites |
77
- | `event` | In person or online, with offers |
78
- | `person` | |
79
- | `service` | |
80
-
81
- **Linking:** `graph()` combines nodes into one `@graph`, linked by `@id`. For example, a location's `parentOrganization` points to `https://site/#organization`.
82
-
83
- **Development checks:**
84
- - Google's required and recommended properties for each type.
85
- - Dates in ISO 8601, and datetimes that include a time zone.
86
- - Absolute URLs.
87
- - Breadcrumb positions, and only the last breadcrumb may omit its URL.
88
- - FAQ answers that are actually filled in.
89
- - `@id` references that point to nodes not in the graph.
90
-
91
- **Serialization** escapes `<`, `>`, `&` and U+2028/2029, so CMS text containing `</script>` can't break out. A test checks this in Chrome.
92
-
93
- **CSP:** `application/ld+json` is a data block that browsers never execute, so `script-src` doesn't apply. A test checks this under `script-src 'self'` and finds no violations.
94
-
95
- ## Sitemap, RSS and robots.txt
96
-
97
- **Sitemap (integration).** After the build, it reads each page's `<head>` from the HTML Astro actually wrote, so the sitemap agrees with SEOHead.
98
- - **Left out:**
99
- - pages marked `noindex`;
100
- - pages whose canonical points to another URL (print versions, duplicates);
101
- - Astro's redirect stubs;
102
- - `404` and `500` pages;
103
- - anything matching `exclude` or rejected by `filter`.
104
- - **Carried over:** hreflang alternates, and `article:modified_time` as `lastmod`. `og:image` too, if you turn on `images: true`.
105
- - **Size limits:** the sitemap is split into files of at most 45,000 URLs (protocol limit 50,000 / 50 MB) under `sitemap-index.xml`.
106
- - **Redirect conflicts:** the build warns when a redirect source is also a real page.
107
- - **On-demand pages** aren't files, so add them yourself:
108
- - with `extraEntries: async () => [...]`; or
109
- - with a `sitemapEndpoint` route listed in `extraSitemaps`.
110
-
111
- **robots.txt.** The integration writes it unless one already exists in `public/`.
112
- - **Production:** allows crawling and lists the sitemap index.
113
- - **Every other environment** (`robots.production: false`): `Disallow: /`, so preview and staging deploys never get indexed. Production defaults to `true`, so wire the flag to your deploy environment.
114
-
115
- **RSS.** Set up a feed with `rssEndpoint`:
116
-
117
- ```ts
118
- // src/pages/blog/rss.xml.ts
119
- export const GET = rssEndpoint(async ({ site }) => ({
120
- title: 'Champion Healthcare blog', description: '…', site: site!, feedUrl: new URL('/blog/rss.xml', site).href,
121
- items: posts.map((p) => ({ title: p.title, link: `/blog/${p.slug}/`, pubDate: p.date, description: p.summary, content: p.html })),
122
- }));
123
- ```
124
-
125
- - It's RSS 2.0 with `atom:link rel="self"`.
126
- - Items are newest first, limited to 50.
127
- - Dates use RFC 822, and relative links are made absolute.
128
- - `content:encoded` handles `]]>` correctly, and `dc:creator` holds the authors (RSS `<author>` would need an email address).
129
- - Invalid items are dropped.
130
-
131
- ## RedirectMap
132
-
133
- ```js
134
- // src/data/redirects.mjs
135
- export const redirects = new RedirectMap([
136
- { from: '/home-health-services', to: '/services/home-health' },
137
- { from: '/news/[slug]', to: '/blog/[slug]' },
138
- { from: '/docs/[...path]', to: '/help/[...path]' },
139
- { from: '/flu-shots', to: '/contact', status: 302 },
140
- ]);
141
- ```
142
-
143
- **Checks, which fail the build:**
144
- - loops (`/a → /b → /a`);
145
- - the same source pointing to two different places;
146
- - self-redirects;
147
- - destination params that aren't in the source;
148
- - non-redirect status codes.
149
-
150
- **Cleanup, reported as warnings:**
151
- - **Chains collapse:** `/a → /b → /c` becomes `/a → /c`, so visitors and crawlers take one hop.
152
- - **Sources are normalized:** trailing slash, `//`, and full old URLs reduced to their path.
153
- - **Query strings in a source:** reported, because they can't be matched.
154
-
155
- **Exporting.** The integration feeds `toAstro()` into the config. Astro's adapters (Netlify, Vercel, Cloudflare) turn that into real redirects, while a purely static build gets meta-refresh pages. For other hosts:
156
- - `toRedirectsFile()` writes a Netlify or Cloudflare Pages `_redirects` file (`[slug]` becomes `:slug`, `[...rest]` becomes `*` / `:splat`).
157
- - `toVercel()` gives Vercel's format (`:path*`).
158
-
159
- **Site migrations:** `RedirectMap.fromCsv(text)` reads a `from,to,status` export from a crawl spreadsheet. It handles quotes, BOM, CRLF and `#` comments. Use `caseInsensitive: true` for old IIS sites.
160
-
161
- **Redirects managed in the CMS** on SSR sites, without a rebuild:
162
-
163
- ```ts
164
- export const onRequest = createRedirectMiddleware(async () => redirectMapFromCms((await getSettings()).redirects));
165
- ```
166
-
167
- The incoming query string is kept, and the destination's own parameters win.
168
-
169
- ## CMS (Tina)
170
-
171
- - `seoField` is a per-page "Search & sharing" object: title, description, share image and alt text, hide from search, canonical. Each field has editor hints about length.
172
- - `seoProps(page.seo, fallbacks)` maps it to SEOHead props.
173
- - `redirectsField` is a redirect list for a settings singleton, and `redirectMapFromCms(rows)` turns it into a RedirectMap.
174
-
175
- ## Testing
176
-
177
- ```sh
178
- pnpm test # 30 tests, including the sitemap build on a fake dist/
179
- pnpm test:browser # 25 checks: XML via lxml (+ xmllint when installed); head + JSON-LD in Chrome under strict CSP
180
- ```
181
-
182
- Setup and flags: [TESTING.md](../../TESTING.md). Without `xmllint` the 6 xmllint checks are skipped (19 run).
183
-
184
- **Not yet verified:**
185
- - **Astro:** `astro build` / `astro check`, i.e. the `getImage` crop, the integration hooks against Astro 5's real objects, and adapter redirect output.
186
- - **Schemas:** the XML is checked to be well-formed and structurally right, but not against the sitemaps.org XSD, which wasn't available offline.
187
- - **Google:** results from Google's Rich Results Test.
1
+ # @sinnstack/ui/seo
2
+
3
+ SEO for Sinnstack sites, all server-rendered and CSP-safe:
4
+
5
+ | Piece | What it is | Import |
6
+ | --- | --- | --- |
7
+ | **SEOHead** | Title, description, canonical, robots, hreflang, Open Graph, Twitter/X, feeds | `@sinnstack/ui/seo` |
8
+ | **JSONLD** | Structured data, with typed builders and checks | `@sinnstack/ui/seo` + `@sinnstack/ui/seo/jsonld` |
9
+ | **Sitemap / RSS** | Sitemaps built from your pages, RSS feeds and robots.txt | `@sinnstack/ui/seo/integration`, `/rss`, `/sitemap` |
10
+ | **RedirectMap** | Redirects from old URLs, checked and exported to Astro or your host | `@sinnstack/ui/seo/redirects` |
11
+
12
+ ```js
13
+ // astro.config.mjs
14
+ import sinnSeo from '@sinnstack/ui/seo/integration';
15
+ import { redirects } from './src/data/redirects.mjs';
16
+ export default defineConfig({
17
+ site: 'https://championhealthcare.com', // required: canonicals, sitemaps and share URLs use it
18
+ integrations: [sinnSeo({ redirects, robots: { production: process.env.DEPLOY_ENV === 'production' } })],
19
+ });
20
+ ```
21
+
22
+ ## SEOHead
23
+
24
+ Place it in your layout's `<head>`:
25
+
26
+ ```astro
27
+ <SEOHead title={title} titleTemplate="%s | Champion Healthcare" defaultTitle="Champion Healthcare"
28
+ description={description} siteName="Champion Healthcare" locale="en_US"
29
+ image={{ src: cover, alt: 'A nurse reviewing a care plan with a patient' }}
30
+ noindex={noindex} feeds={[{ title: 'Blog', href: '/blog/rss.xml' }]} />
31
+ ```
32
+
33
+ **Canonical URL**
34
+ - Built from the current URL, but always on your production `site` origin, so preview deploys never claim to be the real page.
35
+ - The hash and every query parameter are dropped (UTM tags, for example), except those you list in `keepQuery`, such as `page`.
36
+ - `index.html` is removed and your `trailingSlash` setting is applied (the integration passes it in).
37
+ - An explicit `canonical` can be relative (resolved on the site) or absolute (for content syndicated from elsewhere).
38
+
39
+ **Title:** `titleTemplate` is skipped when the title already contains the site name. `og:title` uses the bare page title.
40
+
41
+ **Share image:** an imported image is cropped to a 1200×630 JPEG, the size Facebook, LinkedIn, Slack and X show large. URL strings are used as given. With an image, the Twitter card is `summary_large_image`; without one it's `summary`.
42
+
43
+ **Robots:** indexable pages get `max-image-preview:large`, so Google can show big image previews. `noindex` also keeps the page out of the sitemap.
44
+
45
+ **Development warnings** (`warn`, on by default in dev):
46
+ - a missing title or description, or one that's too long or too short;
47
+ - no share image, a share image smaller than 1200×630, or missing image alt text;
48
+ - `noindex` while the canonical points elsewhere;
49
+ - duplicate hreflang values, or hreflang alternates that don't include the page itself;
50
+ - no `site` set.
51
+
52
+ **Safety:** every value is escaped (tested with `</title><script>` in a title).
53
+
54
+ Without Astro, `buildHead(input)` returns the tags plus warnings, and `renderHead(tags)` returns HTML.
55
+
56
+ ## JSONLD
57
+
58
+ ```astro
59
+ ---
60
+ import { breadcrumbList, article } from '@sinnstack/ui/seo/jsonld';
61
+ ---
62
+ <JSONLD data={[breadcrumbList([{ name: 'Home', url: '/' }, { name: 'Blog', url: '/blog/' }, { name: post.title }], { site: Astro.site }),
63
+ article({ type: 'BlogPosting', url, headline: post.title, images: [cover], datePublished: post.date, authors: [{ name: post.author }] })]} />
64
+ ```
65
+
66
+ **Builders:**
67
+
68
+ | Builder | Notes |
69
+ | --- | --- |
70
+ | `organization` | Any type, e.g. `MedicalOrganization` |
71
+ | `localBusiness` | `MedicalClinic`, `Physician`, `Dentist`, `Pharmacy`… Includes opening hours from `{ days: ['Mo','Fr'], opens, closes }`, geo, area served, medical specialty and the parent organization |
72
+ | `website` | Includes the site search action |
73
+ | `webPage` | |
74
+ | `breadcrumbList` | Positions added automatically, URLs made absolute |
75
+ | `article` / `BlogPosting` / `NewsArticle` | |
76
+ | `faqPage` | Google currently shows FAQ rich results mainly for authoritative health and government sites |
77
+ | `event` | In person or online, with offers |
78
+ | `person` | |
79
+ | `service` | |
80
+
81
+ **Linking:** `graph()` combines nodes into one `@graph`, linked by `@id`. For example, a location's `parentOrganization` points to `https://site/#organization`.
82
+
83
+ **Development checks:**
84
+ - Google's required and recommended properties for each type.
85
+ - Dates in ISO 8601, and datetimes that include a time zone.
86
+ - Absolute URLs.
87
+ - Breadcrumb positions, and only the last breadcrumb may omit its URL.
88
+ - FAQ answers that are actually filled in.
89
+ - `@id` references that point to nodes not in the graph.
90
+
91
+ **Serialization** escapes `<`, `>`, `&` and U+2028/2029, so CMS text containing `</script>` can't break out. A test checks this in Chrome.
92
+
93
+ **CSP:** `application/ld+json` is a data block that browsers never execute, so `script-src` doesn't apply. A test checks this under `script-src 'self'` and finds no violations.
94
+
95
+ ## Sitemap, RSS and robots.txt
96
+
97
+ **Sitemap (integration).** After the build, it reads each page's `<head>` from the HTML Astro actually wrote, so the sitemap agrees with SEOHead.
98
+ - **Left out:**
99
+ - pages marked `noindex`;
100
+ - pages whose canonical points to another URL (print versions, duplicates);
101
+ - Astro's redirect stubs;
102
+ - `404` and `500` pages;
103
+ - anything matching `exclude` or rejected by `filter`.
104
+ - **Carried over:** hreflang alternates, and `article:modified_time` as `lastmod`. `og:image` too, if you turn on `images: true`.
105
+ - **Size limits:** the sitemap is split into files of at most 45,000 URLs (protocol limit 50,000 / 50 MB) under `sitemap-index.xml`.
106
+ - **Redirect conflicts:** the build warns when a redirect source is also a real page.
107
+ - **On-demand pages** aren't files, so add them yourself:
108
+ - with `extraEntries: async () => [...]`; or
109
+ - with a `sitemapEndpoint` route listed in `extraSitemaps`.
110
+
111
+ **robots.txt.** The integration writes it unless one already exists in `public/`.
112
+ - **Production:** allows crawling and lists the sitemap index.
113
+ - **Every other environment** (`robots.production: false`): `Disallow: /`, so preview and staging deploys never get indexed. Production defaults to `true`, so wire the flag to your deploy environment.
114
+
115
+ **RSS.** Set up a feed with `rssEndpoint`:
116
+
117
+ ```ts
118
+ // src/pages/blog/rss.xml.ts
119
+ export const GET = rssEndpoint(async ({ site }) => ({
120
+ title: 'Champion Healthcare blog', description: '…', site: site!, feedUrl: new URL('/blog/rss.xml', site).href,
121
+ items: posts.map((p) => ({ title: p.title, link: `/blog/${p.slug}/`, pubDate: p.date, description: p.summary, content: p.html })),
122
+ }));
123
+ ```
124
+
125
+ - It's RSS 2.0 with `atom:link rel="self"`.
126
+ - Items are newest first, limited to 50.
127
+ - Dates use RFC 822, and relative links are made absolute.
128
+ - `content:encoded` handles `]]>` correctly, and `dc:creator` holds the authors (RSS `<author>` would need an email address).
129
+ - Invalid items are dropped.
130
+
131
+ ## RedirectMap
132
+
133
+ ```js
134
+ // src/data/redirects.mjs
135
+ export const redirects = new RedirectMap([
136
+ { from: '/home-health-services', to: '/services/home-health' },
137
+ { from: '/news/[slug]', to: '/blog/[slug]' },
138
+ { from: '/docs/[...path]', to: '/help/[...path]' },
139
+ { from: '/flu-shots', to: '/contact', status: 302 },
140
+ ]);
141
+ ```
142
+
143
+ **Checks, which fail the build:**
144
+ - loops (`/a → /b → /a`);
145
+ - the same source pointing to two different places;
146
+ - self-redirects;
147
+ - destination params that aren't in the source;
148
+ - non-redirect status codes.
149
+
150
+ **Cleanup, reported as warnings:**
151
+ - **Chains collapse:** `/a → /b → /c` becomes `/a → /c`, so visitors and crawlers take one hop.
152
+ - **Sources are normalized:** trailing slash, `//`, and full old URLs reduced to their path.
153
+ - **Query strings in a source:** reported, because they can't be matched.
154
+
155
+ **Exporting.** The integration feeds `toAstro()` into the config. Astro's adapters (Netlify, Vercel, Cloudflare) turn that into real redirects, while a purely static build gets meta-refresh pages.
156
+
157
+ A static build makes one page per path for a redirect with params (`/news/[slug]`), and it takes those paths from the `getStaticPaths` of the destination page (`src/pages/blog/[slug].astro`). When that page doesn't exist, the integration leaves the rule out of Astro's config and warns, instead of letting the build fail. The rule stays in the map for your host's redirect file and the middleware. With `output: 'server'`, every rule goes to Astro.
158
+
159
+ For other hosts:
160
+ - `toRedirectsFile()` writes a Netlify or Cloudflare Pages `_redirects` file (`[slug]` becomes `:slug`, `[...rest]` becomes `*` / `:splat`).
161
+ - `toVercel()` gives Vercel's format (`:path*`).
162
+
163
+ **Site migrations:** `RedirectMap.fromCsv(text)` reads a `from,to,status` export from a crawl spreadsheet. It handles quotes, BOM, CRLF and `#` comments. Use `caseInsensitive: true` for old IIS sites.
164
+
165
+ **Redirects managed in the CMS** on SSR sites, without a rebuild:
166
+
167
+ ```ts
168
+ export const onRequest = createRedirectMiddleware(async () => redirectMapFromCms((await getSettings()).redirects));
169
+ ```
170
+
171
+ The incoming query string is kept, and the destination's own parameters win.
172
+
173
+ ## CMS
174
+
175
+ - A per-page `seo` object (`CmsSeo`: `title`, `description`, `image`, `imageAlt`, `noindex`, `canonical`). `seoProps(page.seo, fallbacks, { resolveImage })` maps it to SEOHead props. Pass the same `resolveImage` you give BlockRenderer: the CMS stores the share image as a path like `/src/assets/share.jpg`, which only works as a URL after it's resolved to the built asset.
176
+ - A redirect list in site settings (rows of `from`, `to`, `status` `'301' | '302' | '307' | '308'`). `redirectMapFromCms(rows)` turns it into a RedirectMap.
177
+ - SinnStackCMS fields for both ship in `@sinnstack/ui/seo/schema`: `seo: seoSchema` on a page collection, `redirects: redirectsSchema` in site settings.
178
+
179
+ ## Testing
180
+
181
+ ```sh
182
+ pnpm test # 30 tests, including the sitemap build on a fake dist/
183
+ pnpm test:browser # 25 checks: XML via lxml (+ xmllint when installed); head + JSON-LD in Chrome under strict CSP
184
+ ```
185
+
186
+ Setup and flags: [TESTING.md](../../TESTING.md). Without `xmllint` the 6 xmllint checks are skipped (19 run).
187
+
188
+ **Not yet verified:**
189
+ - **Astro:** `astro build` / `astro check`, i.e. the `getImage` crop, the integration hooks against Astro 5's real objects, and adapter redirect output.
190
+ - **Schemas:** the XML is checked to be well-formed and structurally right, but not against the sitemaps.org XSD, which wasn't available offline.
191
+ - **Google:** results from Google's Rich Results Test.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@sinnstack/ui",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
- "description": "Astro components and design tokens for fast, accessible marketing sites: layout and form primitives, page-section blocks with TinaCMS schemas, SEO tooling, SVG charts and optional motion. Static HTML first, strict-CSP safe.",
5
+ "description": "Astro components and design tokens for fast, accessible marketing sites: layout and form primitives, page-section blocks with CMS data mappers, SEO tooling, SVG charts and optional motion. Static HTML first, strict-CSP safe.",
6
6
  "license": "MPL-2.0",
7
7
  "author": "Jeffrey Jackson (Sinnstack)",
8
8
  "repository": {
@@ -21,45 +21,33 @@
21
21
  "./primitives/*.astro": "./src/primitives/*.astro",
22
22
  "./primitives/types": "./src/primitives/types.ts",
23
23
  "./primitives/utils": "./src/primitives/utils.ts",
24
- "./primitives/motion": "./src/primitives/lib/motion.ts",
25
- "./primitives/focus": "./src/primitives/lib/focus.ts",
26
- "./primitives/focus-trap": "./src/primitives/lib/focus-trap.ts",
27
- "./primitives/deprecate": "./src/primitives/lib/deprecate.ts",
28
24
  "./primitives/internal/*": null,
25
+ "./primitives/*": "./src/primitives/lib/*.ts",
29
26
  "./blocks": "./src/blocks/index.ts",
30
27
  "./blocks/*.astro": "./src/blocks/*.astro",
31
28
  "./blocks/types": "./src/blocks/types.ts",
32
29
  "./blocks/icons": "./src/blocks/icons.ts",
33
30
  "./blocks/cms": "./src/blocks/cms/index.ts",
31
+ "./blocks/schema": "./src/blocks/cms/schema.ts",
34
32
  "./blocks/registry": "./src/blocks/registry.ts",
35
- "./blocks/maintenance": "./src/blocks/lib/maintenance.ts",
36
- "./blocks/error-pages": "./src/blocks/lib/error-pages.ts",
37
- "./blocks/contact": "./src/blocks/lib/contact.ts",
38
33
  "./blocks/consent": "./src/blocks/consent.ts",
39
- "./blocks/rich-text": "./src/blocks/lib/rich-text.ts",
40
- "./blocks/hours": "./src/blocks/lib/hours.ts",
41
- "./blocks/faq": "./src/blocks/lib/faq.ts",
42
34
  "./blocks/styles.css": "./src/blocks/styles/blocks.css",
43
35
  "./blocks/internal/*": null,
36
+ "./blocks/*": "./src/blocks/lib/*.ts",
44
37
  "./seo": "./src/seo/index.ts",
45
38
  "./seo/*.astro": "./src/seo/*.astro",
46
- "./seo/meta": "./src/seo/lib/meta.ts",
47
- "./seo/jsonld": "./src/seo/lib/jsonld.ts",
48
- "./seo/sitemap": "./src/seo/lib/sitemap.ts",
49
- "./seo/rss": "./src/seo/lib/rss.ts",
50
- "./seo/robots": "./src/seo/lib/robots.ts",
51
- "./seo/redirects": "./src/seo/lib/redirects.ts",
52
39
  "./seo/integration": "./src/seo/integration.ts",
53
40
  "./seo/cms": "./src/seo/cms.ts",
41
+ "./seo/schema": "./src/seo/schema.ts",
54
42
  "./seo/internal/*": null,
43
+ "./seo/*": "./src/seo/lib/*.ts",
55
44
  "./data": "./src/data/index.ts",
56
45
  "./data/*.astro": "./src/data/*.astro",
57
- "./data/chart": "./src/data/lib/chart.ts",
58
- "./data/sparkline": "./src/data/lib/sparkline.ts",
59
- "./data/render": "./src/data/lib/render.ts",
60
46
  "./data/cms": "./src/data/cms.ts",
47
+ "./data/schema": "./src/data/schema.ts",
61
48
  "./data/styles.css": "./src/data/styles/chart.css",
62
49
  "./data/internal/*": null,
50
+ "./data/*": "./src/data/lib/*.ts",
63
51
  "./motion": "./src/motion/index.ts",
64
52
  "./motion/*.astro": "./src/motion/*.astro",
65
53
  "./motion/runtime": "./src/motion/runtime/runtime.ts",
@@ -69,6 +57,8 @@
69
57
  "./motion/integration": "./src/motion/integration.ts",
70
58
  "./motion/styles.css": "./src/motion/styles/motion.css",
71
59
  "./motion/internal/*": null,
60
+ "./finishes/*.css": "./src/finishes/*.css",
61
+ "./finishes/scripts/*": "./src/finishes/scripts/*.ts",
72
62
  "./package.json": "./package.json"
73
63
  },
74
64
  "files": [
@@ -84,7 +74,8 @@
84
74
  "**/*.astro",
85
75
  "./src/primitives/scripts/*.ts",
86
76
  "./src/blocks/scripts/*.ts",
87
- "./src/data/scripts/*.ts"
77
+ "./src/data/scripts/*.ts",
78
+ "./src/finishes/scripts/*.ts"
88
79
  ],
89
80
  "peerDependencies": {
90
81
  "astro": "^5.10.0",
@@ -118,7 +109,7 @@
118
109
  "layout",
119
110
  "landing-page",
120
111
  "blocks",
121
- "tinacms",
112
+ "cms",
122
113
  "seo",
123
114
  "sitemap",
124
115
  "json-ld",
@@ -136,7 +127,7 @@
136
127
  "gen:chart-css": "node scripts/generate-chart-css.mjs",
137
128
  "gen:motion-css": "node scripts/generate-motion-css.mjs",
138
129
  "check": "node scripts/check-contrast.mjs && astro check",
139
- "test": "node --no-warnings test/primitives/controls/slider.unit.mjs && node --no-warnings test/primitives/layer-order.unit.mjs && node --no-warnings test/blocks/unit/system-pages.unit.mjs && node --no-warnings test/blocks/unit/new-blocks.unit.mjs && node --no-warnings test/blocks/unit/content-blocks.unit.mjs && node --no-warnings test/seo/unit/seo.unit.mjs && node --no-warnings test/data/unit/chart-model.unit.mjs",
130
+ "test": "node --no-warnings test/package/exports.unit.mjs && node --no-warnings test/primitives/controls/slider.unit.mjs && node --no-warnings test/primitives/layer-order.unit.mjs && node --no-warnings test/finishes/finish-contract.unit.mjs && node --no-warnings test/blocks/unit/system-pages.unit.mjs && node --no-warnings test/blocks/unit/new-blocks.unit.mjs && node --no-warnings test/blocks/unit/content-blocks.unit.mjs && node --no-warnings test/blocks/unit/schema.unit.mjs && node --no-warnings test/blocks/unit/markdown.unit.mjs && node --no-warnings test/seo/unit/seo.unit.mjs && node --no-warnings test/data/unit/chart-model.unit.mjs",
140
131
  "test:browser": "node ../../scripts/test-browser.mjs all",
141
132
  "test:visual": "node ../../scripts/test-browser.mjs all --only-visual",
142
133
  "size": "size-limit"
@@ -2,8 +2,10 @@
2
2
  /**
3
3
  * BlockRenderer — renders a page's list of CMS blocks through the registry.
4
4
  *
5
- * - Picks each block's component by `_template` (or Tina's `__typename`), maps CMS data to props,
6
- * and passes the raw data on for `data-tina-field` click-to-edit.
5
+ * - Picks each block's component by `_template` and maps the CMS data to props.
6
+ * - With `fieldPath` (the key the blocks are stored under, e.g. "blocks"), each block gets its
7
+ * path (`blocks.2`) and renders `data-sinn-field` attributes for SinnStackCMS visual editing.
8
+ * Leave it off in production for clean HTML.
7
9
  * - Heading levels are decided here, not by editors: the first block that can hold the page title
8
10
  * (Hero or PageHeader, `h1: true` in the registry) is the page's h1 (unless `pageHasH1`);
9
11
  * every other block heading is h2.
@@ -28,22 +30,26 @@ type Props = {
28
30
  placeholder?: boolean;
29
31
  /** The layout already renders an h1, so no hero should. */
30
32
  pageHasH1?: boolean;
33
+ /** Where `blocks` sits in the content entry (e.g. "blocks"). Turns on `data-sinn-field` annotations. */
34
+ fieldPath?: string;
31
35
  };
32
36
 
33
- const { blocks = [], registry = blockRegistry, resolveImage = noImages, placeholder = PLACEHOLDER_DEFAULT, pageHasH1 = false } = Astro.props;
37
+ const { blocks = [], registry = blockRegistry, resolveImage = noImages, placeholder = PLACEHOLDER_DEFAULT, pageHasH1 = false, fieldPath } = Astro.props;
34
38
 
35
39
  let h1Used = pageHasH1;
36
- const rendered = (blocks ?? []).filter(Boolean).map((block) => {
37
- const name = templateName(block!);
40
+ type Rendered = { name: string | undefined; entry: BlockRegistry[string] | undefined; props: Record<string, unknown> };
41
+ const rendered = (blocks ?? []).flatMap((block, index): Rendered[] => {
42
+ if (!block) return [];
43
+ const name = templateName(block);
38
44
  const entry = name ? registry[name] : undefined;
39
45
  if (!entry) {
40
46
  if (import.meta.env?.DEV) console.warn(`[BlockRenderer] No block registered for "${name ?? '(unknown)'}".`);
41
- return { name, entry: undefined, props: {} };
47
+ return [{ name, entry: undefined, props: {} }];
42
48
  }
43
49
  const headingLevel = (entry.h1 ?? name === 'hero') && !h1Used ? 1 : 2;
44
50
  if (headingLevel === 1) h1Used = true;
45
51
  const props = entry.toProps(block, { resolveImage, headingLevel, placeholder });
46
- return { name, entry, props: { ...props, tina: block } };
52
+ return [{ name, entry, props: { ...props, fieldPath: fieldPath ? `${fieldPath}.${index}` : undefined } }];
47
53
  });
48
54
  ---
49
55
 
@@ -26,7 +26,7 @@ import type { ActionItem, BlockProps, HeadingLevelNumber } from './types';
26
26
  import Actions from './internal/Actions.astro';
27
27
  import Placeholder from './internal/Placeholder.astro';
28
28
  import { blockIds, PLACEHOLDER_DEFAULT } from './internal/util';
29
- import { tf, tinaField } from './internal/tina';
29
+ import { sf, joinField } from './internal/fields';
30
30
  import './styles/blocks.css';
31
31
  import { renameValue } from '../primitives/lib/deprecate';
32
32
 
@@ -60,7 +60,7 @@ const {
60
60
  scheme,
61
61
  containerSize = 'default',
62
62
  placeholder = PLACEHOLDER_DEFAULT,
63
- tina,
63
+ fieldPath,
64
64
  id,
65
65
  class: className,
66
66
  ...rest
@@ -76,7 +76,7 @@ const hasAside = actions.length > 0 || slots.has('actions') || Boolean(note) ||
76
76
 
77
77
  {
78
78
  !hasHeading ? (
79
- placeholder && <Placeholder label="Call to action" hint="Add a heading and at least one action." tinaField={tinaField(tina)} />
79
+ placeholder && <Placeholder label="Call to action" hint="Add a heading and at least one action." field={joinField(fieldPath)} />
80
80
  ) : (
81
81
  <section
82
82
  id={sectionId}
@@ -88,18 +88,18 @@ const hasAside = actions.length > 0 || slots.has('actions') || Boolean(note) ||
88
88
  data-align={align === 'center' ? 'center' : undefined}
89
89
  data-bleed={bleed ? '' : undefined}
90
90
  aria-labelledby={headingId}
91
- {...tf(tina)}
91
+ {...sf(fieldPath)}
92
92
  {...rest}
93
93
  >
94
94
  <Container size={bleed ? 'full' : containerSize} gutter={bleed ? 'none' : 'm'} query={false}>
95
95
  <div class="sinn-cta__panel" data-surface={surface} data-tone={surface ? tone : undefined}>
96
96
  <Container size={bleed ? containerSize : 'full'} gutter={bleed ? 'm' : 'none'} query={false} class="sinn-cta__inner">
97
97
  <div class="sinn-cta__text">
98
- <Heading level={headingLevel} size={size === 'l' ? '3xl' : '2xl'} weight="bold" id={headingId} class="sinn-cta__title" {...tf(tina, 'heading')}>
98
+ <Heading level={headingLevel} size={size === 'l' ? '3xl' : '2xl'} weight="bold" id={headingId} class="sinn-cta__title" {...sf(fieldPath, 'heading')}>
99
99
  {slots.has('heading') ? <slot name="heading" /> : heading}
100
100
  </Heading>
101
101
  {(description || slots.has('description')) && (
102
- <Text size="l" class="sinn-cta__description" measure {...tf(tina, 'description')}>
102
+ <Text size="l" class="sinn-cta__description" measure {...sf(fieldPath, 'description')}>
103
103
  {slots.has('description') ? <slot name="description" /> : description}
104
104
  </Text>
105
105
  )}
@@ -107,10 +107,10 @@ const hasAside = actions.length > 0 || slots.has('actions') || Boolean(note) ||
107
107
  </div>
108
108
  {hasAside && (
109
109
  <div class="sinn-cta__aside">
110
- <Actions actions={actions} class="sinn-cta__actions" tina={tina}>
110
+ <Actions actions={actions} class="sinn-cta__actions" fieldPath={fieldPath}>
111
111
  {slots.has('actions') && <slot name="actions" />}
112
112
  </Actions>
113
- {(note || slots.has('note')) && <p class="sinn-cta__note" {...tf(tina, 'note')}>{slots.has('note') ? <slot name="note" /> : note}</p>}
113
+ {(note || slots.has('note')) && <p class="sinn-cta__note" {...sf(fieldPath, 'note')}>{slots.has('note') ? <slot name="note" /> : note}</p>}
114
114
  </div>
115
115
  )}
116
116
  </Container>