@getvitops/astro 8.2.0-alpha.0 → 8.3.0-alpha.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 (61) hide show
  1. package/CHANGELOG.md +584 -26
  2. package/dist/config-adapters-CbTywgEY.mjs +71 -0
  3. package/dist/config-adapters-CbTywgEY.mjs.map +1 -0
  4. package/dist/exports/tracking.d.mts +1 -1
  5. package/dist/exports/tracking.mjs +1 -1
  6. package/dist/index.d.mts +83 -43
  7. package/dist/index.d.mts.map +1 -1
  8. package/dist/index.mjs +351 -60
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/middleware.d.mts +0 -2
  11. package/dist/middleware.d.mts.map +1 -1
  12. package/dist/middleware.mjs +1 -2
  13. package/dist/routes/conversion.d.mts +71 -15
  14. package/dist/routes/conversion.d.mts.map +1 -1
  15. package/dist/routes/conversion.mjs +79 -68
  16. package/dist/routes/conversion.mjs.map +1 -1
  17. package/dist/{tracking-M2PqlMpw.mjs → tracking-Cb3A0BrC.mjs} +2 -3
  18. package/dist/tracking-Cb3A0BrC.mjs.map +1 -0
  19. package/dist/{tracking-BNKKBqOe.d.mts → tracking-D2xOzjFD.d.mts} +5 -25
  20. package/dist/tracking-D2xOzjFD.d.mts.map +1 -0
  21. package/package.json +18 -6
  22. package/src/ads.ts +15 -22
  23. package/src/components/CookieConsent.astro +2 -1
  24. package/src/components/Entries.astro +58 -0
  25. package/src/components/Head.astro +6 -37
  26. package/src/components/ReviewCardBody.astro +16 -2
  27. package/src/components/SiteFooter.astro +79 -0
  28. package/src/components/SiteNav.astro +163 -0
  29. package/src/components/SiteNavList.astro +73 -0
  30. package/src/components/sitenav.ts +260 -0
  31. package/src/inline-scripts.ts +53 -0
  32. package/src/json-ld.ts +19 -0
  33. package/src/schemas/Article.astro +2 -1
  34. package/src/schemas/BookActions.astro +2 -1
  35. package/src/schemas/Breadcrumb.astro +2 -1
  36. package/src/schemas/Carousel.astro +2 -1
  37. package/src/schemas/CourseList.astro +2 -1
  38. package/src/schemas/Dataset.astro +2 -1
  39. package/src/schemas/DiscussionForum.astro +2 -1
  40. package/src/schemas/EducationQA.astro +2 -1
  41. package/src/schemas/EmployerAggregateRating.astro +2 -1
  42. package/src/schemas/Event.astro +2 -1
  43. package/src/schemas/FAQ.astro +2 -1
  44. package/src/schemas/FactCheck.astro +2 -1
  45. package/src/schemas/ImageMetadata.astro +2 -1
  46. package/src/schemas/JobPosting.astro +2 -1
  47. package/src/schemas/LocalBusiness.astro +2 -1
  48. package/src/schemas/MathSolver.astro +2 -1
  49. package/src/schemas/MovieCarousel.astro +2 -1
  50. package/src/schemas/Organization.astro +2 -1
  51. package/src/schemas/Product.astro +2 -1
  52. package/src/schemas/ProfilePage.astro +2 -1
  53. package/src/schemas/QAPage.astro +2 -1
  54. package/src/schemas/Recipe.astro +2 -1
  55. package/src/schemas/Review.astro +2 -1
  56. package/src/schemas/SoftwareApp.astro +2 -1
  57. package/src/seo.ts +6 -5
  58. package/src/tracking.ts +5 -9
  59. package/virtual.d.ts +17 -0
  60. package/dist/tracking-BNKKBqOe.d.mts.map +0 -1
  61. package/dist/tracking-M2PqlMpw.mjs.map +0 -1
package/src/seo.ts CHANGED
@@ -20,11 +20,12 @@ export type SeoOgType = 'website' | 'article' | 'profile';
20
20
  * Site-level SEO defaults, passed to `vitops({ seo })` and baked into the
21
21
  * `virtual:getvitops/head` module. Per-page `<Seo />` props override these.
22
22
  *
23
- * The vocabulary mirrors the site-config schema's `seo` block
24
- * (`@getvitops/generator`, `src/config.ts`) so a `Config` → these adapter would
25
- * be a flat field map — but it is not imported from there. This is the
26
- * integration's own option surface, and it must stay JSON-serialisable: it is
27
- * `JSON.stringify`d into the virtual module, so no functions, no `URL`s, no dates.
23
+ * `site.seo` in the site config is the source (`@getvitops/config`'s `SeoSchema`);
24
+ * `resolveSeoDefaults()` turns it into this shape for a build locale, and `vitops({ seo })` is merged
25
+ * over the result as an override. This interface is therefore the *resolved* shape — plain strings,
26
+ * `Localizable` already picked — and must stay JSON-serialisable: it is `JSON.stringify`d into the
27
+ * virtual module, so no functions, no `URL`s, no dates. `seo-defaults.test.ts` fails when a
28
+ * `site.seo` field is added to the schema and not read here (ADR-0002).
28
29
  */
29
30
  export interface GetvitopsSeoOptions {
30
31
  /** `og:site_name`, and the `<title>` when a page passes none. */
package/src/tracking.ts CHANGED
@@ -12,17 +12,13 @@
12
12
  * under `analytics`, and that is the consumer's call to make, not ours to guess.
13
13
  */
14
14
 
15
+ import type { TrackingConfig } from '@getvitops/config';
16
+
15
17
  /** Which consent category the attribution cookie waits on. */
16
- export type TrackingCategory = 'marketing' | 'analytics';
18
+ export type TrackingCategory = NonNullable<TrackingConfig['category']>;
17
19
 
18
- export interface GetvitopsTrackingOptions {
19
- /** Capture ad click IDs and UTMs into `_ac`. */
20
- enabled?: boolean;
21
- /** Default `marketing`. */
22
- category?: TrackingCategory;
23
- /** Informational; capture recognises every known click-ID parameter regardless. */
24
- platforms?: string[];
25
- }
20
+ /** The `site.tracking` block — the schema's own type from `@getvitops/config`, not a copy. */
21
+ export type GetvitopsTrackingOptions = TrackingConfig;
26
22
 
27
23
  /** The cookie the capture script writes. Mirrors `TRACKING_COOKIE` in utils. */
28
24
  export const TRACKING_COOKIE = '_ac';
package/virtual.d.ts CHANGED
@@ -63,11 +63,28 @@ declare module 'virtual:getvitops/head' {
63
63
  // site config is already parsed, and because a pixel is a `marketing` demand
64
64
  // the banner must have a row for.
65
65
  ads: { enabled: boolean; properties: Record<string, unknown> } | null;
66
+ turnstileSiteKey: string | null;
66
67
  }
67
68
  const data: HeadData;
68
69
  export default data;
69
70
  }
70
71
 
72
+ /**
73
+ * The committed `.vitops/reviews.json` cache as a build-time import — for components that
74
+ * render in a Worker and so cannot read the file (the EmDash `vitops.reviews` block). Always
75
+ * defined: with no cache file it is `{ version: 1, locations: {} }`.
76
+ */
77
+ declare module 'virtual:getvitops/reviews' {
78
+ // Structurally `ReviewCache` from `@getvitops/utils/reviews` (an ambient module in a
79
+ // shipped .d.ts cannot import from src). Kept loose on purpose: callers re-type it on the
80
+ // way into `selectReviews`, which is where the real contract is.
81
+ const cache: {
82
+ version: 1;
83
+ locations: Record<string, { reviews: Record<string, unknown>[] } & Record<string, unknown>>;
84
+ };
85
+ export default cache;
86
+ }
87
+
71
88
  /** Types for the virtual module the getvitops() integration provides to <Icon />. */
72
89
  declare module 'virtual:getvitops/icons' {
73
90
  // Keep these keys in step with `IconsData` in src/integration.ts, for the same
@@ -1 +0,0 @@
1
- {"version":3,"file":"tracking-BNKKBqOe.d.mts","names":[],"sources":["../src/tracking.ts"],"mappings":";;;;;;;;;;;;;;;KAeY;UAEK;;EAEf;;EAEA,WAAW;;EAEX;;;cAIW;;;;;;;;;;;;cAaA;UAEI;EACf;EACA,UAAU;;EAEV;;EAEA;;UAGe;;EAEf;;EAEA;;;;;;;;;;;iBAYc,gBACd,MAAM,sCACN,MAAK,yBACJ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tracking-M2PqlMpw.mjs","names":[],"sources":["../src/tracking.ts"],"sourcesContent":["/**\n * The `<Tracking />` resolution layer — tracking config in, what to emit out.\n *\n * Separate from `Tracking.astro` for the same reason `analytics.ts` is separate\n * from `Analytics.astro`: everything decidable is a pure function asserted in\n * `tracking.test.ts`, and the component only renders what this returns.\n *\n * The one decision here is **which consent category the `_ac` cookie waits on**,\n * and it is stated rather than inferred. `_ac` is a 90-day identifier tying a\n * visitor to the ad that brought them, so `marketing` is the default — but a site\n * using click IDs purely for its own campaign reporting may reasonably file it\n * under `analytics`, and that is the consumer's call to make, not ours to guess.\n */\n\n/** Which consent category the attribution cookie waits on. */\nexport type TrackingCategory = 'marketing' | 'analytics';\n\nexport interface GetvitopsTrackingOptions {\n /** Capture ad click IDs and UTMs into `_ac`. */\n enabled?: boolean;\n /** Default `marketing`. */\n category?: TrackingCategory;\n /** Informational; capture recognises every known click-ID parameter regardless. */\n platforms?: string[];\n}\n\n/** The cookie the capture script writes. Mirrors `TRACKING_COOKIE` in utils. */\nexport const TRACKING_COOKIE = '_ac';\n\n/**\n * Where the capture script sends its `tel:`/`mailto:` conversion beacons.\n *\n * The route itself is the consumer's to write (`createConversionRoute()` in\n * `@getvitops/astro/routes`), so this is the one place the two halves agree on\n * a path. It was a bare literal inside the inlined script: a consumer who named\n * the file anything else got a silent 404 on every beacon and lost conversions\n * with no error anywhere to explain it. Exported so a consumer can assert\n * against it, mirrored in `scripts/tracking.ts` because that file is inlined\n * into the document and cannot import, and pinned by `tracking.test.ts`.\n */\nexport const TRACKING_ENDPOINT = '/api/track';\n\nexport interface ResolvedTracking {\n enabled: boolean;\n category: TrackingCategory;\n /** Cookie names to clear on revoke — rides on `data-consent-cookies`. */\n cookies: string[];\n /** Configuration problems, as prose. The integration logs these. */\n warnings: string[];\n}\n\nexport interface ResolveTrackingContext {\n /** Is the consent gate enabled on this site (`vitops({ consent })`)? */\n consent?: boolean;\n /** Categories the banner offers, so we can catch a demand with no row. */\n consentCategories?: readonly string[];\n}\n\n/**\n * Resolve the tracking config into what the component emits.\n *\n * Two warnings, both about the same failure — a persistent identifier written\n * with no way for the visitor to decline, or a permission asked for with no way\n * to answer. Returned as data rather than logged here so the check is a test\n * rather than a line someone might scroll past, exactly as `resolveAnalytics`\n * does.\n */\nexport function resolveTracking(\n opts: GetvitopsTrackingOptions | undefined,\n ctx: ResolveTrackingContext = {},\n): ResolvedTracking {\n const warnings: string[] = [];\n const category: TrackingCategory = opts?.category ?? 'marketing';\n const enabled = opts?.enabled === true;\n\n if (!enabled) return { enabled: false, category, cookies: [], warnings };\n\n if (!ctx.consent) {\n warnings.push(\n `tracking is on, so this site writes the \\`${TRACKING_COOKIE}\\` cookie — a 90-day ` +\n 'identifier tying a visitor to the ad that brought them — and `consent` is off, so it ' +\n 'is written for every visitor with no way to decline. Set `consent: true`.',\n );\n } else if (ctx.consentCategories && !ctx.consentCategories.includes(category)) {\n // The banner would be raised for a category it renders no row for: the\n // visitor is asked a question the form does not show them.\n warnings.push(\n `tracking demands the \\`${category}\\` consent category, but the banner offers ` +\n `${ctx.consentCategories.join(', ') || 'nothing'}. Add \\`${category}\\` to ` +\n '`consent.categories`, or the visitor is asked about something the banner never names.',\n );\n }\n\n return { enabled, category, cookies: [TRACKING_COOKIE], warnings };\n}\n"],"mappings":";;AA2BA,MAAa,kBAAkB;;;;;;;;;;;;AAa/B,MAAa,oBAAoB;;;;;;;;;;AA2BjC,SAAgB,gBACd,MACA,MAA8B,CAAC,GACb;CAClB,MAAM,WAAqB,CAAC;CAC5B,MAAM,WAA6B,MAAM,YAAY;CACrD,MAAM,UAAU,MAAM,YAAY;CAElC,IAAI,CAAC,SAAS,OAAO;EAAE,SAAS;EAAO;EAAU,SAAS,CAAC;EAAG;CAAS;CAEvE,IAAI,CAAC,IAAI,SACP,SAAS,KACP,mDAA6D,wLAG/D;MACK,IAAI,IAAI,qBAAqB,CAAC,IAAI,kBAAkB,SAAS,QAAQ,GAG1E,SAAS,KACP,0BAA0B,SAAS,6CAC9B,IAAI,kBAAkB,KAAK,IAAI,KAAK,UAAU,UAAU,SAAS,8FAExE;CAGF,OAAO;EAAE;EAAS;EAAU,SAAS,MAAgB;EAAG;CAAS;AACnE"}