@sinnstack/ui 0.0.0-stage → 0.2.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 (280) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +373 -0
  3. package/README.md +186 -2
  4. package/docs/blocks.md +364 -0
  5. package/docs/data.md +128 -0
  6. package/docs/motion.md +166 -0
  7. package/docs/primitives.md +510 -0
  8. package/docs/seo.md +187 -0
  9. package/docs/tokens.md +122 -0
  10. package/package.json +141 -3
  11. package/scripts/check-contrast.mjs +180 -0
  12. package/src/blocks/BlockRenderer.astro +54 -0
  13. package/src/blocks/CTABanner.astro +121 -0
  14. package/src/blocks/CTAPair.astro +110 -0
  15. package/src/blocks/CardGrid.astro +167 -0
  16. package/src/blocks/ConsentEmbed.astro +125 -0
  17. package/src/blocks/ConsentManager.astro +147 -0
  18. package/src/blocks/ConsentScript.astro +47 -0
  19. package/src/blocks/ContactCard.astro +164 -0
  20. package/src/blocks/ContactForm.astro +224 -0
  21. package/src/blocks/ErrorPage.astro +242 -0
  22. package/src/blocks/FAQ.astro +135 -0
  23. package/src/blocks/FeatureGrid.astro +148 -0
  24. package/src/blocks/Hero.astro +171 -0
  25. package/src/blocks/HeroCarousel.astro +220 -0
  26. package/src/blocks/HighlightCards.astro +107 -0
  27. package/src/blocks/LocationHours.astro +311 -0
  28. package/src/blocks/LogoCloud.astro +135 -0
  29. package/src/blocks/MaintenancePage.astro +168 -0
  30. package/src/blocks/MediaText.astro +177 -0
  31. package/src/blocks/PageHeader.astro +126 -0
  32. package/src/blocks/ProseSection.astro +98 -0
  33. package/src/blocks/Reviews.astro +194 -0
  34. package/src/blocks/RichText.astro +57 -0
  35. package/src/blocks/StatsBand.astro +117 -0
  36. package/src/blocks/Steps.astro +141 -0
  37. package/src/blocks/Testimonials.astro +144 -0
  38. package/src/blocks/Topbar.astro +158 -0
  39. package/src/blocks/cms/card-grid.ts +80 -0
  40. package/src/blocks/cms/consent.ts +45 -0
  41. package/src/blocks/cms/contact-card.ts +88 -0
  42. package/src/blocks/cms/contact-form.ts +55 -0
  43. package/src/blocks/cms/cta-banner.ts +48 -0
  44. package/src/blocks/cms/cta-pair.ts +63 -0
  45. package/src/blocks/cms/data-base.ts +7 -0
  46. package/src/blocks/cms/data.ts +257 -0
  47. package/src/blocks/cms/faq.ts +70 -0
  48. package/src/blocks/cms/feature-grid.ts +80 -0
  49. package/src/blocks/cms/fixtures.ts +599 -0
  50. package/src/blocks/cms/hero-carousel.ts +80 -0
  51. package/src/blocks/cms/hero.ts +77 -0
  52. package/src/blocks/cms/highlight-cards.ts +76 -0
  53. package/src/blocks/cms/images.ts +38 -0
  54. package/src/blocks/cms/index.ts +87 -0
  55. package/src/blocks/cms/location-hours.ts +149 -0
  56. package/src/blocks/cms/logo-cloud.ts +62 -0
  57. package/src/blocks/cms/media-text.ts +44 -0
  58. package/src/blocks/cms/page-header.ts +49 -0
  59. package/src/blocks/cms/pages.ts +81 -0
  60. package/src/blocks/cms/prose-section.ts +45 -0
  61. package/src/blocks/cms/reviews.ts +101 -0
  62. package/src/blocks/cms/shared.ts +115 -0
  63. package/src/blocks/cms/stats-band.ts +61 -0
  64. package/src/blocks/cms/steps.ts +67 -0
  65. package/src/blocks/cms/testimonials.ts +80 -0
  66. package/src/blocks/cms/topbar.ts +64 -0
  67. package/src/blocks/cms/types.ts +63 -0
  68. package/src/blocks/consent.ts +14 -0
  69. package/src/blocks/icons.ts +47 -0
  70. package/src/blocks/index.ts +42 -0
  71. package/src/blocks/internal/Actions.astro +29 -0
  72. package/src/blocks/internal/BlockHeader.astro +45 -0
  73. package/src/blocks/internal/BlockShell.astro +58 -0
  74. package/src/blocks/internal/CarouselScript.astro +7 -0
  75. package/src/blocks/internal/ConsentEmbedScript.astro +7 -0
  76. package/src/blocks/internal/ConsentManagerScript.astro +7 -0
  77. package/src/blocks/internal/HoursScript.astro +7 -0
  78. package/src/blocks/internal/Placeholder.astro +13 -0
  79. package/src/blocks/internal/RichTextNode.astro +133 -0
  80. package/src/blocks/internal/StandaloneDocument.astro +53 -0
  81. package/src/blocks/internal/tina.ts +19 -0
  82. package/src/blocks/internal/util.ts +23 -0
  83. package/src/blocks/lib/consent.ts +96 -0
  84. package/src/blocks/lib/contact.ts +86 -0
  85. package/src/blocks/lib/error-pages.ts +119 -0
  86. package/src/blocks/lib/faq.ts +37 -0
  87. package/src/blocks/lib/hours.ts +201 -0
  88. package/src/blocks/lib/maintenance.ts +129 -0
  89. package/src/blocks/lib/reviews.ts +22 -0
  90. package/src/blocks/lib/rich-text.ts +143 -0
  91. package/src/blocks/lib/slug.ts +12 -0
  92. package/src/blocks/registry.ts +79 -0
  93. package/src/blocks/scripts/carousel.ts +218 -0
  94. package/src/blocks/scripts/consent-embed.ts +105 -0
  95. package/src/blocks/scripts/consent-manager.ts +112 -0
  96. package/src/blocks/scripts/consent-store.ts +86 -0
  97. package/src/blocks/scripts/error-page.ts +71 -0
  98. package/src/blocks/scripts/hours.ts +106 -0
  99. package/src/blocks/scripts/maintenance.ts +109 -0
  100. package/src/blocks/styles/blocks.css +1320 -0
  101. package/src/blocks/styles/consent.css +102 -0
  102. package/src/blocks/styles/faq.css +28 -0
  103. package/src/blocks/styles/location.css +92 -0
  104. package/src/blocks/styles/prose-section.css +13 -0
  105. package/src/blocks/styles/quotes.css +123 -0
  106. package/src/blocks/styles/rich-text.css +14 -0
  107. package/src/blocks/types.ts +283 -0
  108. package/src/data/ChartAxis.astro +19 -0
  109. package/src/data/ChartContainer.astro +151 -0
  110. package/src/data/ChartLegend.astro +25 -0
  111. package/src/data/ChartSeries.astro +14 -0
  112. package/src/data/ChartTable.astro +17 -0
  113. package/src/data/ChartTooltip.astro +20 -0
  114. package/src/data/Sparkline.astro +55 -0
  115. package/src/data/cms.ts +190 -0
  116. package/src/data/index.ts +10 -0
  117. package/src/data/lib/chart.ts +450 -0
  118. package/src/data/lib/render.ts +219 -0
  119. package/src/data/lib/scale.ts +107 -0
  120. package/src/data/lib/sparkline.ts +117 -0
  121. package/src/data/scripts/chart.ts +324 -0
  122. package/src/data/styles/chart.css +392 -0
  123. package/src/motion/Marquee.astro +90 -0
  124. package/src/motion/MotionProvider.astro +50 -0
  125. package/src/motion/PageTransitions.astro +61 -0
  126. package/src/motion/Parallax.astro +44 -0
  127. package/src/motion/ParallaxLayer.astro +31 -0
  128. package/src/motion/RevealOnScroll.astro +59 -0
  129. package/src/motion/SceneRegistry.astro +38 -0
  130. package/src/motion/ScrollScene.astro +81 -0
  131. package/src/motion/index.ts +12 -0
  132. package/src/motion/integration.ts +48 -0
  133. package/src/motion/runtime/page-transitions.ts +68 -0
  134. package/src/motion/runtime/runtime.ts +180 -0
  135. package/src/motion/runtime/scenes.ts +248 -0
  136. package/src/motion/runtime/types.ts +103 -0
  137. package/src/motion/styles/motion.css +332 -0
  138. package/src/motion/transitions.ts +74 -0
  139. package/src/motion/virtual.d.ts +4 -0
  140. package/src/primitives/Accordion.astro +129 -0
  141. package/src/primitives/Breadcrumbs.astro +50 -0
  142. package/src/primitives/BulletList.astro +69 -0
  143. package/src/primitives/Button.astro +73 -0
  144. package/src/primitives/ButtonGroup.astro +54 -0
  145. package/src/primitives/Callout.astro +137 -0
  146. package/src/primitives/Caption.astro +35 -0
  147. package/src/primitives/Card.astro +72 -0
  148. package/src/primitives/CardContent.astro +24 -0
  149. package/src/primitives/CardFooter.astro +36 -0
  150. package/src/primitives/CardHeader.astro +86 -0
  151. package/src/primitives/Checkbox.astro +38 -0
  152. package/src/primitives/ChoiceGroup.astro +23 -0
  153. package/src/primitives/Cluster.astro +49 -0
  154. package/src/primitives/Container.astro +44 -0
  155. package/src/primitives/DescriptionList.astro +83 -0
  156. package/src/primitives/Dialog.astro +38 -0
  157. package/src/primitives/Disclosure.astro +67 -0
  158. package/src/primitives/Divider.astro +93 -0
  159. package/src/primitives/Drawer.astro +33 -0
  160. package/src/primitives/Fieldset.astro +80 -0
  161. package/src/primitives/Flex.astro +64 -0
  162. package/src/primitives/FocusRing.astro +63 -0
  163. package/src/primitives/FocusTrap.astro +64 -0
  164. package/src/primitives/Footer.astro +155 -0
  165. package/src/primitives/Form.astro +68 -0
  166. package/src/primitives/FormDescription.astro +26 -0
  167. package/src/primitives/FormError.astro +106 -0
  168. package/src/primitives/FormField.astro +72 -0
  169. package/src/primitives/Grid.astro +64 -0
  170. package/src/primitives/Heading.astro +45 -0
  171. package/src/primitives/IconButton.astro +48 -0
  172. package/src/primitives/Image.astro +125 -0
  173. package/src/primitives/Input.astro +84 -0
  174. package/src/primitives/Label.astro +50 -0
  175. package/src/primitives/Link.astro +81 -0
  176. package/src/primitives/LinkButton.astro +66 -0
  177. package/src/primitives/List.astro +39 -0
  178. package/src/primitives/ListItem.astro +178 -0
  179. package/src/primitives/MediaObject.astro +66 -0
  180. package/src/primitives/MetricCard.astro +276 -0
  181. package/src/primitives/NavLink.astro +81 -0
  182. package/src/primitives/NavMenu.astro +109 -0
  183. package/src/primitives/Navbar.astro +197 -0
  184. package/src/primitives/Panel.astro +153 -0
  185. package/src/primitives/Picture.astro +167 -0
  186. package/src/primitives/Popover.astro +95 -0
  187. package/src/primitives/Prose.astro +45 -0
  188. package/src/primitives/Radio.astro +21 -0
  189. package/src/primitives/Rating.astro +135 -0
  190. package/src/primitives/ReducedMotion.astro +90 -0
  191. package/src/primitives/SegmentedControl.astro +132 -0
  192. package/src/primitives/Select.astro +107 -0
  193. package/src/primitives/Sheet.astro +45 -0
  194. package/src/primitives/SkipLink.astro +31 -0
  195. package/src/primitives/Slider.astro +186 -0
  196. package/src/primitives/Spacer.astro +35 -0
  197. package/src/primitives/Stack.astro +51 -0
  198. package/src/primitives/Surface.astro +70 -0
  199. package/src/primitives/Switch.astro +22 -0
  200. package/src/primitives/Table.astro +382 -0
  201. package/src/primitives/Tabs.astro +126 -0
  202. package/src/primitives/Text.astro +56 -0
  203. package/src/primitives/Textarea.astro +73 -0
  204. package/src/primitives/Thumbnail.astro +154 -0
  205. package/src/primitives/Toggle.astro +99 -0
  206. package/src/primitives/Tooltip.astro +50 -0
  207. package/src/primitives/VisuallyHidden.astro +29 -0
  208. package/src/primitives/index.ts +103 -0
  209. package/src/primitives/internal/AccordionScript.astro +7 -0
  210. package/src/primitives/internal/ChoiceField.astro +89 -0
  211. package/src/primitives/internal/FocusTrapScript.astro +8 -0
  212. package/src/primitives/internal/FormValidationScript.astro +10 -0
  213. package/src/primitives/internal/IndeterminateScript.astro +13 -0
  214. package/src/primitives/internal/ModalPanel.astro +114 -0
  215. package/src/primitives/internal/OverlayScript.astro +7 -0
  216. package/src/primitives/internal/ReducedMotionScript.astro +7 -0
  217. package/src/primitives/internal/SliderScript.astro +7 -0
  218. package/src/primitives/internal/SparklineScript.astro +7 -0
  219. package/src/primitives/internal/TableSortScript.astro +7 -0
  220. package/src/primitives/internal/TabsScript.astro +7 -0
  221. package/src/primitives/internal/TooltipScript.astro +7 -0
  222. package/src/primitives/lib/deprecate.ts +47 -0
  223. package/src/primitives/lib/focus-trap.ts +197 -0
  224. package/src/primitives/lib/focus.ts +60 -0
  225. package/src/primitives/lib/image-plan.ts +82 -0
  226. package/src/primitives/lib/image.ts +129 -0
  227. package/src/primitives/lib/motion.ts +68 -0
  228. package/src/primitives/lib/slider.ts +170 -0
  229. package/src/primitives/scripts/accordion.ts +123 -0
  230. package/src/primitives/scripts/form-validation.ts +225 -0
  231. package/src/primitives/scripts/overlay.ts +71 -0
  232. package/src/primitives/scripts/reduced-motion.ts +59 -0
  233. package/src/primitives/scripts/slider.ts +150 -0
  234. package/src/primitives/scripts/sparkline.ts +131 -0
  235. package/src/primitives/scripts/table-sort.ts +68 -0
  236. package/src/primitives/scripts/tabs.ts +151 -0
  237. package/src/primitives/scripts/tooltip.ts +28 -0
  238. package/src/primitives/styles/a11y.css +104 -0
  239. package/src/primitives/styles/accordion.css +53 -0
  240. package/src/primitives/styles/breadcrumbs.css +59 -0
  241. package/src/primitives/styles/bullet-list.css +89 -0
  242. package/src/primitives/styles/button.css +237 -0
  243. package/src/primitives/styles/choice.css +164 -0
  244. package/src/primitives/styles/cluster.css +24 -0
  245. package/src/primitives/styles/container.css +19 -0
  246. package/src/primitives/styles/data.css +849 -0
  247. package/src/primitives/styles/disclosure.css +140 -0
  248. package/src/primitives/styles/divider.css +50 -0
  249. package/src/primitives/styles/flex.css +42 -0
  250. package/src/primitives/styles/form.css +241 -0
  251. package/src/primitives/styles/grid.css +36 -0
  252. package/src/primitives/styles/media.css +247 -0
  253. package/src/primitives/styles/nav.css +792 -0
  254. package/src/primitives/styles/overlay.css +362 -0
  255. package/src/primitives/styles/prose.css +146 -0
  256. package/src/primitives/styles/scale.css +175 -0
  257. package/src/primitives/styles/segmented.css +165 -0
  258. package/src/primitives/styles/slider.css +170 -0
  259. package/src/primitives/styles/spacer.css +17 -0
  260. package/src/primitives/styles/stack.css +25 -0
  261. package/src/primitives/styles/surface.css +403 -0
  262. package/src/primitives/styles/tabs.css +223 -0
  263. package/src/primitives/styles/typography.css +144 -0
  264. package/src/primitives/styles/utilities.css +24 -0
  265. package/src/primitives/types.ts +385 -0
  266. package/src/primitives/utils.ts +254 -0
  267. package/src/seo/JSONLD.astro +35 -0
  268. package/src/seo/SEOHead.astro +47 -0
  269. package/src/seo/cms.ts +80 -0
  270. package/src/seo/index.ts +10 -0
  271. package/src/seo/integration.ts +231 -0
  272. package/src/seo/lib/jsonld.ts +334 -0
  273. package/src/seo/lib/meta.ts +205 -0
  274. package/src/seo/lib/redirects.ts +283 -0
  275. package/src/seo/lib/robots.ts +33 -0
  276. package/src/seo/lib/rss.ts +98 -0
  277. package/src/seo/lib/sitemap.ts +105 -0
  278. package/src/seo/lib/url.ts +68 -0
  279. package/src/tokens/base.css +71 -0
  280. package/src/tokens/tokens.css +210 -0
@@ -0,0 +1,283 @@
1
+ /**
2
+ * RedirectMap — redirects from old URLs to new ones, defined once and checked before they ship:
3
+ * chains are collapsed (A→B→C becomes A→C), loops and conflicting duplicates are errors, and
4
+ * dynamic params must match. Export the same map to Astro's config, a Netlify/Cloudflare
5
+ * `_redirects` file, Vercel, or run it as middleware for CMS-managed redirects.
6
+ *
7
+ * const redirects = new RedirectMap([
8
+ * { from: '/old-services', to: '/services' },
9
+ * { from: '/blog/[slug]', to: '/articles/[slug]' },
10
+ * { from: '/promo', to: '/contact', status: 302 },
11
+ * ]);
12
+ * // astro.config.mjs → integrations: [sinnSeo({ redirects })] (or redirects: redirects.toAstro())
13
+ *
14
+ * Migrating a site? `RedirectMap.fromCsv(text)` reads a "from,to,status" spreadsheet export; full
15
+ * old URLs ("https://old-site.com/page.aspx?id=3") are reduced to their path.
16
+ */
17
+
18
+ export type RedirectStatus = 301 | 302 | 303 | 307 | 308;
19
+ export interface RedirectRule {
20
+ from: string;
21
+ to: string;
22
+ /** 301 (default, permanent), 308 (permanent, keeps method), 302/307 (temporary). */
23
+ status?: RedirectStatus;
24
+ }
25
+ interface Compiled extends Required<RedirectRule> {
26
+ params: string[];
27
+ pattern?: RegExp;
28
+ staticSegments: number;
29
+ }
30
+
31
+ const PARAM = /\[(\.\.\.)?([A-Za-z_][\w]*)\]/g;
32
+ const isExternal = (to: string) => /^https?:\/\//i.test(to);
33
+
34
+ function normalizePath(path: string, caseInsensitive: boolean): string {
35
+ let p = path.trim();
36
+ if (isExternal(p)) {
37
+ const u = new URL(p);
38
+ p = u.pathname;
39
+ }
40
+ p = p.split('#')[0];
41
+ if (!p.startsWith('/')) p = `/${p}`;
42
+ p = p.replace(/\/{2,}/g, '/');
43
+ if (p.length > 1) p = p.replace(/\/$/, '');
44
+ try {
45
+ p = decodeURI(p);
46
+ } catch {
47
+ /* keep */
48
+ }
49
+ return caseInsensitive ? p.toLowerCase() : p;
50
+ }
51
+
52
+ function compile(rule: Required<RedirectRule>): Compiled {
53
+ const params: string[] = [];
54
+ let staticSegments = 0;
55
+ const segs = rule.from.split('/').filter(Boolean);
56
+ let pattern: RegExp | undefined;
57
+ if (rule.from.includes('[')) {
58
+ const re = segs
59
+ .map((seg) => {
60
+ const m = /^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(seg);
61
+ if (m) {
62
+ params.push(m[2]);
63
+ return m[1] ? '(?:/(.+))?' : '/([^/]+)';
64
+ }
65
+ staticSegments++;
66
+ return `/${seg.replace(/[.*+?^${}()|\\]/g, '\\$&')}`;
67
+ })
68
+ .join('');
69
+ pattern = new RegExp(`^${re || '/'}$`);
70
+ } else staticSegments = segs.length;
71
+ return { ...rule, params, pattern, staticSegments };
72
+ }
73
+
74
+ export interface RedirectMapOptions {
75
+ /** Match old URLs regardless of case (old IIS / Windows sites). Default false. */
76
+ caseInsensitive?: boolean;
77
+ /** Keep the incoming query string on redirect (default true). */
78
+ preserveQuery?: boolean;
79
+ }
80
+
81
+ export class RedirectMap {
82
+ readonly rules: Array<Required<RedirectRule>> = [];
83
+ readonly errors: string[] = [];
84
+ readonly warnings: string[] = [];
85
+ private exact = new Map<string, Required<RedirectRule>>();
86
+ private dynamic: Compiled[] = [];
87
+ private opts: Required<RedirectMapOptions>;
88
+
89
+ constructor(input: RedirectRule[] | Record<string, string | { to: string; status?: RedirectStatus }>, options: RedirectMapOptions = {}) {
90
+ this.opts = { caseInsensitive: false, preserveQuery: true, ...options };
91
+ const list: RedirectRule[] = Array.isArray(input)
92
+ ? input
93
+ : Object.entries(input).map(([from, v]) => (typeof v === 'string' ? { from, to: v } : { from, ...v }));
94
+ const ci = this.opts.caseInsensitive;
95
+ const seen = new Map<string, Required<RedirectRule>>();
96
+ for (const raw of list) {
97
+ if (!raw?.from || !raw?.to) {
98
+ this.errors.push(`Rule needs "from" and "to": ${JSON.stringify(raw)}`);
99
+ continue;
100
+ }
101
+ if (raw.from.includes('?')) this.warnings.push(`"${raw.from}": query strings can't be matched; the rule matches the path only.`);
102
+ const from = normalizePath(raw.from, ci);
103
+ const [toPathRaw, toQuery] = raw.to.trim().split(/\?(.*)/s);
104
+ const to = isExternal(raw.to) ? raw.to.trim() : normalizePath(toPathRaw, false) + (toQuery ? `?${toQuery}` : '');
105
+ const status = (raw.status ?? 301) as RedirectStatus;
106
+ if (![301, 302, 303, 307, 308].includes(status)) {
107
+ this.errors.push(`"${raw.from}": status ${raw.status} isn't a redirect status.`);
108
+ continue;
109
+ }
110
+ const toPath = to.split('?')[0];
111
+ if (!isExternal(to) && (ci ? toPath.toLowerCase() : toPath) === from) {
112
+ this.errors.push(`"${raw.from}" redirects to itself.`);
113
+ continue;
114
+ }
115
+ const fromParams = [...from.matchAll(PARAM)].map((m) => m[2]);
116
+ const toParams = [...to.matchAll(PARAM)].map((m) => m[2]);
117
+ const missing = toParams.filter((p) => !fromParams.includes(p));
118
+ if (missing.length) {
119
+ this.errors.push(`"${raw.from}" → "${raw.to}": [${missing.join('], [')}] isn't in the source.`);
120
+ continue;
121
+ }
122
+ const prev = seen.get(from);
123
+ if (prev) {
124
+ if (prev.to === to && prev.status === status) this.warnings.push(`Duplicate rule for "${from}".`);
125
+ else this.errors.push(`"${from}" is defined twice: → "${prev.to}" and → "${to}".`);
126
+ continue;
127
+ }
128
+ const rule = { from, to, status };
129
+ seen.set(from, rule);
130
+ }
131
+ // Collapse chains between static rules, and catch loops.
132
+ for (const rule of seen.values()) {
133
+ if (rule.from.includes('[') || isExternal(rule.to)) continue;
134
+ const path = [rule.from];
135
+ let target = rule.to;
136
+ let hops = 0;
137
+ let loop = false;
138
+ while (true) {
139
+ const key = normalizePath(target.split('?')[0], ci);
140
+ const next = seen.get(key);
141
+ if (!next || next.from.includes('[')) break;
142
+ if (path.includes(key)) {
143
+ loop = true;
144
+ break;
145
+ }
146
+ path.push(key);
147
+ target = next.to;
148
+ hops++;
149
+ if (isExternal(target) || hops > 20) break;
150
+ }
151
+ if (loop) this.errors.push(`Redirect loop: ${[...path, path[0]].join(' → ')}`);
152
+ else if (hops) {
153
+ this.warnings.push(`Chain collapsed: ${path.join(' → ')} → ${target} (now "${rule.from}" → "${target}").`);
154
+ rule.to = target;
155
+ }
156
+ }
157
+ for (const rule of seen.values()) {
158
+ this.rules.push(rule);
159
+ if (rule.from.includes('[')) this.dynamic.push(compile(rule));
160
+ else this.exact.set(rule.from, rule);
161
+ }
162
+ // Most specific dynamic rules first.
163
+ this.dynamic.sort((a, b) => b.staticSegments - a.staticSegments || b.from.length - a.from.length);
164
+ }
165
+
166
+ get valid(): boolean {
167
+ return this.errors.length === 0;
168
+ }
169
+
170
+ /** Throws (listing every problem) when the map has errors. */
171
+ assertValid(): this {
172
+ if (!this.valid) throw new Error(`Redirect map has ${this.errors.length} error(s):\n - ${this.errors.join('\n - ')}`);
173
+ return this;
174
+ }
175
+
176
+ /** Where `pathname` should go, or undefined. Keeps the incoming query (destination params win). */
177
+ resolve(pathname: string, search = ''): { location: string; status: RedirectStatus } | undefined {
178
+ const key = normalizePath(pathname, this.opts.caseInsensitive);
179
+ let hit: { to: string; status: RedirectStatus } | undefined = this.exact.get(key);
180
+ if (!hit) {
181
+ for (const d of this.dynamic) {
182
+ const m = d.pattern!.exec(key);
183
+ if (!m) continue;
184
+ let to = d.to;
185
+ d.params.forEach((name, i) => {
186
+ to = to.replace(new RegExp(`\\[(?:\\.\\.\\.)?${name}\\]`, 'g'), (m[i + 1] ?? '').replace(/^\//, ''));
187
+ });
188
+ hit = { to: to.replace(/\/{2,}/g, '/').replace(/(.)\/$/, '$1'), status: d.status };
189
+ break;
190
+ }
191
+ }
192
+ if (!hit) return undefined;
193
+ if (!this.opts.preserveQuery || !search || search === '?') return { location: hit.to, status: hit.status };
194
+ const [base, destQuery = ''] = hit.to.split('?');
195
+ const params = new URLSearchParams(search);
196
+ for (const [k, v] of new URLSearchParams(destQuery)) params.set(k, v);
197
+ const qs = params.toString();
198
+ return { location: qs ? `${base}?${qs}` : base, status: hit.status };
199
+ }
200
+
201
+ /** For astro.config `redirects` (Astro emits real redirects on adapters, meta-refresh pages on static builds). */
202
+ toAstro(): Record<string, string | { status: RedirectStatus; destination: string }> {
203
+ return Object.fromEntries(this.assertValid().rules.map((r) => [r.from, r.status === 301 ? r.to : { status: r.status, destination: r.to }]));
204
+ }
205
+
206
+ /** A Netlify or Cloudflare Pages `_redirects` file. */
207
+ toRedirectsFile(): string {
208
+ const conv = (p: string, side: 'from' | 'to') =>
209
+ p.replace(PARAM, (_m, rest: string | undefined, name: string) => (rest ? (side === 'from' ? '*' : ':splat') : `:${name}`));
210
+ const width = Math.max(...this.assertValid().rules.map((r) => conv(r.from, 'from').length), 10);
211
+ return `${this.rules.map((r) => `${conv(r.from, 'from').padEnd(width)} ${conv(r.to, 'to')} ${r.status}`).join('\n')}\n`;
212
+ }
213
+
214
+ /** Vercel `redirects` array (vercel.json). */
215
+ toVercel(): Array<{ source: string; destination: string; statusCode: number }> {
216
+ const conv = (p: string) => p.replace(PARAM, (_m, rest: string | undefined, name: string) => (rest ? `:${name}*` : `:${name}`));
217
+ return this.assertValid().rules.map((r) => ({ source: conv(r.from), destination: conv(r.to), statusCode: r.status }));
218
+ }
219
+
220
+ /** Reads "from,to[,status]" CSV (header optional; quotes, BOM, CRLF and # comments handled). */
221
+ static fromCsv(text: string, options?: RedirectMapOptions): RedirectMap {
222
+ const rows = parseCsv(text.replace(/^/, ''));
223
+ const rules: RedirectRule[] = [];
224
+ rows.forEach((cells, i) => {
225
+ if (!cells.length || cells.every((c) => !c.trim()) || cells[0].trim().startsWith('#')) return;
226
+ if (i === 0 && /^(from|source|old)/i.test(cells[0].trim())) return;
227
+ const [from, to, status] = cells.map((c) => c.trim());
228
+ rules.push({ from, to, status: status ? (Number(status) as RedirectStatus) : undefined });
229
+ });
230
+ return new RedirectMap(rules, options);
231
+ }
232
+ }
233
+
234
+ function parseCsv(text: string): string[][] {
235
+ const rows: string[][] = [];
236
+ let row: string[] = [];
237
+ let cell = '';
238
+ let quoted = false;
239
+ for (let i = 0; i < text.length; i++) {
240
+ const c = text[i];
241
+ if (quoted) {
242
+ if (c === '"' && text[i + 1] === '"') {
243
+ cell += '"';
244
+ i++;
245
+ } else if (c === '"') quoted = false;
246
+ else cell += c;
247
+ } else if (c === '"') quoted = true;
248
+ else if (c === ',') {
249
+ row.push(cell);
250
+ cell = '';
251
+ } else if (c === '\n' || c === '\r') {
252
+ if (c === '\r' && text[i + 1] === '\n') i++;
253
+ row.push(cell);
254
+ rows.push(row);
255
+ row = [];
256
+ cell = '';
257
+ } else cell += c;
258
+ }
259
+ if (cell || row.length) {
260
+ row.push(cell);
261
+ rows.push(row);
262
+ }
263
+ return rows;
264
+ }
265
+
266
+ /** The parts of Astro's APIContext the middleware needs. */
267
+ export interface RedirectContext {
268
+ url: URL;
269
+ redirect(path: string, status?: RedirectStatus): Response;
270
+ }
271
+
272
+ /**
273
+ * Middleware for redirects that change without a rebuild (e.g. read from the CMS on SSR sites).
274
+ * export const onRequest = createRedirectMiddleware(() => loadRedirectsFromCms());
275
+ * Pass a RedirectMap, or a function returning one (called per request; cache it yourself).
276
+ */
277
+ export function createRedirectMiddleware(source: RedirectMap | (() => RedirectMap | Promise<RedirectMap>)) {
278
+ return async (context: RedirectContext, next: () => Promise<Response>): Promise<Response> => {
279
+ const map = typeof source === 'function' ? await source() : source;
280
+ const hit = map.resolve(context.url.pathname, context.url.search);
281
+ return hit ? context.redirect(hit.location, hit.status) : next();
282
+ };
283
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * robots.txt. Production allows crawling and lists the sitemap; every other environment
3
+ * (previews, staging) disallows everything, so test deploys never get indexed.
4
+ */
5
+ export interface RobotsRule {
6
+ userAgent: string | string[];
7
+ allow?: string[];
8
+ disallow?: string[];
9
+ crawlDelay?: number;
10
+ }
11
+ export interface RobotsOptions {
12
+ /** True only for the production deploy. */
13
+ production: boolean;
14
+ sitemaps?: string[];
15
+ /** Production rules; default allows everything. */
16
+ rules?: RobotsRule[];
17
+ }
18
+
19
+ export function buildRobotsTxt(options: RobotsOptions): string {
20
+ if (!options.production) return 'User-agent: *\nDisallow: /\n';
21
+ const rules = options.rules?.length ? options.rules : [{ userAgent: '*', allow: ['/'] }];
22
+ const out: string[] = [];
23
+ for (const r of rules) {
24
+ for (const ua of ([] as string[]).concat(r.userAgent)) out.push(`User-agent: ${ua}`);
25
+ for (const a of r.allow ?? []) out.push(`Allow: ${a}`);
26
+ for (const d of r.disallow ?? []) out.push(`Disallow: ${d}`);
27
+ if (r.crawlDelay) out.push(`Crawl-delay: ${r.crawlDelay}`);
28
+ if (!r.allow?.length && !r.disallow?.length) out.push('Disallow:');
29
+ out.push('');
30
+ }
31
+ for (const s of options.sitemaps ?? []) out.push(`Sitemap: ${s}`);
32
+ return `${out.join('\n').trim()}\n`;
33
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * RSS 2.0 feeds (with atom:link self, content:encoded and dc:creator).
3
+ *
4
+ * // src/pages/blog/rss.xml.ts
5
+ * import { rssEndpoint } from '@sinnstack/ui/seo/rss';
6
+ * export const GET = rssEndpoint(async (context) => ({
7
+ * title: 'Sinnstack blog', description: 'Guides for site owners and their teams',
8
+ * site: context.site!, feedUrl: new URL('/blog/rss.xml', context.site).href,
9
+ * items: (await getCollection('blog')).map((p) => ({ title: p.data.title, link: `/blog/${p.id}/`, pubDate: p.data.date, description: p.data.summary })),
10
+ * }));
11
+ * Advertise it with SEOHead `feeds={[{ title: 'Blog', href: '/blog/rss.xml' }]}`.
12
+ */
13
+ import { absolute, escapeXml, stripInvalidXml } from './url';
14
+
15
+ export interface RssItem {
16
+ title: string;
17
+ /** Absolute, or relative to `site`. */
18
+ link: string;
19
+ pubDate: string | Date;
20
+ /** Plain-text summary. */
21
+ description?: string;
22
+ /** Full HTML content (put in content:encoded). Make relative links absolute before passing it. */
23
+ content?: string;
24
+ /** Defaults to the link (permalink). */
25
+ guid?: string;
26
+ categories?: string[];
27
+ /** Author name(s), as dc:creator (RSS <author> requires an email address). */
28
+ authors?: string[];
29
+ enclosure?: { url: string; length: number; type: string };
30
+ }
31
+
32
+ export interface RssFeed {
33
+ title: string;
34
+ description: string;
35
+ /** The site (or section) the feed belongs to. */
36
+ site: string | URL;
37
+ /** The feed's own URL (atom:link rel="self"). */
38
+ feedUrl: string;
39
+ items: RssItem[];
40
+ language?: string;
41
+ copyright?: string;
42
+ /** Feed logo (≤ 144×400). */
43
+ image?: { url: string; title?: string };
44
+ /** Minutes a reader may cache the feed. */
45
+ ttl?: number;
46
+ /** Newest N items (default 50). */
47
+ limit?: number;
48
+ stylesheet?: string;
49
+ }
50
+
51
+ const x = (s: string) => escapeXml(stripInvalidXml(s));
52
+ const cdata = (s: string) => `<![CDATA[${stripInvalidXml(s).replace(/]]>/g, ']]]]><![CDATA[>')}]]>`;
53
+ /** RFC 822 date as RSS requires ("Sat, 14 Nov 2026 15:00:00 GMT"). */
54
+ export const rfc822 = (d: string | Date) => new Date(d).toUTCString();
55
+
56
+ export function buildRss(feed: RssFeed): string {
57
+ const site = String(feed.site);
58
+ const items = [...feed.items]
59
+ .filter((i) => i.title && i.link && Number.isFinite(new Date(i.pubDate).getTime()))
60
+ .sort((a, b) => new Date(b.pubDate).getTime() - new Date(a.pubDate).getTime())
61
+ .slice(0, feed.limit ?? 50);
62
+ const lines = ['<?xml version="1.0" encoding="UTF-8"?>'];
63
+ if (feed.stylesheet) lines.push(`<?xml-stylesheet type="text/xsl" href="${x(feed.stylesheet)}"?>`);
64
+ lines.push(
65
+ '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">',
66
+ ' <channel>',
67
+ ` <title>${x(feed.title)}</title>`,
68
+ ` <link>${x(absolute(site)!)}</link>`,
69
+ ` <description>${x(feed.description)}</description>`,
70
+ ` <atom:link href="${x(feed.feedUrl)}" rel="self" type="application/rss+xml"/>`,
71
+ );
72
+ if (feed.language) lines.push(` <language>${x(feed.language)}</language>`);
73
+ if (feed.copyright) lines.push(` <copyright>${x(feed.copyright)}</copyright>`);
74
+ if (feed.ttl) lines.push(` <ttl>${feed.ttl}</ttl>`);
75
+ if (items.length) lines.push(` <lastBuildDate>${rfc822(items[0].pubDate)}</lastBuildDate>`);
76
+ if (feed.image) lines.push(' <image>', ` <url>${x(absolute(feed.image.url, site)!)}</url>`, ` <title>${x(feed.image.title ?? feed.title)}</title>`, ` <link>${x(absolute(site)!)}</link>`, ' </image>');
77
+ for (const i of items) {
78
+ const link = absolute(i.link, site)!;
79
+ lines.push(' <item>', ` <title>${x(i.title)}</title>`, ` <link>${x(link)}</link>`);
80
+ const guid = i.guid ?? link;
81
+ lines.push(` <guid isPermaLink="${i.guid ? 'false' : 'true'}">${x(guid)}</guid>`);
82
+ lines.push(` <pubDate>${rfc822(i.pubDate)}</pubDate>`);
83
+ if (i.description) lines.push(` <description>${x(i.description)}</description>`);
84
+ if (i.content) lines.push(` <content:encoded>${cdata(i.content)}</content:encoded>`);
85
+ for (const a of i.authors ?? []) lines.push(` <dc:creator>${x(a)}</dc:creator>`);
86
+ for (const c of i.categories ?? []) lines.push(` <category>${x(c)}</category>`);
87
+ if (i.enclosure) lines.push(` <enclosure url="${x(absolute(i.enclosure.url, site)!)}" length="${Math.max(0, Math.round(i.enclosure.length))}" type="${x(i.enclosure.type)}"/>`);
88
+ lines.push(' </item>');
89
+ }
90
+ lines.push(' </channel>', '</rss>', '');
91
+ return lines.join('\n');
92
+ }
93
+
94
+ /** An Astro endpoint returning the feed. `context` is Astro's APIContext. */
95
+ export function rssEndpoint(getFeed: (context: { site?: URL; url: URL }) => RssFeed | Promise<RssFeed>) {
96
+ return async (context: { site?: URL; url: URL }) =>
97
+ new Response(buildRss(await getFeed(context)), { headers: { 'Content-Type': 'application/rss+xml; charset=utf-8' } });
98
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * XML sitemaps (sitemaps.org protocol, with Google's xhtml:link alternates and image extension).
3
+ * The `sinnSeo` integration builds them from your built pages; use these functions directly for
4
+ * on-demand routes (`sitemapEndpoint`).
5
+ */
6
+ import { escapeXml, isAbsolute, isoDate, stripInvalidXml } from './url';
7
+
8
+ export interface SitemapEntry {
9
+ loc: string;
10
+ lastmod?: string | Date;
11
+ /** Ignored by Google; kept for other engines when you set it. */
12
+ changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
13
+ /** Ignored by Google; 0.0–1.0. */
14
+ priority?: number;
15
+ /** hreflang alternates, including this URL itself. */
16
+ alternates?: Array<{ hreflang: string; href: string }>;
17
+ images?: Array<{ loc: string }>;
18
+ }
19
+
20
+ /** Protocol limits: 50,000 URLs and 50 MB (uncompressed) per file. */
21
+ export const SITEMAP_MAX_URLS = 50_000;
22
+ export const SITEMAP_MAX_BYTES = 50 * 1024 * 1024;
23
+
24
+ const x = (s: string) => escapeXml(stripInvalidXml(s));
25
+
26
+ /** Dedupes by loc (last wins), drops non-absolute URLs, sorts for stable diffs. */
27
+ export function normalizeEntries(entries: SitemapEntry[]): { entries: SitemapEntry[]; dropped: string[] } {
28
+ const map = new Map<string, SitemapEntry>();
29
+ const dropped: string[] = [];
30
+ for (const e of entries) {
31
+ if (!e?.loc || !isAbsolute(e.loc)) {
32
+ dropped.push(String(e?.loc));
33
+ continue;
34
+ }
35
+ map.set(e.loc, e);
36
+ }
37
+ return { entries: [...map.values()].sort((a, b) => a.loc.localeCompare(b.loc)), dropped };
38
+ }
39
+
40
+ export function buildSitemap(entries: SitemapEntry[], options: { stylesheet?: string } = {}): string {
41
+ const { entries: list } = normalizeEntries(entries);
42
+ const hasAlt = list.some((e) => e.alternates?.length);
43
+ const hasImg = list.some((e) => e.images?.length);
44
+ const ns = ['xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"', hasAlt && 'xmlns:xhtml="http://www.w3.org/1999/xhtml"', hasImg && 'xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"'].filter(Boolean).join(' ');
45
+ const lines = ['<?xml version="1.0" encoding="UTF-8"?>'];
46
+ if (options.stylesheet) lines.push(`<?xml-stylesheet type="text/xsl" href="${x(options.stylesheet)}"?>`);
47
+ lines.push(`<urlset ${ns}>`);
48
+ for (const e of list) {
49
+ lines.push(' <url>', ` <loc>${x(e.loc)}</loc>`);
50
+ const lastmod = isoDate(e.lastmod);
51
+ if (lastmod) lines.push(` <lastmod>${lastmod}</lastmod>`);
52
+ if (e.changefreq) lines.push(` <changefreq>${e.changefreq}</changefreq>`);
53
+ if (typeof e.priority === 'number') lines.push(` <priority>${Math.min(1, Math.max(0, e.priority)).toFixed(1)}</priority>`);
54
+ for (const a of e.alternates ?? []) lines.push(` <xhtml:link rel="alternate" hreflang="${x(a.hreflang)}" href="${x(a.href)}"/>`);
55
+ for (const i of (e.images ?? []).slice(0, 1000)) if (isAbsolute(i.loc)) lines.push(` <image:image><image:loc>${x(i.loc)}</image:loc></image:image>`);
56
+ lines.push(' </url>');
57
+ }
58
+ lines.push('</urlset>', '');
59
+ return lines.join('\n');
60
+ }
61
+
62
+ export function buildSitemapIndex(sitemaps: Array<{ loc: string; lastmod?: string | Date }>): string {
63
+ const lines = ['<?xml version="1.0" encoding="UTF-8"?>', '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'];
64
+ for (const s of sitemaps) {
65
+ lines.push(' <sitemap>', ` <loc>${x(s.loc)}</loc>`);
66
+ const lastmod = isoDate(s.lastmod);
67
+ if (lastmod) lines.push(` <lastmod>${lastmod}</lastmod>`);
68
+ lines.push(' </sitemap>');
69
+ }
70
+ lines.push('</sitemapindex>', '');
71
+ return lines.join('\n');
72
+ }
73
+
74
+ /** Splits entries into sitemap files that respect the URL and size limits. */
75
+ export function chunkEntries(entries: SitemapEntry[], maxUrls = 45_000): SitemapEntry[][] {
76
+ const { entries: list } = normalizeEntries(entries);
77
+ const chunks: SitemapEntry[][] = [];
78
+ let cur: SitemapEntry[] = [];
79
+ let bytes = 200;
80
+ for (const e of list) {
81
+ const size = 120 + e.loc.length * 1.2 + (e.alternates?.length ?? 0) * 120 + (e.images?.length ?? 0) * 100;
82
+ if (cur.length >= maxUrls || bytes + size > SITEMAP_MAX_BYTES * 0.9) {
83
+ chunks.push(cur);
84
+ cur = [];
85
+ bytes = 200;
86
+ }
87
+ cur.push(e);
88
+ bytes += size;
89
+ }
90
+ if (cur.length || !chunks.length) chunks.push(cur);
91
+ return chunks;
92
+ }
93
+
94
+ /**
95
+ * An Astro endpoint for a sitemap of on-demand pages (e.g. CMS records not built as files):
96
+ * // src/pages/sitemap-records.xml.ts
97
+ * export const GET = sitemapEndpoint(async () => (await getRecords()).map((r) => ({ loc: `https://example.com/r/${r.slug}`, lastmod: r.updated })));
98
+ * Then list it in the integration's `extraSitemaps`.
99
+ */
100
+ export function sitemapEndpoint(getEntries: () => SitemapEntry[] | Promise<SitemapEntry[]>, options: { maxAge?: number } = {}) {
101
+ return async () =>
102
+ new Response(buildSitemap(await getEntries()), {
103
+ headers: { 'Content-Type': 'application/xml; charset=utf-8', 'Cache-Control': `public, max-age=${options.maxAge ?? 3600}` },
104
+ });
105
+ }
@@ -0,0 +1,68 @@
1
+ /** URL helpers shared by the SEO modules. Pure; no Astro imports. */
2
+
3
+ export type TrailingSlash = 'always' | 'never' | 'ignore';
4
+
5
+ /** True for http(s) URLs with a host. */
6
+ export const isAbsolute = (value: string) => /^https?:\/\/[^/]/i.test(value);
7
+
8
+ /** Resolves `value` against `base` (site URL). Returns undefined when it can't be made absolute. */
9
+ export function absolute(value: string | URL | undefined, base?: string | URL): string | undefined {
10
+ if (!value) return undefined;
11
+ try {
12
+ return new URL(String(value), base ? String(base) : undefined).href;
13
+ } catch {
14
+ return undefined;
15
+ }
16
+ }
17
+
18
+ /** Applies the trailing-slash policy to a pathname (files like /feed.xml are left alone). */
19
+ export function applyTrailingSlash(pathname: string, policy: TrailingSlash): string {
20
+ if (policy === 'ignore' || pathname === '/') return pathname;
21
+ const last = pathname.slice(pathname.lastIndexOf('/') + 1);
22
+ if (last.includes('.')) return pathname; // a file
23
+ if (policy === 'always') return pathname.endsWith('/') ? pathname : `${pathname}/`;
24
+ return pathname.endsWith('/') ? pathname.slice(0, -1) || '/' : pathname;
25
+ }
26
+
27
+ /**
28
+ * The canonical form of a page URL: on the production origin (`site`), no hash, no query except
29
+ * `keepQuery` params (sorted), no index.html, and the site's trailing-slash policy.
30
+ */
31
+ export function canonicalize(
32
+ url: string | URL,
33
+ options: { site?: string | URL; trailingSlash?: TrailingSlash; keepQuery?: string[] } = {},
34
+ ): string {
35
+ const u = new URL(String(url), options.site ? String(options.site) : undefined);
36
+ if (options.site) {
37
+ const s = new URL(String(options.site));
38
+ u.protocol = s.protocol;
39
+ u.host = s.host;
40
+ }
41
+ u.hash = '';
42
+ const keep = new URLSearchParams();
43
+ for (const key of [...(options.keepQuery ?? [])].sort()) {
44
+ const v = u.searchParams.get(key);
45
+ if (v !== null && v !== '') keep.set(key, v);
46
+ }
47
+ u.search = keep.toString() ? `?${keep}` : '';
48
+ u.pathname = applyTrailingSlash(u.pathname.replace(/\/index\.html?$/, '/').replace(/\/{2,}/g, '/'), options.trailingSlash ?? 'ignore');
49
+ return u.href;
50
+ }
51
+
52
+ /** Escapes text for HTML/XML attribute values and text nodes. */
53
+ export function escapeXml(value: string): string {
54
+ return value.replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]!);
55
+ }
56
+
57
+ /** Removes characters that are invalid in XML 1.0 (control characters from pasted CMS text). */
58
+ export function stripInvalidXml(value: string): string {
59
+ // eslint-disable-next-line no-control-regex
60
+ return value.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F￾￿]/g, '');
61
+ }
62
+
63
+ /** ISO 8601 date-time (with Z) or undefined when the date is invalid. */
64
+ export function isoDate(value: string | Date | undefined): string | undefined {
65
+ if (!value) return undefined;
66
+ const d = value instanceof Date ? value : new Date(value);
67
+ return Number.isFinite(d.getTime()) ? d.toISOString() : undefined;
68
+ }
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Optional page baseline. Import after tokens.css if the site has no reset of its own.
3
+ * Lives in the lowest layer, so anything else overrides it.
4
+ */
5
+ /* Same order as tokens.css: whichever stylesheet loads first fixes the layer order. */
6
+ @layer sinn.reset, sinn.tokens, sinn.primitives, sinn.data, sinn.motion, sinn.blocks, sinn.overrides;
7
+
8
+ @layer sinn.reset {
9
+ *, *::before, *::after { box-sizing: border-box; }
10
+
11
+ html {
12
+ -webkit-text-size-adjust: 100%;
13
+ text-size-adjust: 100%;
14
+ }
15
+
16
+ body {
17
+ margin: 0;
18
+ background-color: var(--sinn-color-surface);
19
+ color: var(--sinn-color-text);
20
+ font-family: var(--sinn-font-sans);
21
+ font-size: var(--sinn-text-m);
22
+ line-height: var(--sinn-leading-normal);
23
+ -webkit-font-smoothing: antialiased;
24
+ }
25
+
26
+ img, picture, svg, video { display: block; max-inline-size: 100%; }
27
+
28
+ /* One focus treatment for everything, including plain links and third-party embeds.
29
+ Components refine it; this guarantees nothing focusable is ever left without a ring. */
30
+ :focus-visible {
31
+ outline: var(--sinn-focus-width) solid var(--sinn-color-focus);
32
+ outline-offset: var(--sinn-focus-offset);
33
+ }
34
+ /* Programmatic focus targets (skip-link targets, dialogs) don't need a ring on mouse focus. */
35
+ [tabindex='-1']:focus:not(:focus-visible) { outline: none; }
36
+
37
+ html { scroll-behavior: smooth; }
38
+ svg { display: inline-block; }
39
+ input, button, textarea, select { font: inherit; }
40
+ }
41
+
42
+ /*
43
+ * Reduced motion for content the library doesn't own (site CSS, embeds, plugins): near-instant
44
+ * animations and transitions. Unlayered !important would beat everything; inside the reset layer
45
+ * it still overrides normal declarations everywhere. Mark genuinely necessary motion with
46
+ * data-motion-essential (progress indicators) to opt out.
47
+ */
48
+ @layer sinn.reset {
49
+ @media (prefers-reduced-motion: reduce) {
50
+ :root:not([data-motion='full']) *:not([data-motion-essential], [data-motion-essential] *),
51
+ :root:not([data-motion='full']) *:not([data-motion-essential], [data-motion-essential] *)::before,
52
+ :root:not([data-motion='full']) *:not([data-motion-essential], [data-motion-essential] *)::after {
53
+ animation-duration: 1ms !important;
54
+ animation-iteration-count: 1 !important;
55
+ transition-duration: 1ms !important;
56
+ scroll-behavior: auto !important;
57
+ }
58
+ }
59
+ :root[data-motion='reduce'] *:not([data-motion-essential], [data-motion-essential] *),
60
+ :root[data-motion='reduce'] *:not([data-motion-essential], [data-motion-essential] *)::before,
61
+ :root[data-motion='reduce'] *:not([data-motion-essential], [data-motion-essential] *)::after {
62
+ animation-duration: 1ms !important;
63
+ animation-iteration-count: 1 !important;
64
+ transition-duration: 1ms !important;
65
+ scroll-behavior: auto !important;
66
+ }
67
+ @media (prefers-reduced-motion: reduce) {
68
+ :root:not([data-motion='full']) { scroll-behavior: auto !important; }
69
+ }
70
+ :root[data-motion='reduce'] { scroll-behavior: auto !important; }
71
+ }