sanity-plugin-seofields 1.3.1 → 1.4.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.
@@ -0,0 +1,387 @@
1
+ import React from 'react';
2
+ import * as sanity from 'sanity';
3
+ import { SchemaTypeDefinition } from 'sanity';
4
+ import { S as SchemaOrgAggregateRatingConfig, a as SchemaOrgArticleConfig, b as SchemaOrgBlogPostingConfig, c as SchemaOrgBrandConfig, d as SchemaOrgBreadcrumbListConfig, e as SchemaOrgContactPointConfig, f as SchemaOrgCourseConfig, g as SchemaOrgEventConfig, h as SchemaOrgFAQPageConfig, i as SchemaOrgHowToConfig, j as SchemaOrgImageObjectConfig, k as SchemaOrgLocalBusinessConfig, l as SchemaOrgOfferConfig, m as SchemaOrgOrganizationConfig, n as SchemaOrgPersonConfig, o as SchemaOrgPlaceConfig, p as SchemaOrgPostalAddressConfig, q as SchemaOrgProductConfig, r as SchemaOrgReviewConfig, s as SchemaOrgSoftwareApplicationConfig, t as SchemaOrgVideoObjectConfig, u as SchemaOrgWebApplicationConfig, v as SchemaOrgWebPageConfig, w as SchemaOrgWebsiteConfig } from './types-CVaAX7uy.cjs';
5
+ export { O as OrganizationContactPoint, x as SchemaOrgAggregateRatingData, y as SchemaOrgArticleData, z as SchemaOrgBlogPostingData, A as SchemaOrgBrandData, B as SchemaOrgBreadcrumbListData, C as SchemaOrgContactPointData, D as SchemaOrgCourseData, E as SchemaOrgEventData, F as SchemaOrgFAQPageData, G as SchemaOrgHowToData, H as SchemaOrgImageObjectData, I as SchemaOrgLocalBusinessData, J as SchemaOrgOfferData, K as SchemaOrgOrganizationData, L as SchemaOrgPersonData, M as SchemaOrgPlaceData, N as SchemaOrgPostalAddressData, P as SchemaOrgProductData, Q as SchemaOrgReviewData, R as SchemaOrgSoftwareApplicationData, T as SchemaOrgVideoObjectData, U as SchemaOrgWebApplicationData, V as SchemaOrgWebPageData, W as SchemaOrgWebsiteData, X as WebsitePublisher } from './types-CVaAX7uy.cjs';
6
+ import './types-R3n9Fu4w.cjs';
7
+
8
+ /**
9
+ * Dynamic Sanity schema generator for Schema.org types.
10
+ *
11
+ * Each Schema.org type declares its fields as a plain `SchemaFieldDef[]` array.
12
+ * The generator converts them into Sanity `defineType` / `defineField` calls,
13
+ * wiring up validation, initial values, options, and nested objects/arrays
14
+ * automatically.
15
+ *
16
+ * It also provides a generic JSON-LD builder and React component factory so
17
+ * adding a new Schema.org type requires only a field definition array.
18
+ */
19
+
20
+ interface SchemaFieldOption {
21
+ title: string;
22
+ value: string;
23
+ }
24
+ interface SchemaFieldDef {
25
+ /** Sanity field name */
26
+ name: string;
27
+ /** Human-readable title shown in Studio */
28
+ title: string;
29
+ /** Sanity field type */
30
+ type: 'string' | 'url' | 'text' | 'array' | 'object' | 'image' | 'number' | 'date' | 'datetime';
31
+ /** Help text shown below the field */
32
+ description?: string;
33
+ /** If set, field is required — key is the validation config key, message is the default */
34
+ required?: {
35
+ key: string;
36
+ message: string;
37
+ };
38
+ /** Initial value for the field */
39
+ initialValue?: unknown;
40
+ /** Dropdown / radio options for string fields */
41
+ options?: SchemaFieldOption[];
42
+ /** Number of rows for text fields */
43
+ rows?: number;
44
+ /** Array member types, e.g. [{type: 'string'}] */
45
+ of?: {
46
+ type: string;
47
+ }[];
48
+ /** Nested fields for object type */
49
+ fields?: SchemaFieldDef[];
50
+ /** Schema.org @type for this nested object or array items in JSON-LD output */
51
+ jsonLdType?: string;
52
+ /** JSON-LD key if different from the Sanity field name */
53
+ jsonLdKey?: string;
54
+ }
55
+ interface SchemaTypeDef {
56
+ /** Sanity type name, e.g. "schemaOrgWebsite" */
57
+ name: string;
58
+ /** Title shown in Studio, e.g. "Schema.org — Website" */
59
+ title: string;
60
+ /** Icon component shown in Studio and the array grid picker */
61
+ icon?: React.ComponentType;
62
+ /** Field definitions */
63
+ fields: SchemaFieldDef[];
64
+ }
65
+ interface SchemaOrgConfig {
66
+ /** Custom validation error messages keyed by field config key */
67
+ validation?: Record<string, string>;
68
+ }
69
+ /**
70
+ * Generates a complete Sanity `SchemaTypeDefinition` from a declarative
71
+ * `SchemaTypeDef` and optional user config.
72
+ */
73
+ declare function generateSchemaType(def: SchemaTypeDef, config?: SchemaOrgConfig): SchemaTypeDefinition;
74
+ /**
75
+ * Builds a complete Schema.org JSON-LD object from Sanity data using field defs.
76
+ * Returns `null` if any of the `requiredFields` are missing.
77
+ *
78
+ * @param schemaType The Schema.org `@type` (e.g. "Person", "Article")
79
+ * @param data Raw data from a Sanity GROQ query
80
+ * @param fieldDefs The field definitions for this schema type
81
+ * @param requiredFields Field names that must be present (returns null if missing)
82
+ */
83
+ declare function buildGenericJsonLd(schemaType: string, data: Record<string, unknown> | null | undefined, fieldDefs: SchemaFieldDef[], requiredFields?: string[]): Record<string, unknown> | null;
84
+
85
+ /** Per-type validation overrides for the combined `schemaOrg()` plugin. */
86
+ interface SchemaOrgCombinedConfig {
87
+ website?: SchemaOrgConfig;
88
+ organization?: SchemaOrgConfig;
89
+ webPage?: SchemaOrgConfig;
90
+ person?: SchemaOrgConfig;
91
+ breadcrumbList?: SchemaOrgConfig;
92
+ imageObject?: SchemaOrgConfig;
93
+ article?: SchemaOrgConfig;
94
+ blogPosting?: SchemaOrgConfig;
95
+ faqPage?: SchemaOrgConfig;
96
+ howTo?: SchemaOrgConfig;
97
+ product?: SchemaOrgConfig;
98
+ offer?: SchemaOrgConfig;
99
+ aggregateRating?: SchemaOrgConfig;
100
+ review?: SchemaOrgConfig;
101
+ brand?: SchemaOrgConfig;
102
+ localBusiness?: SchemaOrgConfig;
103
+ postalAddress?: SchemaOrgConfig;
104
+ contactPoint?: SchemaOrgConfig;
105
+ softwareApplication?: SchemaOrgConfig;
106
+ webApplication?: SchemaOrgConfig;
107
+ event?: SchemaOrgConfig;
108
+ place?: SchemaOrgConfig;
109
+ videoObject?: SchemaOrgConfig;
110
+ course?: SchemaOrgConfig;
111
+ }
112
+ declare const schemaOrgWebsitePlugin: sanity.Plugin<void | SchemaOrgConfig>;
113
+ declare const schemaOrgOrganizationPlugin: sanity.Plugin<void | SchemaOrgConfig>;
114
+ declare const schemaOrgWebPagePlugin: sanity.Plugin<void | SchemaOrgConfig>;
115
+ declare const schemaOrgPersonPlugin: sanity.Plugin<void | SchemaOrgConfig>;
116
+ declare const schemaOrgBreadcrumbListPlugin: sanity.Plugin<void | SchemaOrgConfig>;
117
+ declare const schemaOrgImageObjectPlugin: sanity.Plugin<void | SchemaOrgConfig>;
118
+ declare const schemaOrgArticlePlugin: sanity.Plugin<void | SchemaOrgConfig>;
119
+ declare const schemaOrgBlogPostingPlugin: sanity.Plugin<void | SchemaOrgConfig>;
120
+ declare const schemaOrgFAQPagePlugin: sanity.Plugin<void | SchemaOrgConfig>;
121
+ declare const schemaOrgHowToPlugin: sanity.Plugin<void | SchemaOrgConfig>;
122
+ declare const schemaOrgProductPlugin: sanity.Plugin<void | SchemaOrgConfig>;
123
+ declare const schemaOrgOfferPlugin: sanity.Plugin<void | SchemaOrgConfig>;
124
+ declare const schemaOrgAggregateRatingPlugin: sanity.Plugin<void | SchemaOrgConfig>;
125
+ declare const schemaOrgReviewPlugin: sanity.Plugin<void | SchemaOrgConfig>;
126
+ declare const schemaOrgBrandPlugin: sanity.Plugin<void | SchemaOrgConfig>;
127
+ declare const schemaOrgLocalBusinessPlugin: sanity.Plugin<void | SchemaOrgConfig>;
128
+ declare const schemaOrgPostalAddressPlugin: sanity.Plugin<void | SchemaOrgConfig>;
129
+ declare const schemaOrgContactPointPlugin: sanity.Plugin<void | SchemaOrgConfig>;
130
+ declare const schemaOrgSoftwareApplicationPlugin: sanity.Plugin<void | SchemaOrgConfig>;
131
+ declare const schemaOrgWebApplicationPlugin: sanity.Plugin<void | SchemaOrgConfig>;
132
+ declare const schemaOrgEventPlugin: sanity.Plugin<void | SchemaOrgConfig>;
133
+ declare const schemaOrgPlacePlugin: sanity.Plugin<void | SchemaOrgConfig>;
134
+ declare const schemaOrgVideoObjectPlugin: sanity.Plugin<void | SchemaOrgConfig>;
135
+ declare const schemaOrgCoursePlugin: sanity.Plugin<void | SchemaOrgConfig>;
136
+ /**
137
+ * Registers **all** Schema.org types as a single Sanity plugin.
138
+ * Includes a combined `schemaOrg` array type for multi-type fields.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * import { schemaOrg } from 'sanity-plugin-seofields/schema'
143
+ *
144
+ * export default defineConfig({
145
+ * plugins: [schemaOrg()],
146
+ * })
147
+ * ```
148
+ */
149
+ declare const schemaOrg: sanity.Plugin<void | SchemaOrgCombinedConfig>;
150
+
151
+ declare function schemaOrgAggregateRating(config?: SchemaOrgAggregateRatingConfig): SchemaTypeDefinition;
152
+
153
+ /**
154
+ * Schema.org Article — Sanity object type.
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * import { schemaOrgArticle } from 'sanity-plugin-seofields/schema/article'
159
+ *
160
+ * schemaOrgArticle()
161
+ * ```
162
+ */
163
+ declare function schemaOrgArticle(config?: SchemaOrgArticleConfig): SchemaTypeDefinition;
164
+
165
+ /**
166
+ * Schema.org BlogPosting — Sanity object type.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * import { schemaOrgBlogPosting } from 'sanity-plugin-seofields/schema/blogPosting'
171
+ *
172
+ * schemaOrgBlogPosting()
173
+ * ```
174
+ */
175
+ declare function schemaOrgBlogPosting(config?: SchemaOrgBlogPostingConfig): SchemaTypeDefinition;
176
+
177
+ declare function schemaOrgBrand(config?: SchemaOrgBrandConfig): SchemaTypeDefinition;
178
+
179
+ /**
180
+ * Schema.org BreadcrumbList — Sanity object type.
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * import { schemaOrgBreadcrumbList } from 'sanity-plugin-seofields/schema/breadcrumbList'
185
+ *
186
+ * schemaOrgBreadcrumbList()
187
+ * ```
188
+ */
189
+ declare function schemaOrgBreadcrumbList(config?: SchemaOrgBreadcrumbListConfig): SchemaTypeDefinition;
190
+
191
+ declare function schemaOrgContactPoint(config?: SchemaOrgContactPointConfig): SchemaTypeDefinition;
192
+
193
+ /**
194
+ * Schema.org Course — Sanity object type.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * import { schemaOrgCourse } from 'sanity-plugin-seofields/schema/course'
199
+ *
200
+ * // Default
201
+ * schemaOrgCourse()
202
+ *
203
+ * // Custom validation messages
204
+ * schemaOrgCourse({
205
+ * validation: { nameRequired: 'Please enter the course name.' },
206
+ * })
207
+ * ```
208
+ */
209
+ declare function schemaOrgCourse(config?: SchemaOrgCourseConfig): SchemaTypeDefinition;
210
+
211
+ declare function schemaOrgEvent(config?: SchemaOrgEventConfig): SchemaTypeDefinition;
212
+
213
+ /**
214
+ * Schema.org FAQPage — Sanity object type.
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * import { schemaOrgFAQPage } from 'sanity-plugin-seofields/schema/faqPage'
219
+ *
220
+ * schemaOrgFAQPage()
221
+ * ```
222
+ */
223
+ declare function schemaOrgFAQPage(config?: SchemaOrgFAQPageConfig): SchemaTypeDefinition;
224
+
225
+ /**
226
+ * Schema.org HowTo — Sanity object type.
227
+ *
228
+ * @example
229
+ * ```ts
230
+ * import { schemaOrgHowTo } from 'sanity-plugin-seofields/schema/howTo'
231
+ *
232
+ * schemaOrgHowTo()
233
+ * ```
234
+ */
235
+ declare function schemaOrgHowTo(config?: SchemaOrgHowToConfig): SchemaTypeDefinition;
236
+
237
+ declare function schemaOrgImageObject(config?: SchemaOrgImageObjectConfig): SchemaTypeDefinition;
238
+
239
+ declare function schemaOrgLocalBusiness(config?: SchemaOrgLocalBusinessConfig): SchemaTypeDefinition;
240
+
241
+ declare function schemaOrgOffer(config?: SchemaOrgOfferConfig): SchemaTypeDefinition;
242
+
243
+ /**
244
+ * Schema.org Organization — Sanity object type.
245
+ *
246
+ * @example
247
+ * ```ts
248
+ * import { schemaOrgOrganization } from 'sanity-plugin-seofields/schema/organization'
249
+ *
250
+ * // Default
251
+ * schemaOrgOrganization()
252
+ *
253
+ * // Custom validation messages
254
+ * schemaOrgOrganization({
255
+ * validation: { nameRequired: 'Company name is required.' },
256
+ * })
257
+ * ```
258
+ */
259
+ declare function schemaOrgOrganization(config?: SchemaOrgOrganizationConfig): SchemaTypeDefinition;
260
+
261
+ /**
262
+ * Schema.org Person — Sanity object type.
263
+ *
264
+ * @example
265
+ * ```ts
266
+ * import { schemaOrgPerson } from 'sanity-plugin-seofields/schema/person'
267
+ *
268
+ * // Default
269
+ * schemaOrgPerson()
270
+ *
271
+ * // Custom validation messages
272
+ * schemaOrgPerson({
273
+ * validation: { nameRequired: 'Please enter the person\'s name.' },
274
+ * })
275
+ * ```
276
+ */
277
+ declare function schemaOrgPerson(config?: SchemaOrgPersonConfig): SchemaTypeDefinition;
278
+
279
+ declare function schemaOrgPlace(config?: SchemaOrgPlaceConfig): SchemaTypeDefinition;
280
+
281
+ declare function schemaOrgPostalAddress(config?: SchemaOrgPostalAddressConfig): SchemaTypeDefinition;
282
+
283
+ /**
284
+ * Schema.org Product — Sanity object type.
285
+ *
286
+ * @example
287
+ * ```ts
288
+ * import { schemaOrgProduct } from 'sanity-plugin-seofields/schema/product'
289
+ *
290
+ * // Default
291
+ * schemaOrgProduct()
292
+ *
293
+ * // Custom validation messages
294
+ * schemaOrgProduct({
295
+ * validation: { nameRequired: 'Please enter the product name.' },
296
+ * })
297
+ * ```
298
+ */
299
+ declare function schemaOrgProduct(config?: SchemaOrgProductConfig): SchemaTypeDefinition;
300
+
301
+ /**
302
+ * Schema.org Review — Sanity object type.
303
+ *
304
+ * @example
305
+ * ```ts
306
+ * import { schemaOrgReview } from 'sanity-plugin-seofields/schema/review'
307
+ *
308
+ * schemaOrgReview()
309
+ * ```
310
+ */
311
+ declare function schemaOrgReview(config?: SchemaOrgReviewConfig): SchemaTypeDefinition;
312
+
313
+ /**
314
+ * Schema.org SoftwareApplication — Sanity object type.
315
+ *
316
+ * @example
317
+ * ```ts
318
+ * import { schemaOrgSoftwareApplication } from 'sanity-plugin-seofields/schema/softwareApplication'
319
+ *
320
+ * // Default
321
+ * schemaOrgSoftwareApplication()
322
+ *
323
+ * // Custom validation messages
324
+ * schemaOrgSoftwareApplication({
325
+ * validation: { nameRequired: 'Please enter the application name.' },
326
+ * })
327
+ * ```
328
+ */
329
+ declare function schemaOrgSoftwareApplication(config?: SchemaOrgSoftwareApplicationConfig): SchemaTypeDefinition;
330
+
331
+ declare function schemaOrgVideoObject(config?: SchemaOrgVideoObjectConfig): SchemaTypeDefinition;
332
+
333
+ /**
334
+ * Schema.org WebApplication — Sanity object type.
335
+ *
336
+ * @example
337
+ * ```ts
338
+ * import { schemaOrgWebApplication } from 'sanity-plugin-seofields/schema/webApplication'
339
+ *
340
+ * // Default
341
+ * schemaOrgWebApplication()
342
+ *
343
+ * // Custom validation messages
344
+ * schemaOrgWebApplication({
345
+ * validation: { nameRequired: 'Please enter the application name.' },
346
+ * })
347
+ * ```
348
+ */
349
+ declare function schemaOrgWebApplication(config?: SchemaOrgWebApplicationConfig): SchemaTypeDefinition;
350
+
351
+ /**
352
+ * Schema.org WebPage — Sanity object type.
353
+ *
354
+ * @example
355
+ * ```ts
356
+ * import { schemaOrgWebPage } from 'sanity-plugin-seofields/schema/webPage'
357
+ *
358
+ * // Default
359
+ * schemaOrgWebPage()
360
+ *
361
+ * // Custom validation messages
362
+ * schemaOrgWebPage({
363
+ * validation: { nameRequired: 'Please enter a page name.' },
364
+ * })
365
+ * ```
366
+ */
367
+ declare function schemaOrgWebPage(config?: SchemaOrgWebPageConfig): SchemaTypeDefinition;
368
+
369
+ /**
370
+ * Schema.org WebSite — Sanity object type.
371
+ *
372
+ * @example
373
+ * ```ts
374
+ * import { schemaOrgWebsite } from 'sanity-plugin-seofields/schema/website'
375
+ *
376
+ * // Default
377
+ * schemaOrgWebsite()
378
+ *
379
+ * // Custom validation messages
380
+ * schemaOrgWebsite({
381
+ * validation: { nameRequired: 'Please enter a website name.' },
382
+ * })
383
+ * ```
384
+ */
385
+ declare function schemaOrgWebsite(config?: SchemaOrgWebsiteConfig): SchemaTypeDefinition;
386
+
387
+ export { type SchemaFieldDef, type SchemaFieldOption, SchemaOrgAggregateRatingConfig, SchemaOrgArticleConfig, SchemaOrgBlogPostingConfig, SchemaOrgBrandConfig, SchemaOrgBreadcrumbListConfig, type SchemaOrgCombinedConfig, type SchemaOrgConfig, SchemaOrgContactPointConfig, SchemaOrgCourseConfig, SchemaOrgEventConfig, SchemaOrgFAQPageConfig, SchemaOrgHowToConfig, SchemaOrgImageObjectConfig, SchemaOrgLocalBusinessConfig, SchemaOrgOfferConfig, SchemaOrgOrganizationConfig, SchemaOrgPersonConfig, SchemaOrgPlaceConfig, SchemaOrgPostalAddressConfig, SchemaOrgProductConfig, SchemaOrgReviewConfig, SchemaOrgSoftwareApplicationConfig, SchemaOrgVideoObjectConfig, SchemaOrgWebApplicationConfig, SchemaOrgWebPageConfig, SchemaOrgWebsiteConfig, type SchemaTypeDef, buildGenericJsonLd, generateSchemaType, schemaOrg, schemaOrgAggregateRating, schemaOrgAggregateRatingPlugin, schemaOrgArticle, schemaOrgArticlePlugin, schemaOrgBlogPosting, schemaOrgBlogPostingPlugin, schemaOrgBrand, schemaOrgBrandPlugin, schemaOrgBreadcrumbList, schemaOrgBreadcrumbListPlugin, schemaOrgContactPoint, schemaOrgContactPointPlugin, schemaOrgCourse, schemaOrgCoursePlugin, schemaOrgEvent, schemaOrgEventPlugin, schemaOrgFAQPage, schemaOrgFAQPagePlugin, schemaOrgHowTo, schemaOrgHowToPlugin, schemaOrgImageObject, schemaOrgImageObjectPlugin, schemaOrgLocalBusiness, schemaOrgLocalBusinessPlugin, schemaOrgOffer, schemaOrgOfferPlugin, schemaOrgOrganization, schemaOrgOrganizationPlugin, schemaOrgPerson, schemaOrgPersonPlugin, schemaOrgPlace, schemaOrgPlacePlugin, schemaOrgPostalAddress, schemaOrgPostalAddressPlugin, schemaOrgProduct, schemaOrgProductPlugin, schemaOrgReview, schemaOrgReviewPlugin, schemaOrgSoftwareApplication, schemaOrgSoftwareApplicationPlugin, schemaOrgVideoObject, schemaOrgVideoObjectPlugin, schemaOrgWebApplication, schemaOrgWebApplicationPlugin, schemaOrgWebPage, schemaOrgWebPagePlugin, schemaOrgWebsite, schemaOrgWebsitePlugin };