sanity-plugin-seofields 1.7.0 → 1.9.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 (111) hide show
  1. package/README.md +440 -29
  2. package/dist/SchemaOrgJsonLdPreview-DJLkIPq4.d.cts +78 -0
  3. package/dist/SchemaOrgJsonLdPreview-DJLkIPq4.d.ts +78 -0
  4. package/dist/SeoHealthTool-2COI27KI.cjs +8 -0
  5. package/dist/SeoHealthTool-2COI27KI.cjs.map +1 -0
  6. package/dist/SeoHealthTool-CWI3KB2V.js +8 -0
  7. package/dist/SeoHealthTool-CWI3KB2V.js.map +1 -0
  8. package/dist/{SeoPreview-WYH7NYNM.cjs → SeoPreview-LMZAWWOE.cjs} +35 -38
  9. package/dist/SeoPreview-LMZAWWOE.cjs.map +1 -0
  10. package/dist/{SeoPreview-KEGGQSPJ.js → SeoPreview-UNQBKTQO.js} +14 -11
  11. package/dist/SeoPreview-UNQBKTQO.js.map +1 -0
  12. package/dist/chunk-3OK3S2F7.cjs +673 -0
  13. package/dist/chunk-3OK3S2F7.cjs.map +1 -0
  14. package/dist/{chunk-GWPOJSGW.cjs → chunk-5XTQRILL.cjs} +1022 -307
  15. package/dist/chunk-5XTQRILL.cjs.map +1 -0
  16. package/dist/{chunk-2NMEKWO5.js → chunk-7N4MLTMR.js} +8 -15
  17. package/dist/chunk-7N4MLTMR.js.map +1 -0
  18. package/dist/{chunk-S367Y35J.cjs → chunk-A57XNQC7.cjs} +9 -20
  19. package/dist/chunk-A57XNQC7.cjs.map +1 -0
  20. package/dist/chunk-BWLJDK5J.js +624 -0
  21. package/dist/chunk-BWLJDK5J.js.map +1 -0
  22. package/dist/chunk-FUUWBQE2.cjs +195 -0
  23. package/dist/chunk-FUUWBQE2.cjs.map +1 -0
  24. package/dist/{chunk-ZBHLMQTS.cjs → chunk-HHO2AKAP.js} +44 -17
  25. package/dist/chunk-HHO2AKAP.js.map +1 -0
  26. package/dist/chunk-KIEO6QG3.js +195 -0
  27. package/dist/chunk-KIEO6QG3.js.map +1 -0
  28. package/dist/chunk-R2U7JF7U.cjs +624 -0
  29. package/dist/chunk-R2U7JF7U.cjs.map +1 -0
  30. package/dist/{chunk-HRKRV2X7.js → chunk-XZKQWV2H.js} +974 -148
  31. package/dist/chunk-XZKQWV2H.js.map +1 -0
  32. package/dist/{chunk-HDZZQCH7.js → chunk-Y46ACXM4.cjs} +45 -5
  33. package/dist/chunk-Y46ACXM4.cjs.map +1 -0
  34. package/dist/chunk-Z5AOUU4H.js +673 -0
  35. package/dist/chunk-Z5AOUU4H.js.map +1 -0
  36. package/dist/cli.js +27 -27
  37. package/dist/{component-DQ4KuQQD.d.ts → component-CjT1hvxh.d.ts} +3 -27
  38. package/dist/{component-D1sBm6ts.d.cts → component-WYh0z8as.d.cts} +3 -27
  39. package/dist/define-cli.cjs +2 -4
  40. package/dist/define-cli.cjs.map +1 -1
  41. package/dist/define-cli.js +4 -4
  42. package/dist/define-cli.js.map +1 -1
  43. package/dist/head.cjs +14 -0
  44. package/dist/head.cjs.map +1 -0
  45. package/dist/head.d.cts +254 -0
  46. package/dist/head.d.ts +254 -0
  47. package/dist/head.js +14 -0
  48. package/dist/head.js.map +1 -0
  49. package/dist/index.cjs +1797 -230
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +11 -598
  52. package/dist/index.d.ts +11 -598
  53. package/dist/index.js +1777 -197
  54. package/dist/index.js.map +1 -1
  55. package/dist/next.cjs +210 -447
  56. package/dist/next.cjs.map +1 -1
  57. package/dist/next.d.cts +8 -200
  58. package/dist/next.d.ts +8 -200
  59. package/dist/next.js +200 -124
  60. package/dist/next.js.map +1 -1
  61. package/dist/plugin-DQdThyxG.d.ts +449 -0
  62. package/dist/plugin-DoGeZP79.d.cts +449 -0
  63. package/dist/schema/next.cjs +173 -319
  64. package/dist/schema/next.cjs.map +1 -1
  65. package/dist/schema/next.d.cts +4 -4
  66. package/dist/schema/next.d.ts +4 -4
  67. package/dist/schema/next.js +172 -8
  68. package/dist/schema/next.js.map +1 -1
  69. package/dist/schema.cjs +390 -489
  70. package/dist/schema.cjs.map +1 -1
  71. package/dist/schema.d.cts +26 -16
  72. package/dist/schema.d.ts +26 -16
  73. package/dist/schema.js +236 -13
  74. package/dist/schema.js.map +1 -1
  75. package/dist/server.cjs +149 -0
  76. package/dist/server.cjs.map +1 -0
  77. package/dist/server.d.cts +102 -0
  78. package/dist/server.d.ts +102 -0
  79. package/dist/server.js +149 -0
  80. package/dist/server.js.map +1 -0
  81. package/dist/{types-CeBULNFF.d.ts → types-BAdN1RMu.d.ts} +2 -2
  82. package/dist/{types-_wBLg6RV.d.cts → types-C5i3KMgs.d.cts} +2 -2
  83. package/dist/{types-9_wbCIi9.d.ts → types-DP-DiW6f.d.cts} +29 -2
  84. package/dist/{types-Bb49oRBV.d.cts → types-DRLUGLtX.d.ts} +29 -2
  85. package/dist/{types-B91ena4g.d.cts → types-DxlPXihz.d.cts} +8 -1
  86. package/dist/{types-B91ena4g.d.ts → types-DxlPXihz.d.ts} +8 -1
  87. package/package.json +25 -3
  88. package/dist/SeoHealthDashboard-IP5BJ322.cjs +0 -10
  89. package/dist/SeoHealthDashboard-IP5BJ322.cjs.map +0 -1
  90. package/dist/SeoHealthDashboard-PTUEVYZL.js +0 -4
  91. package/dist/SeoHealthDashboard-PTUEVYZL.js.map +0 -1
  92. package/dist/SeoHealthTool-CZZRMWQK.cjs +0 -14
  93. package/dist/SeoHealthTool-CZZRMWQK.cjs.map +0 -1
  94. package/dist/SeoHealthTool-IULT4G25.js +0 -12
  95. package/dist/SeoHealthTool-IULT4G25.js.map +0 -1
  96. package/dist/SeoPreview-KEGGQSPJ.js.map +0 -1
  97. package/dist/SeoPreview-WYH7NYNM.cjs.map +0 -1
  98. package/dist/chunk-2NMEKWO5.js.map +0 -1
  99. package/dist/chunk-5YRH47VQ.cjs +0 -2167
  100. package/dist/chunk-5YRH47VQ.cjs.map +0 -1
  101. package/dist/chunk-ARELX3GK.cjs +0 -689
  102. package/dist/chunk-ARELX3GK.cjs.map +0 -1
  103. package/dist/chunk-AW7OKBQQ.js +0 -2161
  104. package/dist/chunk-AW7OKBQQ.js.map +0 -1
  105. package/dist/chunk-FONJYVF2.js +0 -610
  106. package/dist/chunk-FONJYVF2.js.map +0 -1
  107. package/dist/chunk-GWPOJSGW.cjs.map +0 -1
  108. package/dist/chunk-HDZZQCH7.js.map +0 -1
  109. package/dist/chunk-HRKRV2X7.js.map +0 -1
  110. package/dist/chunk-S367Y35J.cjs.map +0 -1
  111. package/dist/chunk-ZBHLMQTS.cjs.map +0 -1
@@ -1,12 +1,10 @@
1
- 'use strict';
2
-
3
- require('./chunk-S367Y35J.cjs');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-A57XNQC7.cjs');
4
2
 
5
3
  // src/define-cli.ts
6
4
  function defineSeoCli(config) {
7
5
  return config;
8
6
  }
9
7
 
8
+
10
9
  exports.defineSeoCli = defineSeoCli;
11
- //# sourceMappingURL=define-cli.cjs.map
12
10
  //# sourceMappingURL=define-cli.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/define-cli.ts"],"names":[],"mappings":";;;;;AAyCO,SAAS,aAAa,MAAA,EAAgD;AAC3E,EAAA,OAAO,MAAA;AACT","file":"define-cli.cjs","sourcesContent":["/**\n * Configuration helper for `seofields` CLI.\n *\n * Create a `seofields.cli.ts` (or `.js`) file in your project root and\n * use `defineSeoCli()` to configure the CLI without passing flags every time.\n *\n * @example\n * ```ts\n * // seofields.cli.ts\n * import { defineSeoCli } from 'sanity-plugin-seofields/define-cli'\n *\n * export default defineSeoCli({\n * projectId: 'my-project-id',\n * dataset: 'production',\n * token: process.env.SANITY_TOKEN,\n * types: ['post', 'page', 'article'],\n * })\n * ```\n */\n\nexport interface SeoFieldsCliConfig {\n /** Sanity project ID */\n projectId?: string\n /** Sanity dataset name (default: \"production\") */\n dataset?: string\n /** Sanity API token (read access at minimum) */\n token?: string\n /** Default document types for `report` and `export` commands */\n types?: string[]\n /**\n * Show connection info (project ID, dataset, token source) at the end of\n * `report` and `export` output. Useful for debugging which credentials\n * are being used. Defaults to `false`.\n */\n showConnectionInfo?: boolean\n}\n\n/**\n * Define CLI configuration for sanity-plugin-seofields commands.\n * Acts as an identity function — provides type safety for the config object.\n */\nexport function defineSeoCli(config: SeoFieldsCliConfig): SeoFieldsCliConfig {\n return config\n}\n"]}
1
+ {"version":3,"sources":["/Users/hardik/GITHUB/sanity-plugin-seofields/npm/dist/define-cli.cjs","../src/define-cli.ts"],"names":[],"mappings":"AAAA,yGAA6B;AAC7B;AACA;ACuCO,SAAS,YAAA,CAAa,MAAA,EAAgD;AAC3E,EAAA,OAAO,MAAA;AACT;ADrCA;AACE;AACF,oCAAC","file":"/Users/hardik/GITHUB/sanity-plugin-seofields/npm/dist/define-cli.cjs","sourcesContent":[null,"/**\n * Configuration helper for `seofields` CLI.\n *\n * Create a `seofields.cli.ts` (or `.js`) file in your project root and\n * use `defineSeoCli()` to configure the CLI without passing flags every time.\n *\n * @example\n * ```ts\n * // seofields.cli.ts\n * import { defineSeoCli } from 'sanity-plugin-seofields/define-cli'\n *\n * export default defineSeoCli({\n * projectId: 'my-project-id',\n * dataset: 'production',\n * token: process.env.SANITY_TOKEN,\n * types: ['post', 'page', 'article'],\n * })\n * ```\n */\n\nexport interface SeoFieldsCliConfig {\n /** Sanity project ID */\n projectId?: string\n /** Sanity dataset name (default: \"production\") */\n dataset?: string\n /** Sanity API token (read access at minimum) */\n token?: string\n /** Default document types for `report` and `export` commands */\n types?: string[]\n /**\n * Show connection info (project ID, dataset, token source) at the end of\n * `report` and `export` output. Useful for debugging which credentials\n * are being used. Defaults to `false`.\n */\n showConnectionInfo?: boolean\n}\n\n/**\n * Define CLI configuration for sanity-plugin-seofields commands.\n * Acts as an identity function — provides type safety for the config object.\n */\nexport function defineSeoCli(config: SeoFieldsCliConfig): SeoFieldsCliConfig {\n return config\n}\n"]}
@@ -1,10 +1,10 @@
1
- import './chunk-2NMEKWO5.js';
1
+ import "./chunk-7N4MLTMR.js";
2
2
 
3
3
  // src/define-cli.ts
4
4
  function defineSeoCli(config) {
5
5
  return config;
6
6
  }
7
-
8
- export { defineSeoCli };
9
- //# sourceMappingURL=define-cli.js.map
7
+ export {
8
+ defineSeoCli
9
+ };
10
10
  //# sourceMappingURL=define-cli.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/define-cli.ts"],"names":[],"mappings":";;;AAyCO,SAAS,aAAa,MAAA,EAAgD;AAC3E,EAAA,OAAO,MAAA;AACT","file":"define-cli.js","sourcesContent":["/**\n * Configuration helper for `seofields` CLI.\n *\n * Create a `seofields.cli.ts` (or `.js`) file in your project root and\n * use `defineSeoCli()` to configure the CLI without passing flags every time.\n *\n * @example\n * ```ts\n * // seofields.cli.ts\n * import { defineSeoCli } from 'sanity-plugin-seofields/define-cli'\n *\n * export default defineSeoCli({\n * projectId: 'my-project-id',\n * dataset: 'production',\n * token: process.env.SANITY_TOKEN,\n * types: ['post', 'page', 'article'],\n * })\n * ```\n */\n\nexport interface SeoFieldsCliConfig {\n /** Sanity project ID */\n projectId?: string\n /** Sanity dataset name (default: \"production\") */\n dataset?: string\n /** Sanity API token (read access at minimum) */\n token?: string\n /** Default document types for `report` and `export` commands */\n types?: string[]\n /**\n * Show connection info (project ID, dataset, token source) at the end of\n * `report` and `export` output. Useful for debugging which credentials\n * are being used. Defaults to `false`.\n */\n showConnectionInfo?: boolean\n}\n\n/**\n * Define CLI configuration for sanity-plugin-seofields commands.\n * Acts as an identity function — provides type safety for the config object.\n */\nexport function defineSeoCli(config: SeoFieldsCliConfig): SeoFieldsCliConfig {\n return config\n}\n"]}
1
+ {"version":3,"sources":["../src/define-cli.ts"],"sourcesContent":["/**\n * Configuration helper for `seofields` CLI.\n *\n * Create a `seofields.cli.ts` (or `.js`) file in your project root and\n * use `defineSeoCli()` to configure the CLI without passing flags every time.\n *\n * @example\n * ```ts\n * // seofields.cli.ts\n * import { defineSeoCli } from 'sanity-plugin-seofields/define-cli'\n *\n * export default defineSeoCli({\n * projectId: 'my-project-id',\n * dataset: 'production',\n * token: process.env.SANITY_TOKEN,\n * types: ['post', 'page', 'article'],\n * })\n * ```\n */\n\nexport interface SeoFieldsCliConfig {\n /** Sanity project ID */\n projectId?: string\n /** Sanity dataset name (default: \"production\") */\n dataset?: string\n /** Sanity API token (read access at minimum) */\n token?: string\n /** Default document types for `report` and `export` commands */\n types?: string[]\n /**\n * Show connection info (project ID, dataset, token source) at the end of\n * `report` and `export` output. Useful for debugging which credentials\n * are being used. Defaults to `false`.\n */\n showConnectionInfo?: boolean\n}\n\n/**\n * Define CLI configuration for sanity-plugin-seofields commands.\n * Acts as an identity function — provides type safety for the config object.\n */\nexport function defineSeoCli(config: SeoFieldsCliConfig): SeoFieldsCliConfig {\n return config\n}\n"],"mappings":";;;AAyCO,SAAS,aAAa,QAAgD;AAC3E,SAAO;AACT;","names":[]}
package/dist/head.cjs ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+ var _chunkFUUWBQE2cjs = require('./chunk-FUUWBQE2.cjs');
7
+ require('./chunk-A57XNQC7.cjs');
8
+
9
+
10
+
11
+
12
+
13
+ exports.buildSeoHead = _chunkFUUWBQE2cjs.buildSeoHead; exports.buildSeoMeta = _chunkFUUWBQE2cjs.buildSeoMeta; exports.sanitizeOGType = _chunkFUUWBQE2cjs.sanitizeOGType; exports.sanitizeTwitterCard = _chunkFUUWBQE2cjs.sanitizeTwitterCard;
14
+ //# sourceMappingURL=head.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/hardik/GITHUB/sanity-plugin-seofields/npm/dist/head.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,6OAAC","file":"/Users/hardik/GITHUB/sanity-plugin-seofields/npm/dist/head.cjs"}
@@ -0,0 +1,254 @@
1
+ import { a as SanityImage, b as SanityImageWithAlt } from './types-DxlPXihz.cjs';
2
+
3
+ /**
4
+ * Headless CMS integration helpers for sanity-plugin-seofields
5
+ *
6
+ * Provides framework-agnostic SEO metadata utilities for use with:
7
+ * - Next.js App Router → buildSeoMeta() inside generateMetadata()
8
+ * - Next.js Pages Router → <SeoMetaTags> inside Next.js <Head>
9
+ * - Astro / Nuxt / Vue / SvelteKit / Remix → buildSeoHead() into native head APIs
10
+ */
11
+
12
+ /** Structured metadata returned by buildSeoMeta(). Compatible with Next.js Metadata (App Router). */
13
+ interface SeoMetadata {
14
+ title?: string | null;
15
+ description?: string | null;
16
+ keywords?: string[];
17
+ robots?: {
18
+ index?: boolean;
19
+ follow?: boolean;
20
+ notranslate?: boolean;
21
+ noimageindex?: boolean;
22
+ googleBot?: {
23
+ index?: boolean;
24
+ follow?: boolean;
25
+ notranslate?: boolean;
26
+ noimageindex?: boolean;
27
+ };
28
+ };
29
+ openGraph?: {
30
+ type?: string;
31
+ url?: string;
32
+ title?: string;
33
+ description?: string;
34
+ siteName?: string;
35
+ images?: Array<{
36
+ url: string;
37
+ width?: number;
38
+ height?: number;
39
+ alt?: string;
40
+ }>;
41
+ };
42
+ twitter?: {
43
+ card?: string;
44
+ site?: string;
45
+ creator?: string;
46
+ title?: string;
47
+ description?: string;
48
+ images?: string[];
49
+ };
50
+ alternates?: {
51
+ canonical?: string;
52
+ languages?: Record<string, string>;
53
+ };
54
+ /** Any custom meta attributes from seo.metaAttributes */
55
+ other?: Record<string, string>;
56
+ }
57
+ /** Plain `<meta>` tag data returned by buildSeoHead(). */
58
+ type SeoHeadMetaTag = {
59
+ name: string;
60
+ content: string;
61
+ } | {
62
+ property: string;
63
+ content: string;
64
+ };
65
+ /** Plain `<link>` tag data returned by buildSeoHead(). */
66
+ interface SeoHeadLinkTag {
67
+ rel: string;
68
+ href: string;
69
+ hreflang?: string;
70
+ }
71
+ /**
72
+ * Framework-neutral head data returned by buildSeoHead().
73
+ *
74
+ * Use this in Astro, Nuxt, Vue, SvelteKit, Remix, or any frontend where you
75
+ * need plain values instead of React elements or Next.js Metadata.
76
+ */
77
+ interface SeoHead {
78
+ title?: string | null;
79
+ meta: SeoHeadMetaTag[];
80
+ link: SeoHeadLinkTag[];
81
+ }
82
+ /** Default values used when SEO fields are missing. */
83
+ interface SeoMetaDefaults {
84
+ title?: string;
85
+ description?: string;
86
+ siteName?: string;
87
+ twitterSite?: string;
88
+ twitterCreator?: string;
89
+ /** Fallback image URL when no OG / Twitter image is set. */
90
+ ogImage?: string;
91
+ }
92
+ /**
93
+ * Permissive image shape accepted by buildSeoMeta — compatible with both the
94
+ * plugin's SanityImage and Sanity's code-generated image type (where `asset`
95
+ * and `alt` are optional).
96
+ */
97
+ interface SeoImageInput {
98
+ _type?: string;
99
+ asset?: {
100
+ _ref: string;
101
+ _type: string;
102
+ _weak?: boolean;
103
+ [key: string]: unknown;
104
+ };
105
+ hotspot?: unknown;
106
+ crop?: unknown;
107
+ alt?: string;
108
+ }
109
+ /**
110
+ * Input-compatible variant of SeoFields. Structurally matches Sanity's
111
+ * code-generated types (where `asset`, `alt`, `key`, and `type` are all
112
+ * optional), so you can pass `data.seo` from a sanityFetch result directly
113
+ * without any `as any` or manual casting.
114
+ */
115
+ interface SeoFieldsInput {
116
+ _type?: string;
117
+ robots?: {
118
+ noIndex?: boolean | null;
119
+ noFollow?: boolean | null;
120
+ noTranslate?: boolean | null;
121
+ noImageIndex?: boolean | null;
122
+ } | null;
123
+ title?: string | null;
124
+ description?: string | null;
125
+ metaImage?: SeoImageInput | null;
126
+ metaAttributes?: Array<{
127
+ _key?: string;
128
+ key?: string;
129
+ value?: string;
130
+ type?: string;
131
+ }> | null;
132
+ keywords?: string[] | null;
133
+ canonicalUrl?: string | null;
134
+ hreflangs?: Array<{
135
+ locale?: string | null;
136
+ url?: string | null;
137
+ }> | null;
138
+ openGraph?: {
139
+ _type?: string;
140
+ url?: string | null;
141
+ title?: string | null;
142
+ description?: string | null;
143
+ siteName?: string | null;
144
+ type?: string | null;
145
+ imageType?: string | null;
146
+ image?: SeoImageInput | null;
147
+ imageUrl?: string | null;
148
+ } | null;
149
+ twitter?: {
150
+ _type?: string;
151
+ card?: string | null;
152
+ site?: string | null;
153
+ creator?: string | null;
154
+ title?: string | null;
155
+ description?: string | null;
156
+ imageType?: string | null;
157
+ image?: SeoImageInput | null;
158
+ imageUrl?: string | null;
159
+ } | null;
160
+ }
161
+ /** Options accepted by buildSeoMeta(). */
162
+ interface BuildSeoMetaOptions {
163
+ /**
164
+ * The raw SEO object from Sanity (_type excluded or included — both work).
165
+ * Pass `null` or `undefined` to fall back entirely to `defaults`.
166
+ *
167
+ * Accepts both the strict plugin `SeoFields` type and Sanity's code-generated
168
+ * type (which has all nested fields optional) without any `as any` cast.
169
+ */
170
+ seo?: SeoFieldsInput | null;
171
+ /**
172
+ * The base URL of your site, e.g. "https://example.com".
173
+ * Used for canonical URL and OpenGraph URL construction.
174
+ */
175
+ baseUrl?: string;
176
+ /**
177
+ * The path for the current page, e.g. "/about".
178
+ * Combined with baseUrl to produce the canonical + OG url.
179
+ * Defaults to "".
180
+ */
181
+ path?: string;
182
+ /**
183
+ * Default values used when the Sanity SEO fields are empty / missing.
184
+ */
185
+ defaults?: SeoMetaDefaults;
186
+ /**
187
+ * Resolve a Sanity image asset to a plain URL string.
188
+ *
189
+ * @example (using @sanity/image-url)
190
+ * imageUrlResolver: (img) => urlFor(img).width(1200).url()
191
+ */
192
+ imageUrlResolver?: (image: SanityImage | SanityImageWithAlt) => string | null | undefined;
193
+ }
194
+ declare const VALID_OG_TYPES: readonly ["website", "article", "profile", "book", "music", "video", "product"];
195
+ type OGType = (typeof VALID_OG_TYPES)[number];
196
+ /**
197
+ * Coerce an arbitrary string to a valid OpenGraph type.
198
+ * Falls back to "website" when the value is invalid.
199
+ */
200
+ declare function sanitizeOGType(value?: string): OGType;
201
+ declare const VALID_TWITTER_CARDS: readonly ["summary", "summary_large_image", "app", "player"];
202
+ type TwitterCard = (typeof VALID_TWITTER_CARDS)[number];
203
+ /**
204
+ * Coerce an arbitrary string to a valid Twitter card type.
205
+ * Falls back to "summary_large_image" when the value is invalid.
206
+ */
207
+ declare function sanitizeTwitterCard(value?: string): TwitterCard;
208
+ /**
209
+ * Convert a Sanity SEO object into a structured metadata object.
210
+ *
211
+ * The return value is structurally compatible with Next.js App Router's
212
+ * `Metadata` type, so you can return it directly from `generateMetadata()`.
213
+ *
214
+ * @example Next.js App Router
215
+ * ```ts
216
+ * import { buildSeoMeta } from 'sanity-plugin-seofields/next'
217
+ * import { urlFor } from '@/sanity/lib/image'
218
+ *
219
+ * export async function generateMetadata(): Promise<Metadata> {
220
+ * const { seo } = await sanityFetch({ query: PAGE_SEO_QUERY })
221
+ * return buildSeoMeta({
222
+ * seo,
223
+ * baseUrl: process.env.NEXT_PUBLIC_SITE_URL,
224
+ * path: '/about',
225
+ * defaults: { title: 'My Site', siteName: 'My Site' },
226
+ * imageUrlResolver: (img) => urlFor(img).width(1200).url(),
227
+ * })
228
+ * }
229
+ * ```
230
+ */
231
+ declare function buildSeoMeta(options: BuildSeoMetaOptions): SeoMetadata;
232
+ /**
233
+ * Convert Sanity SEO fields into plain head tag data.
234
+ *
235
+ * This helper is framework-neutral: it returns serializable `title`, `meta`,
236
+ * and `link` arrays that can be passed to Astro layouts, Nuxt/Vue `useHead`,
237
+ * SvelteKit `<svelte:head>`, Remix `meta()` exports, or any custom renderer.
238
+ *
239
+ * @example Astro / Nuxt / SvelteKit
240
+ * ```ts
241
+ * import { buildSeoHead } from 'sanity-plugin-seofields/head'
242
+ *
243
+ * const head = buildSeoHead({
244
+ * seo: page.seo,
245
+ * baseUrl: 'https://example.com',
246
+ * path: `/blog/${page.slug}`,
247
+ * defaults: { title: page.title, siteName: 'My Site' },
248
+ * imageUrlResolver: (img) => urlFor(img).width(1200).height(630).url(),
249
+ * })
250
+ * ```
251
+ */
252
+ declare function buildSeoHead(options: BuildSeoMetaOptions): SeoHead;
253
+
254
+ export { type BuildSeoMetaOptions, type SeoFieldsInput, type SeoHead, type SeoHeadLinkTag, type SeoHeadMetaTag, type SeoMetaDefaults, type SeoMetadata, buildSeoHead, buildSeoMeta, sanitizeOGType, sanitizeTwitterCard };
package/dist/head.d.ts ADDED
@@ -0,0 +1,254 @@
1
+ import { a as SanityImage, b as SanityImageWithAlt } from './types-DxlPXihz.js';
2
+
3
+ /**
4
+ * Headless CMS integration helpers for sanity-plugin-seofields
5
+ *
6
+ * Provides framework-agnostic SEO metadata utilities for use with:
7
+ * - Next.js App Router → buildSeoMeta() inside generateMetadata()
8
+ * - Next.js Pages Router → <SeoMetaTags> inside Next.js <Head>
9
+ * - Astro / Nuxt / Vue / SvelteKit / Remix → buildSeoHead() into native head APIs
10
+ */
11
+
12
+ /** Structured metadata returned by buildSeoMeta(). Compatible with Next.js Metadata (App Router). */
13
+ interface SeoMetadata {
14
+ title?: string | null;
15
+ description?: string | null;
16
+ keywords?: string[];
17
+ robots?: {
18
+ index?: boolean;
19
+ follow?: boolean;
20
+ notranslate?: boolean;
21
+ noimageindex?: boolean;
22
+ googleBot?: {
23
+ index?: boolean;
24
+ follow?: boolean;
25
+ notranslate?: boolean;
26
+ noimageindex?: boolean;
27
+ };
28
+ };
29
+ openGraph?: {
30
+ type?: string;
31
+ url?: string;
32
+ title?: string;
33
+ description?: string;
34
+ siteName?: string;
35
+ images?: Array<{
36
+ url: string;
37
+ width?: number;
38
+ height?: number;
39
+ alt?: string;
40
+ }>;
41
+ };
42
+ twitter?: {
43
+ card?: string;
44
+ site?: string;
45
+ creator?: string;
46
+ title?: string;
47
+ description?: string;
48
+ images?: string[];
49
+ };
50
+ alternates?: {
51
+ canonical?: string;
52
+ languages?: Record<string, string>;
53
+ };
54
+ /** Any custom meta attributes from seo.metaAttributes */
55
+ other?: Record<string, string>;
56
+ }
57
+ /** Plain `<meta>` tag data returned by buildSeoHead(). */
58
+ type SeoHeadMetaTag = {
59
+ name: string;
60
+ content: string;
61
+ } | {
62
+ property: string;
63
+ content: string;
64
+ };
65
+ /** Plain `<link>` tag data returned by buildSeoHead(). */
66
+ interface SeoHeadLinkTag {
67
+ rel: string;
68
+ href: string;
69
+ hreflang?: string;
70
+ }
71
+ /**
72
+ * Framework-neutral head data returned by buildSeoHead().
73
+ *
74
+ * Use this in Astro, Nuxt, Vue, SvelteKit, Remix, or any frontend where you
75
+ * need plain values instead of React elements or Next.js Metadata.
76
+ */
77
+ interface SeoHead {
78
+ title?: string | null;
79
+ meta: SeoHeadMetaTag[];
80
+ link: SeoHeadLinkTag[];
81
+ }
82
+ /** Default values used when SEO fields are missing. */
83
+ interface SeoMetaDefaults {
84
+ title?: string;
85
+ description?: string;
86
+ siteName?: string;
87
+ twitterSite?: string;
88
+ twitterCreator?: string;
89
+ /** Fallback image URL when no OG / Twitter image is set. */
90
+ ogImage?: string;
91
+ }
92
+ /**
93
+ * Permissive image shape accepted by buildSeoMeta — compatible with both the
94
+ * plugin's SanityImage and Sanity's code-generated image type (where `asset`
95
+ * and `alt` are optional).
96
+ */
97
+ interface SeoImageInput {
98
+ _type?: string;
99
+ asset?: {
100
+ _ref: string;
101
+ _type: string;
102
+ _weak?: boolean;
103
+ [key: string]: unknown;
104
+ };
105
+ hotspot?: unknown;
106
+ crop?: unknown;
107
+ alt?: string;
108
+ }
109
+ /**
110
+ * Input-compatible variant of SeoFields. Structurally matches Sanity's
111
+ * code-generated types (where `asset`, `alt`, `key`, and `type` are all
112
+ * optional), so you can pass `data.seo` from a sanityFetch result directly
113
+ * without any `as any` or manual casting.
114
+ */
115
+ interface SeoFieldsInput {
116
+ _type?: string;
117
+ robots?: {
118
+ noIndex?: boolean | null;
119
+ noFollow?: boolean | null;
120
+ noTranslate?: boolean | null;
121
+ noImageIndex?: boolean | null;
122
+ } | null;
123
+ title?: string | null;
124
+ description?: string | null;
125
+ metaImage?: SeoImageInput | null;
126
+ metaAttributes?: Array<{
127
+ _key?: string;
128
+ key?: string;
129
+ value?: string;
130
+ type?: string;
131
+ }> | null;
132
+ keywords?: string[] | null;
133
+ canonicalUrl?: string | null;
134
+ hreflangs?: Array<{
135
+ locale?: string | null;
136
+ url?: string | null;
137
+ }> | null;
138
+ openGraph?: {
139
+ _type?: string;
140
+ url?: string | null;
141
+ title?: string | null;
142
+ description?: string | null;
143
+ siteName?: string | null;
144
+ type?: string | null;
145
+ imageType?: string | null;
146
+ image?: SeoImageInput | null;
147
+ imageUrl?: string | null;
148
+ } | null;
149
+ twitter?: {
150
+ _type?: string;
151
+ card?: string | null;
152
+ site?: string | null;
153
+ creator?: string | null;
154
+ title?: string | null;
155
+ description?: string | null;
156
+ imageType?: string | null;
157
+ image?: SeoImageInput | null;
158
+ imageUrl?: string | null;
159
+ } | null;
160
+ }
161
+ /** Options accepted by buildSeoMeta(). */
162
+ interface BuildSeoMetaOptions {
163
+ /**
164
+ * The raw SEO object from Sanity (_type excluded or included — both work).
165
+ * Pass `null` or `undefined` to fall back entirely to `defaults`.
166
+ *
167
+ * Accepts both the strict plugin `SeoFields` type and Sanity's code-generated
168
+ * type (which has all nested fields optional) without any `as any` cast.
169
+ */
170
+ seo?: SeoFieldsInput | null;
171
+ /**
172
+ * The base URL of your site, e.g. "https://example.com".
173
+ * Used for canonical URL and OpenGraph URL construction.
174
+ */
175
+ baseUrl?: string;
176
+ /**
177
+ * The path for the current page, e.g. "/about".
178
+ * Combined with baseUrl to produce the canonical + OG url.
179
+ * Defaults to "".
180
+ */
181
+ path?: string;
182
+ /**
183
+ * Default values used when the Sanity SEO fields are empty / missing.
184
+ */
185
+ defaults?: SeoMetaDefaults;
186
+ /**
187
+ * Resolve a Sanity image asset to a plain URL string.
188
+ *
189
+ * @example (using @sanity/image-url)
190
+ * imageUrlResolver: (img) => urlFor(img).width(1200).url()
191
+ */
192
+ imageUrlResolver?: (image: SanityImage | SanityImageWithAlt) => string | null | undefined;
193
+ }
194
+ declare const VALID_OG_TYPES: readonly ["website", "article", "profile", "book", "music", "video", "product"];
195
+ type OGType = (typeof VALID_OG_TYPES)[number];
196
+ /**
197
+ * Coerce an arbitrary string to a valid OpenGraph type.
198
+ * Falls back to "website" when the value is invalid.
199
+ */
200
+ declare function sanitizeOGType(value?: string): OGType;
201
+ declare const VALID_TWITTER_CARDS: readonly ["summary", "summary_large_image", "app", "player"];
202
+ type TwitterCard = (typeof VALID_TWITTER_CARDS)[number];
203
+ /**
204
+ * Coerce an arbitrary string to a valid Twitter card type.
205
+ * Falls back to "summary_large_image" when the value is invalid.
206
+ */
207
+ declare function sanitizeTwitterCard(value?: string): TwitterCard;
208
+ /**
209
+ * Convert a Sanity SEO object into a structured metadata object.
210
+ *
211
+ * The return value is structurally compatible with Next.js App Router's
212
+ * `Metadata` type, so you can return it directly from `generateMetadata()`.
213
+ *
214
+ * @example Next.js App Router
215
+ * ```ts
216
+ * import { buildSeoMeta } from 'sanity-plugin-seofields/next'
217
+ * import { urlFor } from '@/sanity/lib/image'
218
+ *
219
+ * export async function generateMetadata(): Promise<Metadata> {
220
+ * const { seo } = await sanityFetch({ query: PAGE_SEO_QUERY })
221
+ * return buildSeoMeta({
222
+ * seo,
223
+ * baseUrl: process.env.NEXT_PUBLIC_SITE_URL,
224
+ * path: '/about',
225
+ * defaults: { title: 'My Site', siteName: 'My Site' },
226
+ * imageUrlResolver: (img) => urlFor(img).width(1200).url(),
227
+ * })
228
+ * }
229
+ * ```
230
+ */
231
+ declare function buildSeoMeta(options: BuildSeoMetaOptions): SeoMetadata;
232
+ /**
233
+ * Convert Sanity SEO fields into plain head tag data.
234
+ *
235
+ * This helper is framework-neutral: it returns serializable `title`, `meta`,
236
+ * and `link` arrays that can be passed to Astro layouts, Nuxt/Vue `useHead`,
237
+ * SvelteKit `<svelte:head>`, Remix `meta()` exports, or any custom renderer.
238
+ *
239
+ * @example Astro / Nuxt / SvelteKit
240
+ * ```ts
241
+ * import { buildSeoHead } from 'sanity-plugin-seofields/head'
242
+ *
243
+ * const head = buildSeoHead({
244
+ * seo: page.seo,
245
+ * baseUrl: 'https://example.com',
246
+ * path: `/blog/${page.slug}`,
247
+ * defaults: { title: page.title, siteName: 'My Site' },
248
+ * imageUrlResolver: (img) => urlFor(img).width(1200).height(630).url(),
249
+ * })
250
+ * ```
251
+ */
252
+ declare function buildSeoHead(options: BuildSeoMetaOptions): SeoHead;
253
+
254
+ export { type BuildSeoMetaOptions, type SeoFieldsInput, type SeoHead, type SeoHeadLinkTag, type SeoHeadMetaTag, type SeoMetaDefaults, type SeoMetadata, buildSeoHead, buildSeoMeta, sanitizeOGType, sanitizeTwitterCard };
package/dist/head.js ADDED
@@ -0,0 +1,14 @@
1
+ import {
2
+ buildSeoHead,
3
+ buildSeoMeta,
4
+ sanitizeOGType,
5
+ sanitizeTwitterCard
6
+ } from "./chunk-KIEO6QG3.js";
7
+ import "./chunk-7N4MLTMR.js";
8
+ export {
9
+ buildSeoHead,
10
+ buildSeoMeta,
11
+ sanitizeOGType,
12
+ sanitizeTwitterCard
13
+ };
14
+ //# sourceMappingURL=head.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}