sanity-plugin-seofields 1.2.4 → 1.2.6

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 (49) hide show
  1. package/dist/index.cjs +2604 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +422 -0
  4. package/dist/index.d.ts +339 -492
  5. package/dist/index.js +1284 -2013
  6. package/dist/index.js.map +1 -1
  7. package/dist/next.cjs +182 -0
  8. package/dist/next.cjs.map +1 -0
  9. package/dist/next.d.cts +241 -0
  10. package/dist/next.d.ts +202 -295
  11. package/dist/next.js +110 -70
  12. package/dist/next.js.map +1 -1
  13. package/dist/types-B91ena4g.d.cts +89 -0
  14. package/dist/types-B91ena4g.d.ts +89 -0
  15. package/package.json +37 -18
  16. package/dist/index.d.mts +0 -575
  17. package/dist/index.mjs +0 -3292
  18. package/dist/index.mjs.map +0 -1
  19. package/dist/next.d.mts +0 -334
  20. package/dist/next.mjs +0 -102
  21. package/dist/next.mjs.map +0 -1
  22. package/sanity.json +0 -8
  23. package/src/components/SeoHealthDashboard.tsx +0 -1568
  24. package/src/components/SeoHealthPane.tsx +0 -81
  25. package/src/components/SeoHealthTool.tsx +0 -11
  26. package/src/components/SeoPreview.tsx +0 -178
  27. package/src/components/meta/MetaDescription.tsx +0 -39
  28. package/src/components/meta/MetaTitle.tsx +0 -44
  29. package/src/components/openGraph/OgDescription.tsx +0 -46
  30. package/src/components/openGraph/OgTitle.tsx +0 -45
  31. package/src/components/twitter/twitterDescription.tsx +0 -45
  32. package/src/components/twitter/twitterTitle.tsx +0 -45
  33. package/src/helpers/SeoMetaTags.tsx +0 -154
  34. package/src/helpers/seoMeta.ts +0 -283
  35. package/src/index.ts +0 -26
  36. package/src/next.ts +0 -12
  37. package/src/plugin.ts +0 -344
  38. package/src/schemas/index.ts +0 -121
  39. package/src/schemas/types/index.ts +0 -20
  40. package/src/schemas/types/metaAttribute/index.ts +0 -60
  41. package/src/schemas/types/metaTag/index.ts +0 -17
  42. package/src/schemas/types/openGraph/index.ts +0 -114
  43. package/src/schemas/types/robots/index.ts +0 -26
  44. package/src/schemas/types/twitter/index.ts +0 -108
  45. package/src/types.ts +0 -108
  46. package/src/utils/fieldsUtils.ts +0 -160
  47. package/src/utils/seoUtils.ts +0 -423
  48. package/src/utils/utils.ts +0 -9
  49. package/v2-incompatible.js +0 -11
package/dist/next.d.ts CHANGED
@@ -1,5 +1,175 @@
1
- import {default as React_2} from 'react'
1
+ import { b as SanityImage, c as SanityImageWithAlt, d as SeoFields } from './types-B91ena4g.js';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
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;
3
173
  /**
4
174
  * Convert a Sanity SEO object into a structured metadata object.
5
175
  *
@@ -23,238 +193,36 @@ import {default as React_2} from 'react'
23
193
  * }
24
194
  * ```
25
195
  */
26
- export declare function buildSeoMeta(options: BuildSeoMetaOptions): SeoMetadata
27
-
28
- /** Options accepted by buildSeoMeta(). */
29
- export declare interface BuildSeoMetaOptions {
30
- /**
31
- * The raw SEO object from Sanity (_type excluded or included — both work).
32
- * Pass `null` or `undefined` to fall back entirely to `defaults`.
33
- *
34
- * Accepts both the strict plugin `SeoFields` type and Sanity's code-generated
35
- * type (which has all nested fields optional) without any `as any` cast.
36
- */
37
- seo?: SeoFieldsInput | null
38
- /**
39
- * The base URL of your site, e.g. "https://example.com".
40
- * Used for canonical URL and OpenGraph URL construction.
41
- */
42
- baseUrl?: string
43
- /**
44
- * The path for the current page, e.g. "/about".
45
- * Combined with baseUrl to produce the canonical + OG url.
46
- * Defaults to "".
47
- */
48
- path?: string
49
- /**
50
- * Default values used when the Sanity SEO fields are empty / missing.
51
- */
52
- defaults?: SeoMetaDefaults
53
- /**
54
- * Resolve a Sanity image asset to a plain URL string.
55
- *
56
- * @example (using @sanity/image-url)
57
- * imageUrlResolver: (img) => urlFor(img).width(1200).url()
58
- */
59
- imageUrlResolver?: (image: SanityImage | SanityImageWithAlt) => string | null | undefined
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;
60
225
  }
61
-
62
- declare interface MetaAttribute {
63
- _type: 'metaAttribute'
64
- key?: string
65
- type?: 'string' | 'image'
66
- value?: string
67
- image?: SanityImage
68
- }
69
-
70
- declare type OGType = (typeof VALID_OG_TYPES)[number]
71
-
72
- declare interface OpenGraphSettings {
73
- _type: 'openGraph'
74
- /** The canonical URL for OpenGraph (og:url). Maps to the `url` field in Sanity. */
75
- url?: string
76
- title?: string
77
- description?: string
78
- siteName?: string
79
- type?: 'website' | 'article' | 'profile' | 'book' | 'music' | 'video' | 'product'
80
- imageType?: 'upload' | 'url'
81
- image?: SanityImageWithAlt
82
- imageUrl?: string
83
- }
84
-
85
- declare interface RobotsSettings {
86
- noIndex?: boolean
87
- noFollow?: boolean
88
- }
89
-
90
- /**
91
- * Coerce an arbitrary string to a valid OpenGraph type.
92
- * Falls back to "website" when the value is invalid.
93
- */
94
- export declare function sanitizeOGType(value?: string): OGType
95
-
96
- /**
97
- * Coerce an arbitrary string to a valid Twitter card type.
98
- * Falls back to "summary_large_image" when the value is invalid.
99
- */
100
- export declare function sanitizeTwitterCard(value?: string): TwitterCard
101
-
102
- declare interface SanityImage {
103
- _type: 'image'
104
- asset: {
105
- _ref: string
106
- _type: 'reference'
107
- }
108
- hotspot?: {
109
- x: number
110
- y: number
111
- height: number
112
- width: number
113
- }
114
- crop?: {
115
- top: number
116
- bottom: number
117
- left: number
118
- right: number
119
- }
120
- alt?: string
121
- }
122
-
123
- declare interface SanityImageWithAlt extends SanityImage {
124
- alt: string
125
- }
126
-
127
- declare interface SeoFields {
128
- _type: 'seoFields'
129
- robots?: RobotsSettings
130
- preview?: string
131
- title?: string
132
- description?: string
133
- metaImage?: SanityImage
134
- metaAttributes?: MetaAttribute[]
135
- keywords?: string[]
136
- canonicalUrl?: string
137
- openGraph?: OpenGraphSettings
138
- twitter?: TwitterCardSettings
139
- }
140
-
141
- /**
142
- * Input-compatible variant of SeoFields. Structurally matches Sanity's
143
- * code-generated types (where `asset`, `alt`, `key`, and `type` are all
144
- * optional), so you can pass `data.seo` from a sanityFetch result directly
145
- * without any `as any` or manual casting.
146
- */
147
- declare interface SeoFieldsInput {
148
- _type?: string
149
- robots?: {
150
- noIndex?: boolean | null
151
- noFollow?: boolean | null
152
- } | null
153
- title?: string | null
154
- description?: string | null
155
- metaImage?: SeoImageInput | null
156
- metaAttributes?: Array<{
157
- _key?: string
158
- key?: string
159
- value?: string
160
- type?: string
161
- }> | null
162
- keywords?: string[] | null
163
- canonicalUrl?: string | null
164
- openGraph?: {
165
- _type?: string
166
- url?: string | null
167
- title?: string | null
168
- description?: string | null
169
- siteName?: string | null
170
- type?: string | null
171
- imageType?: string | null
172
- image?: SeoImageInput | null
173
- imageUrl?: string | null
174
- } | null
175
- twitter?: {
176
- _type?: string
177
- card?: string | null
178
- site?: string | null
179
- creator?: string | null
180
- title?: string | null
181
- description?: string | null
182
- imageType?: string | null
183
- image?: SeoImageInput | null
184
- imageUrl?: string | null
185
- } | null
186
- }
187
-
188
- /**
189
- * Permissive image shape accepted by buildSeoMeta — compatible with both the
190
- * plugin's SanityImage and Sanity's code-generated image type (where `asset`
191
- * and `alt` are optional).
192
- */
193
- declare interface SeoImageInput {
194
- _type?: string
195
- asset?: {
196
- _ref: string
197
- _type: string
198
- _weak?: boolean
199
- [key: string]: unknown
200
- }
201
- hotspot?: unknown
202
- crop?: unknown
203
- alt?: string
204
- }
205
-
206
- /** Structured metadata returned by buildSeoMeta(). Compatible with Next.js Metadata (App Router). */
207
- export declare interface SeoMetadata {
208
- title?: string | null
209
- description?: string | null
210
- keywords?: string[]
211
- robots?: {
212
- index?: boolean
213
- follow?: boolean
214
- googleBot?: {
215
- index?: boolean
216
- follow?: boolean
217
- }
218
- }
219
- openGraph?: {
220
- type?: string
221
- url?: string
222
- title?: string
223
- description?: string
224
- siteName?: string
225
- images?: Array<{
226
- url: string
227
- width?: number
228
- height?: number
229
- alt?: string
230
- }>
231
- }
232
- twitter?: {
233
- card?: string
234
- site?: string
235
- creator?: string
236
- title?: string
237
- description?: string
238
- images?: string[]
239
- }
240
- alternates?: {
241
- canonical?: string
242
- }
243
- /** Any custom meta attributes from seo.metaAttributes */
244
- other?: Record<string, string>
245
- }
246
-
247
- /** Default values used when SEO fields are missing. */
248
- export declare interface SeoMetaDefaults {
249
- title?: string
250
- description?: string
251
- siteName?: string
252
- twitterSite?: string
253
- twitterCreator?: string
254
- /** Fallback image URL when no OG / Twitter image is set. */
255
- ogImage?: string
256
- }
257
-
258
226
  /**
259
227
  * Renders all SEO meta tags for a page as plain React elements.
260
228
  * Intended to be placed inside your framework's <Head> / <head> component.
@@ -268,67 +236,6 @@ export declare interface SeoMetaDefaults {
268
236
  * - Twitter Card meta tags (`twitter:*`)
269
237
  * - Any custom `seo.metaAttributes` as `<meta name="..." content="...">`
270
238
  */
271
- export declare function SeoMetaTags({
272
- data,
273
- baseUrl,
274
- path,
275
- defaults,
276
- imageUrlResolver,
277
- }: SeoMetaTagsProps): React_2.JSX.Element
278
-
279
- export declare interface SeoMetaTagsProps {
280
- /**
281
- * The raw SEO object from Sanity.
282
- * Pass `null` / `undefined` to render only the defaults.
283
- */
284
- data?: Partial<SeoFields> | null
285
- /**
286
- * Base URL of your site, e.g. "https://example.com".
287
- * Used for canonical link, og:url fallback.
288
- */
289
- baseUrl?: string
290
- /**
291
- * Current page path, e.g. "/about".
292
- * Defaults to "".
293
- */
294
- path?: string
295
- /**
296
- * Default values used when SEO fields are missing.
297
- */
298
- defaults?: BuildSeoMetaOptions['defaults']
299
- /**
300
- * Resolve a Sanity image asset reference to a full URL string.
301
- *
302
- * @example
303
- * imageUrlResolver={(img) => urlFor(img).width(1200).url()}
304
- */
305
- imageUrlResolver?: (image: SanityImage | SanityImageWithAlt) => string | null | undefined
306
- }
307
-
308
- declare type TwitterCard = (typeof VALID_TWITTER_CARDS)[number]
309
-
310
- declare interface TwitterCardSettings {
311
- _type: 'twitter'
312
- card?: 'summary' | 'summary_large_image' | 'app' | 'player'
313
- site?: string
314
- creator?: string
315
- title?: string
316
- description?: string
317
- imageType?: 'upload' | 'url'
318
- image?: SanityImageWithAlt
319
- imageUrl?: string
320
- }
321
-
322
- declare const VALID_OG_TYPES: readonly [
323
- 'website',
324
- 'article',
325
- 'profile',
326
- 'book',
327
- 'music',
328
- 'video',
329
- 'product',
330
- ]
331
-
332
- declare const VALID_TWITTER_CARDS: readonly ['summary', 'summary_large_image', 'app', 'player']
239
+ declare function SeoMetaTags({ data, baseUrl, path, defaults, imageUrlResolver }: SeoMetaTagsProps): react_jsx_runtime.JSX.Element;
333
240
 
334
- export {}
241
+ export { type BuildSeoMetaOptions, type SeoMetaDefaults, SeoMetaTags, type SeoMetaTagsProps, type SeoMetadata, buildSeoMeta, sanitizeOGType, sanitizeTwitterCard };