sanity-plugin-seofields 1.2.5 → 1.2.7

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 (50) hide show
  1. package/README.md +465 -0
  2. package/dist/index.cjs +2604 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +422 -0
  5. package/dist/index.d.ts +339 -492
  6. package/dist/index.js +1284 -2013
  7. package/dist/index.js.map +1 -1
  8. package/dist/next.cjs +182 -0
  9. package/dist/next.cjs.map +1 -0
  10. package/dist/next.d.cts +241 -0
  11. package/dist/next.d.ts +202 -295
  12. package/dist/next.js +110 -70
  13. package/dist/next.js.map +1 -1
  14. package/dist/types-B91ena4g.d.cts +89 -0
  15. package/dist/types-B91ena4g.d.ts +89 -0
  16. package/package.json +46 -20
  17. package/dist/index.d.mts +0 -575
  18. package/dist/index.mjs +0 -3292
  19. package/dist/index.mjs.map +0 -1
  20. package/dist/next.d.mts +0 -334
  21. package/dist/next.mjs +0 -102
  22. package/dist/next.mjs.map +0 -1
  23. package/sanity.json +0 -8
  24. package/src/components/SeoHealthDashboard.tsx +0 -1568
  25. package/src/components/SeoHealthPane.tsx +0 -81
  26. package/src/components/SeoHealthTool.tsx +0 -11
  27. package/src/components/SeoPreview.tsx +0 -178
  28. package/src/components/meta/MetaDescription.tsx +0 -39
  29. package/src/components/meta/MetaTitle.tsx +0 -44
  30. package/src/components/openGraph/OgDescription.tsx +0 -46
  31. package/src/components/openGraph/OgTitle.tsx +0 -45
  32. package/src/components/twitter/twitterDescription.tsx +0 -45
  33. package/src/components/twitter/twitterTitle.tsx +0 -45
  34. package/src/helpers/SeoMetaTags.tsx +0 -154
  35. package/src/helpers/seoMeta.ts +0 -283
  36. package/src/index.ts +0 -26
  37. package/src/next.ts +0 -12
  38. package/src/plugin.ts +0 -344
  39. package/src/schemas/index.ts +0 -121
  40. package/src/schemas/types/index.ts +0 -20
  41. package/src/schemas/types/metaAttribute/index.ts +0 -60
  42. package/src/schemas/types/metaTag/index.ts +0 -17
  43. package/src/schemas/types/openGraph/index.ts +0 -114
  44. package/src/schemas/types/robots/index.ts +0 -26
  45. package/src/schemas/types/twitter/index.ts +0 -108
  46. package/src/types.ts +0 -108
  47. package/src/utils/fieldsUtils.ts +0 -160
  48. package/src/utils/seoUtils.ts +0 -423
  49. package/src/utils/utils.ts +0 -9
  50. package/v2-incompatible.js +0 -11
package/dist/next.cjs ADDED
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
35
+ // If the importer is in node compatibility mode or this is not an ESM
36
+ // file that has been converted to a CommonJS file using a Babel-
37
+ // compatible transform (i.e. "__esModule" has not been set), then set
38
+ // "default" to the CommonJS "module.exports" for node compatibility.
39
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
40
+ mod
41
+ ));
42
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
+
44
+ // src/next.ts
45
+ var next_exports = {};
46
+ __export(next_exports, {
47
+ SeoMetaTags: () => SeoMetaTags,
48
+ buildSeoMeta: () => buildSeoMeta,
49
+ sanitizeOGType: () => sanitizeOGType,
50
+ sanitizeTwitterCard: () => sanitizeTwitterCard
51
+ });
52
+ module.exports = __toCommonJS(next_exports);
53
+
54
+ // src/helpers/seoMeta.ts
55
+ var VALID_OG_TYPES = [
56
+ "website",
57
+ "article",
58
+ "profile",
59
+ "book",
60
+ "music",
61
+ "video",
62
+ "product"
63
+ ];
64
+ function sanitizeOGType(value) {
65
+ if (value && VALID_OG_TYPES.includes(value)) {
66
+ return value;
67
+ }
68
+ return "website";
69
+ }
70
+ var VALID_TWITTER_CARDS = ["summary", "summary_large_image", "app", "player"];
71
+ function sanitizeTwitterCard(value) {
72
+ if (value && VALID_TWITTER_CARDS.includes(value)) {
73
+ return value;
74
+ }
75
+ return "summary_large_image";
76
+ }
77
+ function buildSeoMeta(options) {
78
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
79
+ const { seo, baseUrl = "", path = "", defaults = {}, imageUrlResolver } = options;
80
+ const normalizedBase = baseUrl.replace(/\/+$/, "");
81
+ const normalizedPath = path.replace(/^\/+/, "");
82
+ const fullUrl = [normalizedBase, normalizedPath].filter(Boolean).join("/");
83
+ let ogImageURL = defaults.ogImage || "";
84
+ if (((_a = seo == null ? void 0 : seo.openGraph) == null ? void 0 : _a.imageType) === "url" && seo.openGraph.imageUrl) {
85
+ ogImageURL = seo.openGraph.imageUrl;
86
+ } else if (((_b = seo == null ? void 0 : seo.openGraph) == null ? void 0 : _b.image) && imageUrlResolver) {
87
+ ogImageURL = imageUrlResolver(seo.openGraph.image) || ogImageURL;
88
+ }
89
+ let twitterImageURL = ogImageURL;
90
+ if (((_c = seo == null ? void 0 : seo.twitter) == null ? void 0 : _c.imageType) === "url" && seo.twitter.imageUrl) {
91
+ twitterImageURL = seo.twitter.imageUrl;
92
+ } else if (((_d = seo == null ? void 0 : seo.twitter) == null ? void 0 : _d.image) && imageUrlResolver) {
93
+ twitterImageURL = imageUrlResolver(seo.twitter.image) || twitterImageURL;
94
+ }
95
+ const other = {};
96
+ if (Array.isArray(seo == null ? void 0 : seo.metaAttributes)) {
97
+ for (const attr of seo.metaAttributes) {
98
+ if (attr.key && attr.value) {
99
+ other[attr.key] = attr.value;
100
+ }
101
+ }
102
+ }
103
+ const ogUrl = ((_e = seo == null ? void 0 : seo.openGraph) == null ? void 0 : _e.url) || fullUrl;
104
+ return __spreadValues({
105
+ title: (_g = (_f = seo == null ? void 0 : seo.title) != null ? _f : defaults.title) != null ? _g : null,
106
+ description: (_i = (_h = seo == null ? void 0 : seo.description) != null ? _h : defaults.description) != null ? _i : null,
107
+ keywords: ((_j = seo == null ? void 0 : seo.keywords) == null ? void 0 : _j.length) ? seo.keywords : void 0,
108
+ robots: {
109
+ index: !((_k = seo == null ? void 0 : seo.robots) == null ? void 0 : _k.noIndex),
110
+ follow: !((_l = seo == null ? void 0 : seo.robots) == null ? void 0 : _l.noFollow),
111
+ googleBot: {
112
+ index: !((_m = seo == null ? void 0 : seo.robots) == null ? void 0 : _m.noIndex),
113
+ follow: !((_n = seo == null ? void 0 : seo.robots) == null ? void 0 : _n.noFollow)
114
+ }
115
+ },
116
+ openGraph: {
117
+ type: sanitizeOGType((_p = (_o = seo == null ? void 0 : seo.openGraph) == null ? void 0 : _o.type) != null ? _p : void 0),
118
+ url: ogUrl || void 0,
119
+ title: (_r = (_q = seo == null ? void 0 : seo.openGraph) == null ? void 0 : _q.title) != null ? _r : defaults.title,
120
+ description: (_t = (_s = seo == null ? void 0 : seo.openGraph) == null ? void 0 : _s.description) != null ? _t : defaults.description,
121
+ siteName: (_v = (_u = seo == null ? void 0 : seo.openGraph) == null ? void 0 : _u.siteName) != null ? _v : defaults.siteName,
122
+ images: ogImageURL ? [{ url: ogImageURL }] : []
123
+ },
124
+ twitter: {
125
+ card: sanitizeTwitterCard((_x = (_w = seo == null ? void 0 : seo.twitter) == null ? void 0 : _w.card) != null ? _x : void 0),
126
+ site: (_z = (_y = seo == null ? void 0 : seo.twitter) == null ? void 0 : _y.site) != null ? _z : defaults.twitterSite,
127
+ creator: (_B = (_A = seo == null ? void 0 : seo.twitter) == null ? void 0 : _A.creator) != null ? _B : defaults.twitterCreator,
128
+ title: (_D = (_C = seo == null ? void 0 : seo.twitter) == null ? void 0 : _C.title) != null ? _D : defaults.title,
129
+ description: (_F = (_E = seo == null ? void 0 : seo.twitter) == null ? void 0 : _E.description) != null ? _F : defaults.description,
130
+ images: twitterImageURL ? [twitterImageURL] : []
131
+ },
132
+ alternates: {
133
+ canonical: fullUrl || void 0
134
+ }
135
+ }, Object.keys(other).length > 0 ? { other } : {});
136
+ }
137
+
138
+ // src/helpers/SeoMetaTags.tsx
139
+ var import_react = __toESM(require("react"), 1);
140
+ var import_jsx_runtime = require("react/jsx-runtime");
141
+ function SeoMetaTags({ data, baseUrl, path, defaults, imageUrlResolver }) {
142
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
143
+ const meta = buildSeoMeta({ seo: data, baseUrl, path, defaults, imageUrlResolver });
144
+ const robotsContent = [
145
+ ((_a = meta.robots) == null ? void 0 : _a.index) === false ? "noindex" : "index",
146
+ ((_b = meta.robots) == null ? void 0 : _b.follow) === false ? "nofollow" : "follow"
147
+ ].join(", ");
148
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
149
+ meta.title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { children: meta.title }),
150
+ meta.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { name: "description", content: meta.description }),
151
+ ((_c = meta.keywords) == null ? void 0 : _c.length) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { name: "keywords", content: meta.keywords.join(", ") }) : null,
152
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { name: "robots", content: robotsContent }),
153
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { name: "googlebot", content: robotsContent }),
154
+ ((_d = meta.openGraph) == null ? void 0 : _d.type) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { property: "og:type", content: meta.openGraph.type }),
155
+ ((_e = meta.openGraph) == null ? void 0 : _e.url) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { property: "og:url", content: meta.openGraph.url }),
156
+ ((_f = meta.openGraph) == null ? void 0 : _f.title) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { property: "og:title", content: meta.openGraph.title }),
157
+ ((_g = meta.openGraph) == null ? void 0 : _g.description) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { property: "og:description", content: meta.openGraph.description }),
158
+ ((_h = meta.openGraph) == null ? void 0 : _h.siteName) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { property: "og:site_name", content: meta.openGraph.siteName }),
159
+ (_j = (_i = meta.openGraph) == null ? void 0 : _i.images) == null ? void 0 : _j.map((img, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.default.Fragment, { children: [
160
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { property: "og:image", content: img.url }),
161
+ img.width && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { property: "og:image:width", content: String(img.width) }),
162
+ img.height && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { property: "og:image:height", content: String(img.height) }),
163
+ img.alt && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { property: "og:image:alt", content: img.alt })
164
+ ] }, `og-img-${i}`)),
165
+ ((_k = meta.twitter) == null ? void 0 : _k.card) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { name: "twitter:card", content: meta.twitter.card }),
166
+ ((_l = meta.twitter) == null ? void 0 : _l.site) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { name: "twitter:site", content: meta.twitter.site }),
167
+ ((_m = meta.twitter) == null ? void 0 : _m.creator) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { name: "twitter:creator", content: meta.twitter.creator }),
168
+ ((_n = meta.twitter) == null ? void 0 : _n.title) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { name: "twitter:title", content: meta.twitter.title }),
169
+ ((_o = meta.twitter) == null ? void 0 : _o.description) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { name: "twitter:description", content: meta.twitter.description }),
170
+ (_q = (_p = meta.twitter) == null ? void 0 : _p.images) == null ? void 0 : _q.map((url, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { name: "twitter:image", content: url }, `tw-img-${i}`)),
171
+ meta.other && Object.entries(meta.other).map(([name, content]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("meta", { name, content }, `custom-${name}`)),
172
+ ((_r = meta.alternates) == null ? void 0 : _r.canonical) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("link", { rel: "canonical", href: meta.alternates.canonical })
173
+ ] });
174
+ }
175
+ // Annotate the CommonJS export names for ESM import in node:
176
+ 0 && (module.exports = {
177
+ SeoMetaTags,
178
+ buildSeoMeta,
179
+ sanitizeOGType,
180
+ sanitizeTwitterCard
181
+ });
182
+ //# sourceMappingURL=next.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/next.ts","../src/helpers/seoMeta.ts","../src/helpers/SeoMetaTags.tsx"],"sourcesContent":["/**\n * Next.js App Router helpers — safe to import in Server Components.\n *\n * @example\n * import { buildSeoMeta, SeoMetaTags } from 'sanity-plugin-seofields/next'\n */\nexport type {\n BuildSeoMetaOptions,\n SeoFieldsInput,\n SeoMetadata,\n SeoMetaDefaults,\n} from './helpers/seoMeta'\nexport {buildSeoMeta, sanitizeOGType, sanitizeTwitterCard} from './helpers/seoMeta'\nexport type {SeoMetaTagsProps} from './helpers/SeoMetaTags'\nexport {SeoMetaTags} from './helpers/SeoMetaTags'\n","/**\n * Headless CMS integration helpers for sanity-plugin-seofields\n *\n * Provides framework-agnostic SEO metadata utilities for use with:\n * - Next.js App Router → buildSeoMeta() inside generateMetadata()\n * - Next.js Pages Router → <SeoMetaTags> inside Next.js <Head>\n * - Nuxt / Remix / any SSR → <SeoMetaTags> inside your <head> slot\n */\n\nimport type {SanityImage, SanityImageWithAlt, SeoFields} from '../types'\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/** Structured metadata returned by buildSeoMeta(). Compatible with Next.js Metadata (App Router). */\nexport interface SeoMetadata {\n title?: string | null\n description?: string | null\n keywords?: string[]\n robots?: {\n index?: boolean\n follow?: boolean\n googleBot?: {\n index?: boolean\n follow?: boolean\n }\n }\n openGraph?: {\n type?: string\n url?: string\n title?: string\n description?: string\n siteName?: string\n images?: Array<{url: string; width?: number; height?: number; alt?: string}>\n }\n twitter?: {\n card?: string\n site?: string\n creator?: string\n title?: string\n description?: string\n images?: string[]\n }\n alternates?: {\n canonical?: string\n }\n /** Any custom meta attributes from seo.metaAttributes */\n other?: Record<string, string>\n}\n\n/** Default values used when SEO fields are missing. */\nexport interface SeoMetaDefaults {\n title?: string\n description?: string\n siteName?: string\n twitterSite?: string\n twitterCreator?: string\n /** Fallback image URL when no OG / Twitter image is set. */\n ogImage?: string\n}\n\n/**\n * Permissive image shape accepted by buildSeoMeta — compatible with both the\n * plugin's SanityImage and Sanity's code-generated image type (where `asset`\n * and `alt` are optional).\n */\ninterface SeoImageInput {\n _type?: string\n asset?: {_ref: string; _type: string; _weak?: boolean; [key: string]: unknown}\n hotspot?: unknown\n crop?: unknown\n alt?: string\n}\n\n/**\n * Input-compatible variant of SeoFields. Structurally matches Sanity's\n * code-generated types (where `asset`, `alt`, `key`, and `type` are all\n * optional), so you can pass `data.seo` from a sanityFetch result directly\n * without any `as any` or manual casting.\n */\nexport interface SeoFieldsInput {\n _type?: string\n robots?: {noIndex?: boolean | null; noFollow?: boolean | null} | null\n title?: string | null\n description?: string | null\n metaImage?: SeoImageInput | null\n metaAttributes?: Array<{_key?: string; key?: string; value?: string; type?: string}> | null\n keywords?: string[] | null\n canonicalUrl?: string | null\n openGraph?: {\n _type?: string\n url?: string | null\n title?: string | null\n description?: string | null\n siteName?: string | null\n type?: string | null\n imageType?: string | null\n image?: SeoImageInput | null\n imageUrl?: string | null\n } | null\n twitter?: {\n _type?: string\n card?: string | null\n site?: string | null\n creator?: string | null\n title?: string | null\n description?: string | null\n imageType?: string | null\n image?: SeoImageInput | null\n imageUrl?: string | null\n } | null\n}\n\n/** Options accepted by buildSeoMeta(). */\nexport interface BuildSeoMetaOptions {\n /**\n * The raw SEO object from Sanity (_type excluded or included — both work).\n * Pass `null` or `undefined` to fall back entirely to `defaults`.\n *\n * Accepts both the strict plugin `SeoFields` type and Sanity's code-generated\n * type (which has all nested fields optional) without any `as any` cast.\n */\n seo?: SeoFieldsInput | null\n\n /**\n * The base URL of your site, e.g. \"https://example.com\".\n * Used for canonical URL and OpenGraph URL construction.\n */\n baseUrl?: string\n\n /**\n * The path for the current page, e.g. \"/about\".\n * Combined with baseUrl to produce the canonical + OG url.\n * Defaults to \"\".\n */\n path?: string\n\n /**\n * Default values used when the Sanity SEO fields are empty / missing.\n */\n defaults?: SeoMetaDefaults\n\n /**\n * Resolve a Sanity image asset to a plain URL string.\n *\n * @example (using @sanity/image-url)\n * imageUrlResolver: (img) => urlFor(img).width(1200).url()\n */\n imageUrlResolver?: (image: SanityImage | SanityImageWithAlt) => string | null | undefined\n}\n\n// ─── Internal helpers ─────────────────────────────────────────────────────────\n\nconst VALID_OG_TYPES = [\n 'website',\n 'article',\n 'profile',\n 'book',\n 'music',\n 'video',\n 'product',\n] as const\ntype OGType = (typeof VALID_OG_TYPES)[number]\n\n/**\n * Coerce an arbitrary string to a valid OpenGraph type.\n * Falls back to \"website\" when the value is invalid.\n */\nexport function sanitizeOGType(value?: string): OGType {\n if (value && (VALID_OG_TYPES as readonly string[]).includes(value)) {\n return value as OGType\n }\n return 'website'\n}\n\nconst VALID_TWITTER_CARDS = ['summary', 'summary_large_image', 'app', 'player'] as const\ntype TwitterCard = (typeof VALID_TWITTER_CARDS)[number]\n\n/**\n * Coerce an arbitrary string to a valid Twitter card type.\n * Falls back to \"summary_large_image\" when the value is invalid.\n */\nexport function sanitizeTwitterCard(value?: string): TwitterCard {\n if (value && (VALID_TWITTER_CARDS as readonly string[]).includes(value)) {\n return value as TwitterCard\n }\n return 'summary_large_image'\n}\n\n// ─── Core builder ─────────────────────────────────────────────────────────────\n\n/**\n * Convert a Sanity SEO object into a structured metadata object.\n *\n * The return value is structurally compatible with Next.js App Router's\n * `Metadata` type, so you can return it directly from `generateMetadata()`.\n *\n * @example Next.js App Router\n * ```ts\n * import { buildSeoMeta } from 'sanity-plugin-seofields'\n * import { urlFor } from '@/sanity/lib/image'\n *\n * export async function generateMetadata(): Promise<Metadata> {\n * const { seo } = await sanityFetch({ query: PAGE_SEO_QUERY })\n * return buildSeoMeta({\n * seo,\n * baseUrl: process.env.NEXT_PUBLIC_SITE_URL,\n * path: '/about',\n * defaults: { title: 'My Site', siteName: 'My Site' },\n * imageUrlResolver: (img) => urlFor(img).width(1200).url(),\n * })\n * }\n * ```\n */\nexport function buildSeoMeta(options: BuildSeoMetaOptions): SeoMetadata {\n const {seo, baseUrl = '', path = '', defaults = {}, imageUrlResolver} = options\n\n const normalizedBase = baseUrl.replace(/\\/+$/, '') // remove trailing /\n const normalizedPath = path.replace(/^\\/+/, '') // remove leading /\n\n const fullUrl = [normalizedBase, normalizedPath].filter(Boolean).join('/')\n\n // ── OG image resolution ──\n let ogImageURL: string = defaults.ogImage || ''\n if (seo?.openGraph?.imageType === 'url' && seo.openGraph.imageUrl) {\n ogImageURL = seo.openGraph.imageUrl\n } else if (seo?.openGraph?.image && imageUrlResolver) {\n ogImageURL = imageUrlResolver(seo.openGraph.image as SanityImage) || ogImageURL\n }\n\n // ── Twitter image resolution ──\n let twitterImageURL: string = ogImageURL // reuse OG image as fallback\n if (seo?.twitter?.imageType === 'url' && seo.twitter.imageUrl) {\n twitterImageURL = seo.twitter.imageUrl\n } else if (seo?.twitter?.image && imageUrlResolver) {\n twitterImageURL = imageUrlResolver(seo.twitter.image as SanityImage) || twitterImageURL\n }\n\n // ── Custom meta attributes → `other` map ──\n const other: Record<string, string> = {}\n if (Array.isArray(seo?.metaAttributes)) {\n for (const attr of seo!.metaAttributes!) {\n if (attr.key && attr.value) {\n other[attr.key] = attr.value\n }\n }\n }\n\n const ogUrl = seo?.openGraph?.url || fullUrl\n\n return {\n title: seo?.title ?? defaults.title ?? null,\n description: seo?.description ?? defaults.description ?? null,\n keywords: seo?.keywords?.length ? (seo.keywords as string[]) : undefined,\n robots: {\n index: !seo?.robots?.noIndex,\n follow: !seo?.robots?.noFollow,\n googleBot: {\n index: !seo?.robots?.noIndex,\n follow: !seo?.robots?.noFollow,\n },\n },\n openGraph: {\n type: sanitizeOGType(seo?.openGraph?.type ?? undefined),\n url: ogUrl || undefined,\n title: seo?.openGraph?.title ?? defaults.title,\n description: seo?.openGraph?.description ?? defaults.description,\n siteName: seo?.openGraph?.siteName ?? defaults.siteName,\n images: ogImageURL ? [{url: ogImageURL}] : [],\n },\n twitter: {\n card: sanitizeTwitterCard(seo?.twitter?.card ?? undefined),\n site: seo?.twitter?.site ?? defaults.twitterSite,\n creator: seo?.twitter?.creator ?? defaults.twitterCreator,\n title: seo?.twitter?.title ?? defaults.title,\n description: seo?.twitter?.description ?? defaults.description,\n images: twitterImageURL ? [twitterImageURL] : [],\n },\n alternates: {\n canonical: fullUrl || undefined,\n },\n ...(Object.keys(other).length > 0 ? {other} : {}),\n }\n}\n","/**\n * <SeoMetaTags> — Framework-agnostic React SEO meta tag renderer.\n *\n * Renders all SEO meta tags as plain React elements.\n * Place it inside your framework's <Head> component:\n *\n * @example Next.js Pages Router\n * ```tsx\n * import Head from 'next/head'\n * import { SeoMetaTags } from 'sanity-plugin-seofields'\n *\n * export default function Page({ seo }) {\n * return (\n * <>\n * <Head>\n * <SeoMetaTags\n * data={seo}\n * baseUrl=\"https://example.com\"\n * path=\"/about\"\n * defaults={{ title: 'My Site', siteName: 'My Site' }}\n * imageUrlResolver={(img) => urlFor(img).width(1200).url()}\n * />\n * </Head>\n * <main>...</main>\n * </>\n * )\n * }\n * ```\n *\n * @example Nuxt 3 / generic SSR (inside <Head> slot)\n * ```tsx\n * <Head>\n * <SeoMetaTags data={seo} baseUrl=\"https://example.com\" path=\"/\" />\n * </Head>\n * ```\n */\nimport React from 'react'\n\nimport type {SanityImage, SanityImageWithAlt, SeoFields} from '../types'\nimport {buildSeoMeta, type BuildSeoMetaOptions} from './seoMeta'\n\n// ─── Props ────────────────────────────────────────────────────────────────────\n\nexport interface SeoMetaTagsProps {\n /**\n * The raw SEO object from Sanity.\n * Pass `null` / `undefined` to render only the defaults.\n */\n data?: Partial<SeoFields> | null\n\n /**\n * Base URL of your site, e.g. \"https://example.com\".\n * Used for canonical link, og:url fallback.\n */\n baseUrl?: string\n\n /**\n * Current page path, e.g. \"/about\".\n * Defaults to \"\".\n */\n path?: string\n\n /**\n * Default values used when SEO fields are missing.\n */\n defaults?: BuildSeoMetaOptions['defaults']\n\n /**\n * Resolve a Sanity image asset reference to a full URL string.\n *\n * @example\n * imageUrlResolver={(img) => urlFor(img).width(1200).url()}\n */\n imageUrlResolver?: (image: SanityImage | SanityImageWithAlt) => string | null | undefined\n}\n\n// ─── Component ────────────────────────────────────────────────────────────────\n\n/**\n * Renders all SEO meta tags for a page as plain React elements.\n * Intended to be placed inside your framework's <Head> / <head> component.\n *\n * Renders:\n * - `<title>`\n * - `<meta name=\"description\">`\n * - `<meta name=\"keywords\">`\n * - `<meta name=\"robots\">`\n * - OpenGraph meta tags (`og:*`)\n * - Twitter Card meta tags (`twitter:*`)\n * - Any custom `seo.metaAttributes` as `<meta name=\"...\" content=\"...\">`\n */\nexport function SeoMetaTags({data, baseUrl, path, defaults, imageUrlResolver}: SeoMetaTagsProps) {\n const meta = buildSeoMeta({seo: data, baseUrl, path, defaults, imageUrlResolver})\n\n const robotsContent = [\n meta.robots?.index === false ? 'noindex' : 'index',\n meta.robots?.follow === false ? 'nofollow' : 'follow',\n ].join(', ')\n\n return (\n <>\n {/* ── Title ── */}\n {meta.title && <title>{meta.title}</title>}\n\n {/* ── Basic meta ── */}\n {meta.description && <meta name=\"description\" content={meta.description} />}\n {meta.keywords?.length ? <meta name=\"keywords\" content={meta.keywords.join(', ')} /> : null}\n <meta name=\"robots\" content={robotsContent} />\n <meta name=\"googlebot\" content={robotsContent} />\n\n {/* ── Open Graph ── */}\n {meta.openGraph?.type && <meta property=\"og:type\" content={meta.openGraph.type} />}\n {meta.openGraph?.url && <meta property=\"og:url\" content={meta.openGraph.url} />}\n {meta.openGraph?.title && <meta property=\"og:title\" content={meta.openGraph.title} />}\n {meta.openGraph?.description && (\n <meta property=\"og:description\" content={meta.openGraph.description} />\n )}\n {meta.openGraph?.siteName && (\n <meta property=\"og:site_name\" content={meta.openGraph.siteName} />\n )}\n {meta.openGraph?.images?.map((img, i) => (\n <React.Fragment key={`og-img-${i}`}>\n <meta property=\"og:image\" content={img.url} />\n {img.width && <meta property=\"og:image:width\" content={String(img.width)} />}\n {img.height && <meta property=\"og:image:height\" content={String(img.height)} />}\n {img.alt && <meta property=\"og:image:alt\" content={img.alt} />}\n </React.Fragment>\n ))}\n\n {/* ── Twitter Card ── */}\n {meta.twitter?.card && <meta name=\"twitter:card\" content={meta.twitter.card} />}\n {meta.twitter?.site && <meta name=\"twitter:site\" content={meta.twitter.site} />}\n {meta.twitter?.creator && <meta name=\"twitter:creator\" content={meta.twitter.creator} />}\n {meta.twitter?.title && <meta name=\"twitter:title\" content={meta.twitter.title} />}\n {meta.twitter?.description && (\n <meta name=\"twitter:description\" content={meta.twitter.description} />\n )}\n {meta.twitter?.images?.map((url, i) => (\n <meta key={`tw-img-${i}`} name=\"twitter:image\" content={url} />\n ))}\n\n {/* ── Custom meta attributes ── */}\n {meta.other &&\n Object.entries(meta.other).map(([name, content]) => (\n <meta key={`custom-${name}`} name={name} content={content} />\n ))}\n\n {/* ── Canonical URL ── */}\n {meta.alternates?.canonical && <link rel=\"canonical\" href={meta.alternates.canonical} />}\n </>\n )\n}\n\nexport default SeoMetaTags\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwJA,IAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOO,SAAS,eAAe,OAAwB;AACrD,MAAI,SAAU,eAAqC,SAAS,KAAK,GAAG;AAClE,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,IAAM,sBAAsB,CAAC,WAAW,uBAAuB,OAAO,QAAQ;AAOvE,SAAS,oBAAoB,OAA6B;AAC/D,MAAI,SAAU,oBAA0C,SAAS,KAAK,GAAG;AACvE,WAAO;AAAA,EACT;AACA,SAAO;AACT;AA2BO,SAAS,aAAa,SAA2C;AArNxE;AAsNE,QAAM,EAAC,KAAK,UAAU,IAAI,OAAO,IAAI,WAAW,CAAC,GAAG,iBAAgB,IAAI;AAExE,QAAM,iBAAiB,QAAQ,QAAQ,QAAQ,EAAE;AACjD,QAAM,iBAAiB,KAAK,QAAQ,QAAQ,EAAE;AAE9C,QAAM,UA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,QAAQ,MAAM;AAAA,MAC5E,UAAK,YAAL,mBAAc,SAAQ,4CAAC,UAAK,MAAK,gBAAe,SAAS,KAAK,QAAQ,MAAM;AAAA,MAC5E,UAAK,YAAL,mBAAc,YAAW,4CAAC,UAAK,MAAK,mBAAkB,SAAS,KAAK,QAAQ,SAAS;AAAA,MACrF,UAAK,YAAL,mBAAc,UAAS,4CAAC,UAAK,MAAK,iBAAgB,SAAS,KAAK,QAAQ,OAAO;AAAA,MAC/E,UAAK,YAAL,mBAAc,gBACb,4CAAC,UAAK,MAAK,uBAAsB,SAAS,KAAK,QAAQ,aAAa;AAAA,KAErE,gBAAK,YAAL,mBAAc,WAAd,mBAAsB,IAAI,CAAC,KAAK,MAC/B,4CAAC,UAAyB,MAAK,iBAAgB,SAAS,OAA7C,UAAU,CAAC,EAAuC;AAAA,IAI9D,KAAK,SACJ,OAAO,QAAQ,KAAK,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,OAAO,MAC5C,4CAAC,UAA4B,MAAY,WAA9B,UAAU,IAAI,EAAkC,CAC5D;AAAA,MAGF,UAAK,eAAL,mBAAiB,cAAa,4CAAC,UAAK,KAAI,aAAY,MAAM,KAAK,WAAW,WAAW;AAAA,KACxF;AAEJ;","names":["React"]}
@@ -0,0 +1,241 @@
1
+ import { b as SanityImage, c as SanityImageWithAlt, d as SeoFields } from './types-B91ena4g.cjs';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
4
+ /**
5
+ * Headless CMS integration helpers for sanity-plugin-seofields
6
+ *
7
+ * Provides framework-agnostic SEO metadata utilities for use with:
8
+ * - Next.js App Router → buildSeoMeta() inside generateMetadata()
9
+ * - Next.js Pages Router → <SeoMetaTags> inside Next.js <Head>
10
+ * - Nuxt / Remix / any SSR → <SeoMetaTags> inside your <head> slot
11
+ */
12
+
13
+ /** Structured metadata returned by buildSeoMeta(). Compatible with Next.js Metadata (App Router). */
14
+ interface SeoMetadata {
15
+ title?: string | null;
16
+ description?: string | null;
17
+ keywords?: string[];
18
+ robots?: {
19
+ index?: boolean;
20
+ follow?: boolean;
21
+ googleBot?: {
22
+ index?: boolean;
23
+ follow?: boolean;
24
+ };
25
+ };
26
+ openGraph?: {
27
+ type?: string;
28
+ url?: string;
29
+ title?: string;
30
+ description?: string;
31
+ siteName?: string;
32
+ images?: Array<{
33
+ url: string;
34
+ width?: number;
35
+ height?: number;
36
+ alt?: string;
37
+ }>;
38
+ };
39
+ twitter?: {
40
+ card?: string;
41
+ site?: string;
42
+ creator?: string;
43
+ title?: string;
44
+ description?: string;
45
+ images?: string[];
46
+ };
47
+ alternates?: {
48
+ canonical?: string;
49
+ };
50
+ /** Any custom meta attributes from seo.metaAttributes */
51
+ other?: Record<string, string>;
52
+ }
53
+ /** Default values used when SEO fields are missing. */
54
+ interface SeoMetaDefaults {
55
+ title?: string;
56
+ description?: string;
57
+ siteName?: string;
58
+ twitterSite?: string;
59
+ twitterCreator?: string;
60
+ /** Fallback image URL when no OG / Twitter image is set. */
61
+ ogImage?: string;
62
+ }
63
+ /**
64
+ * Permissive image shape accepted by buildSeoMeta — compatible with both the
65
+ * plugin's SanityImage and Sanity's code-generated image type (where `asset`
66
+ * and `alt` are optional).
67
+ */
68
+ interface SeoImageInput {
69
+ _type?: string;
70
+ asset?: {
71
+ _ref: string;
72
+ _type: string;
73
+ _weak?: boolean;
74
+ [key: string]: unknown;
75
+ };
76
+ hotspot?: unknown;
77
+ crop?: unknown;
78
+ alt?: string;
79
+ }
80
+ /**
81
+ * Input-compatible variant of SeoFields. Structurally matches Sanity's
82
+ * code-generated types (where `asset`, `alt`, `key`, and `type` are all
83
+ * optional), so you can pass `data.seo` from a sanityFetch result directly
84
+ * without any `as any` or manual casting.
85
+ */
86
+ interface SeoFieldsInput {
87
+ _type?: string;
88
+ robots?: {
89
+ noIndex?: boolean | null;
90
+ noFollow?: boolean | null;
91
+ } | null;
92
+ title?: string | null;
93
+ description?: string | null;
94
+ metaImage?: SeoImageInput | null;
95
+ metaAttributes?: Array<{
96
+ _key?: string;
97
+ key?: string;
98
+ value?: string;
99
+ type?: string;
100
+ }> | null;
101
+ keywords?: string[] | null;
102
+ canonicalUrl?: string | null;
103
+ openGraph?: {
104
+ _type?: string;
105
+ url?: string | null;
106
+ title?: string | null;
107
+ description?: string | null;
108
+ siteName?: string | null;
109
+ type?: string | null;
110
+ imageType?: string | null;
111
+ image?: SeoImageInput | null;
112
+ imageUrl?: string | null;
113
+ } | null;
114
+ twitter?: {
115
+ _type?: string;
116
+ card?: string | null;
117
+ site?: string | null;
118
+ creator?: string | null;
119
+ title?: string | null;
120
+ description?: string | null;
121
+ imageType?: string | null;
122
+ image?: SeoImageInput | null;
123
+ imageUrl?: string | null;
124
+ } | null;
125
+ }
126
+ /** Options accepted by buildSeoMeta(). */
127
+ interface BuildSeoMetaOptions {
128
+ /**
129
+ * The raw SEO object from Sanity (_type excluded or included — both work).
130
+ * Pass `null` or `undefined` to fall back entirely to `defaults`.
131
+ *
132
+ * Accepts both the strict plugin `SeoFields` type and Sanity's code-generated
133
+ * type (which has all nested fields optional) without any `as any` cast.
134
+ */
135
+ seo?: SeoFieldsInput | null;
136
+ /**
137
+ * The base URL of your site, e.g. "https://example.com".
138
+ * Used for canonical URL and OpenGraph URL construction.
139
+ */
140
+ baseUrl?: string;
141
+ /**
142
+ * The path for the current page, e.g. "/about".
143
+ * Combined with baseUrl to produce the canonical + OG url.
144
+ * Defaults to "".
145
+ */
146
+ path?: string;
147
+ /**
148
+ * Default values used when the Sanity SEO fields are empty / missing.
149
+ */
150
+ defaults?: SeoMetaDefaults;
151
+ /**
152
+ * Resolve a Sanity image asset to a plain URL string.
153
+ *
154
+ * @example (using @sanity/image-url)
155
+ * imageUrlResolver: (img) => urlFor(img).width(1200).url()
156
+ */
157
+ imageUrlResolver?: (image: SanityImage | SanityImageWithAlt) => string | null | undefined;
158
+ }
159
+ declare const VALID_OG_TYPES: readonly ["website", "article", "profile", "book", "music", "video", "product"];
160
+ type OGType = (typeof VALID_OG_TYPES)[number];
161
+ /**
162
+ * Coerce an arbitrary string to a valid OpenGraph type.
163
+ * Falls back to "website" when the value is invalid.
164
+ */
165
+ declare function sanitizeOGType(value?: string): OGType;
166
+ declare const VALID_TWITTER_CARDS: readonly ["summary", "summary_large_image", "app", "player"];
167
+ type TwitterCard = (typeof VALID_TWITTER_CARDS)[number];
168
+ /**
169
+ * Coerce an arbitrary string to a valid Twitter card type.
170
+ * Falls back to "summary_large_image" when the value is invalid.
171
+ */
172
+ declare function sanitizeTwitterCard(value?: string): TwitterCard;
173
+ /**
174
+ * Convert a Sanity SEO object into a structured metadata object.
175
+ *
176
+ * The return value is structurally compatible with Next.js App Router's
177
+ * `Metadata` type, so you can return it directly from `generateMetadata()`.
178
+ *
179
+ * @example Next.js App Router
180
+ * ```ts
181
+ * import { buildSeoMeta } from 'sanity-plugin-seofields'
182
+ * import { urlFor } from '@/sanity/lib/image'
183
+ *
184
+ * export async function generateMetadata(): Promise<Metadata> {
185
+ * const { seo } = await sanityFetch({ query: PAGE_SEO_QUERY })
186
+ * return buildSeoMeta({
187
+ * seo,
188
+ * baseUrl: process.env.NEXT_PUBLIC_SITE_URL,
189
+ * path: '/about',
190
+ * defaults: { title: 'My Site', siteName: 'My Site' },
191
+ * imageUrlResolver: (img) => urlFor(img).width(1200).url(),
192
+ * })
193
+ * }
194
+ * ```
195
+ */
196
+ declare function buildSeoMeta(options: BuildSeoMetaOptions): SeoMetadata;
197
+
198
+ interface SeoMetaTagsProps {
199
+ /**
200
+ * The raw SEO object from Sanity.
201
+ * Pass `null` / `undefined` to render only the defaults.
202
+ */
203
+ data?: Partial<SeoFields> | null;
204
+ /**
205
+ * Base URL of your site, e.g. "https://example.com".
206
+ * Used for canonical link, og:url fallback.
207
+ */
208
+ baseUrl?: string;
209
+ /**
210
+ * Current page path, e.g. "/about".
211
+ * Defaults to "".
212
+ */
213
+ path?: string;
214
+ /**
215
+ * Default values used when SEO fields are missing.
216
+ */
217
+ defaults?: BuildSeoMetaOptions['defaults'];
218
+ /**
219
+ * Resolve a Sanity image asset reference to a full URL string.
220
+ *
221
+ * @example
222
+ * imageUrlResolver={(img) => urlFor(img).width(1200).url()}
223
+ */
224
+ imageUrlResolver?: (image: SanityImage | SanityImageWithAlt) => string | null | undefined;
225
+ }
226
+ /**
227
+ * Renders all SEO meta tags for a page as plain React elements.
228
+ * Intended to be placed inside your framework's <Head> / <head> component.
229
+ *
230
+ * Renders:
231
+ * - `<title>`
232
+ * - `<meta name="description">`
233
+ * - `<meta name="keywords">`
234
+ * - `<meta name="robots">`
235
+ * - OpenGraph meta tags (`og:*`)
236
+ * - Twitter Card meta tags (`twitter:*`)
237
+ * - Any custom `seo.metaAttributes` as `<meta name="..." content="...">`
238
+ */
239
+ declare function SeoMetaTags({ data, baseUrl, path, defaults, imageUrlResolver }: SeoMetaTagsProps): react_jsx_runtime.JSX.Element;
240
+
241
+ export { type BuildSeoMetaOptions, type SeoFieldsInput, type SeoMetaDefaults, SeoMetaTags, type SeoMetaTagsProps, type SeoMetadata, buildSeoMeta, sanitizeOGType, sanitizeTwitterCard };