sanity-plugin-seofields 1.0.8 → 1.0.9

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.
package/README.md CHANGED
@@ -589,21 +589,6 @@ import seofields from 'sanity-plugin-seofields'
589
589
 
590
590
  All types are exported from the main module for use in your project.
591
591
 
592
- ### Migration Utilities
593
-
594
- The plugin includes utilities for migrating existing data from old formats:
595
-
596
- ```typescript
597
- import {
598
- migrateSeoFields,
599
- generateMigrationScript,
600
- needsMigration,
601
- normalizeValue
602
- } from 'sanity-plugin-seofields'
603
- ```
604
-
605
- For detailed migration instructions, see [MIGRATION_GUIDE.md](./MIGRATION_GUIDE.md).
606
-
607
592
  ## 🤝 Contributing
608
593
 
609
594
  Contributions are welcome! Please feel free to submit a Pull Request.
package/dist/index.d.mts CHANGED
@@ -1,82 +1,14 @@
1
1
  import {ObjectDefinition} from 'sanity'
2
2
  import {Plugin as Plugin_2} from 'sanity'
3
3
  import {PreviewConfig} from 'sanity'
4
+ import {SchemaTypeDefinition} from 'sanity'
4
5
 
5
6
  export declare type AllFieldKeys = SeoFieldKeys | openGraphFieldKeys | twitterFieldKeys
6
7
 
7
- export declare function allSchemas(config?: SeoFieldsPluginConfig): (
8
- | ({
9
- type: 'object'
10
- name: 'twitter'
11
- } & Omit<ObjectDefinition, 'preview'> & {
12
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
13
- })
14
- | ({
15
- type: 'object'
16
- name: 'seoFields'
17
- } & Omit<ObjectDefinition, 'preview'> & {
18
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
19
- })
20
- | ({
21
- type: 'object'
22
- name: 'metaAttribute'
23
- } & Omit<ObjectDefinition, 'preview'> & {
24
- preview?:
25
- | PreviewConfig<
26
- {
27
- attributeName: string
28
- attributeValueString: string
29
- attributeValueImage: string
30
- },
31
- {
32
- attributeName: string
33
- attributeValueString: string
34
- attributeValueImage: any
35
- }
36
- >
37
- | undefined
38
- })
39
- | ({
40
- type: 'object'
41
- name: 'openGraph'
42
- } & Omit<ObjectDefinition, 'preview'> & {
43
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
44
- })
45
- | ({
46
- type: 'object'
47
- name: 'robots'
48
- } & Omit<ObjectDefinition, 'preview'> & {
49
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
50
- })
51
- | ({
52
- type: 'object'
53
- name: 'metaTag'
54
- } & Omit<ObjectDefinition, 'preview'> & {
55
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
56
- })
57
- )[]
58
-
59
- export declare const defaultSeoValidationRules: SeoValidationRules
8
+ export declare function allSchemas(config?: SeoFieldsPluginConfig): SchemaTypeDefinition[]
60
9
 
61
10
  export declare interface FieldVisibilityConfig {
62
- hiddenFields?: AllFieldKeys[]
63
- postType?: string
64
- }
65
-
66
- export declare const isMetaAttribute: (obj: any) => obj is MetaAttribute
67
-
68
- export declare const isOpenGraphSettings: (obj: any) => obj is OpenGraphSettings
69
-
70
- export declare const isSeoFields: (obj: any) => obj is SeoFields
71
-
72
- export declare const isTwitterCardSettings: (obj: any) => obj is TwitterCardSettings
73
-
74
- export declare interface MetaAttribute {
75
- _type: 'metaAttribute'
76
- key: string
77
- type: 'string' | 'image'
78
- value?: string
79
- image?: SanityImage
11
+ hiddenFields?: ValidHiddenFieldKeys[]
80
12
  }
81
13
 
82
14
  export declare const metaAttributeSchema: {
@@ -90,11 +22,7 @@ export declare const metaAttributeSchema: {
90
22
  attributeValueString: string
91
23
  attributeValueImage: string
92
24
  },
93
- {
94
- attributeName: string
95
- attributeValueString: string
96
- attributeValueImage: any
97
- }
25
+ Record<'attributeName' | 'attributeValueString' | 'attributeValueImage', any>
98
26
  >
99
27
  | undefined
100
28
  }
@@ -116,23 +44,7 @@ export declare type openGraphFieldKeys =
116
44
  | 'openGraphImage'
117
45
  | 'openGraphImageUrl'
118
46
 
119
- export declare function openGraphSchema(config?: SeoFieldsPluginConfig): {
120
- type: 'object'
121
- name: 'openGraph'
122
- } & Omit<ObjectDefinition, 'preview'> & {
123
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
124
- }
125
-
126
- export declare interface OpenGraphSettings {
127
- _type: 'openGraph'
128
- title?: string
129
- description?: string
130
- siteName?: string
131
- type?: 'website' | 'article' | 'profile' | 'book' | 'music' | 'video' | 'product'
132
- imageType?: 'upload' | 'url'
133
- image?: SanityImageWithAlt
134
- imageUrl?: string
135
- }
47
+ export declare function openGraphSchema(config?: SeoFieldsPluginConfig): SchemaTypeDefinition
136
48
 
137
49
  export declare const robotsSchema: {
138
50
  type: 'object'
@@ -141,36 +53,6 @@ export declare const robotsSchema: {
141
53
  preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
142
54
  }
143
55
 
144
- export declare interface RobotsSettings {
145
- noIndex?: boolean
146
- noFollow?: boolean
147
- }
148
-
149
- export declare interface SanityImage {
150
- _type: 'image'
151
- asset: {
152
- _ref: string
153
- _type: 'reference'
154
- }
155
- hotspot?: {
156
- x: number
157
- y: number
158
- height: number
159
- width: number
160
- }
161
- crop?: {
162
- top: number
163
- bottom: number
164
- left: number
165
- right: number
166
- }
167
- alt?: string
168
- }
169
-
170
- export declare interface SanityImageWithAlt extends SanityImage {
171
- alt: string
172
- }
173
-
174
56
  export declare interface SeoFieldConfig {
175
57
  title?: string
176
58
  description?: string
@@ -185,19 +67,6 @@ export declare type SeoFieldKeys =
185
67
  | 'metaAttributes'
186
68
  | 'robots'
187
69
 
188
- export declare interface SeoFields {
189
- _type: 'seoFields'
190
- robots?: RobotsSettings
191
- preview?: string
192
- title?: string
193
- description?: string
194
- metaImage?: SanityImage
195
- keywords?: string[]
196
- canonicalUrl?: string
197
- openGraph?: OpenGraphSettings
198
- twitter?: TwitterCardSettings
199
- }
200
-
201
70
  declare const seofields: Plugin_2<void | SeoFieldsPluginConfig>
202
71
  export default seofields
203
72
 
@@ -228,21 +97,17 @@ export declare interface SeoFieldsPluginConfig {
228
97
  * This allows customization of field titles and descriptions.
229
98
  * For example, to change the title of the 'title' field:
230
99
  */
231
- fieldOverrides?: {
232
- [key in AllFieldKeys]?: SeoFieldConfig
233
- }
100
+ fieldOverrides?: Partial<Record<AllFieldKeys, SeoFieldConfig>>
234
101
  /**
235
102
  * A mapping of document types to field visibility configurations.
236
103
  * This allows you to specify which fields should be hidden for specific document types.
237
104
  */
238
- fieldVisibility?: {
239
- [postType: string]: FieldVisibilityConfig
240
- }
105
+ fieldVisibility?: Record<string, FieldVisibilityConfig>
241
106
  /**
242
107
  * A list of fields that should be hidden by default in all document types.
243
108
  * This can be overridden by specific document type settings in `fieldVisibility`.
244
109
  */
245
- defaultHiddenFields?: AllFieldKeys[]
110
+ defaultHiddenFields?: ValidHiddenFieldKeys[]
246
111
  /**
247
112
  * The base URL of your website, used for generating full URLs in the SEO preview.
248
113
  * Defaults to 'https://www.example.com' if not provided.
@@ -250,46 +115,7 @@ export declare interface SeoFieldsPluginConfig {
250
115
  baseUrl?: string
251
116
  }
252
117
 
253
- export declare function seoFieldsSchema(config?: SeoFieldsPluginConfig): {
254
- type: 'object'
255
- name: 'seoFields'
256
- } & Omit<ObjectDefinition, 'preview'> & {
257
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
258
- }
259
-
260
- export declare interface SeoValidationRules {
261
- title: {
262
- maxLength: number
263
- warningLength: number
264
- }
265
- description: {
266
- maxLength: number
267
- warningLength: number
268
- }
269
- openGraphTitle: {
270
- maxLength: number
271
- }
272
- openGraphDescription: {
273
- maxLength: number
274
- }
275
- twitterTitle: {
276
- maxLength: number
277
- }
278
- twitterDescription: {
279
- maxLength: number
280
- }
281
- }
282
-
283
- export declare interface TwitterCardSettings {
284
- _type: 'twitter'
285
- card?: 'summary' | 'summary_large_image' | 'app' | 'player'
286
- site?: string
287
- title?: string
288
- description?: string
289
- imageType?: 'upload' | 'url'
290
- image?: SanityImageWithAlt
291
- imageUrl?: string
292
- }
118
+ export declare function seoFieldsSchema(config?: SeoFieldsPluginConfig): SchemaTypeDefinition
293
119
 
294
120
  export declare type twitterFieldKeys =
295
121
  | 'twitterCard'
@@ -301,11 +127,11 @@ export declare type twitterFieldKeys =
301
127
  | 'twitterImage'
302
128
  | 'twitterImageUrl'
303
129
 
304
- export declare function twitterSchema(config?: SeoFieldsPluginConfig): {
305
- type: 'object'
306
- name: 'twitter'
307
- } & Omit<ObjectDefinition, 'preview'> & {
308
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
309
- }
130
+ export declare function twitterSchema(config?: SeoFieldsPluginConfig): SchemaTypeDefinition
131
+
132
+ export declare type ValidHiddenFieldKeys = Exclude<
133
+ AllFieldKeys,
134
+ 'openGraphImageUrl' | 'twitterImageUrl' | 'openGraphImageType' | 'twitterImageType'
135
+ >
310
136
 
311
137
  export {}
package/dist/index.d.ts CHANGED
@@ -1,82 +1,14 @@
1
1
  import {ObjectDefinition} from 'sanity'
2
2
  import {Plugin as Plugin_2} from 'sanity'
3
3
  import {PreviewConfig} from 'sanity'
4
+ import {SchemaTypeDefinition} from 'sanity'
4
5
 
5
6
  export declare type AllFieldKeys = SeoFieldKeys | openGraphFieldKeys | twitterFieldKeys
6
7
 
7
- export declare function allSchemas(config?: SeoFieldsPluginConfig): (
8
- | ({
9
- type: 'object'
10
- name: 'twitter'
11
- } & Omit<ObjectDefinition, 'preview'> & {
12
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
13
- })
14
- | ({
15
- type: 'object'
16
- name: 'seoFields'
17
- } & Omit<ObjectDefinition, 'preview'> & {
18
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
19
- })
20
- | ({
21
- type: 'object'
22
- name: 'metaAttribute'
23
- } & Omit<ObjectDefinition, 'preview'> & {
24
- preview?:
25
- | PreviewConfig<
26
- {
27
- attributeName: string
28
- attributeValueString: string
29
- attributeValueImage: string
30
- },
31
- {
32
- attributeName: string
33
- attributeValueString: string
34
- attributeValueImage: any
35
- }
36
- >
37
- | undefined
38
- })
39
- | ({
40
- type: 'object'
41
- name: 'openGraph'
42
- } & Omit<ObjectDefinition, 'preview'> & {
43
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
44
- })
45
- | ({
46
- type: 'object'
47
- name: 'robots'
48
- } & Omit<ObjectDefinition, 'preview'> & {
49
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
50
- })
51
- | ({
52
- type: 'object'
53
- name: 'metaTag'
54
- } & Omit<ObjectDefinition, 'preview'> & {
55
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
56
- })
57
- )[]
58
-
59
- export declare const defaultSeoValidationRules: SeoValidationRules
8
+ export declare function allSchemas(config?: SeoFieldsPluginConfig): SchemaTypeDefinition[]
60
9
 
61
10
  export declare interface FieldVisibilityConfig {
62
- hiddenFields?: AllFieldKeys[]
63
- postType?: string
64
- }
65
-
66
- export declare const isMetaAttribute: (obj: any) => obj is MetaAttribute
67
-
68
- export declare const isOpenGraphSettings: (obj: any) => obj is OpenGraphSettings
69
-
70
- export declare const isSeoFields: (obj: any) => obj is SeoFields
71
-
72
- export declare const isTwitterCardSettings: (obj: any) => obj is TwitterCardSettings
73
-
74
- export declare interface MetaAttribute {
75
- _type: 'metaAttribute'
76
- key: string
77
- type: 'string' | 'image'
78
- value?: string
79
- image?: SanityImage
11
+ hiddenFields?: ValidHiddenFieldKeys[]
80
12
  }
81
13
 
82
14
  export declare const metaAttributeSchema: {
@@ -90,11 +22,7 @@ export declare const metaAttributeSchema: {
90
22
  attributeValueString: string
91
23
  attributeValueImage: string
92
24
  },
93
- {
94
- attributeName: string
95
- attributeValueString: string
96
- attributeValueImage: any
97
- }
25
+ Record<'attributeName' | 'attributeValueString' | 'attributeValueImage', any>
98
26
  >
99
27
  | undefined
100
28
  }
@@ -116,23 +44,7 @@ export declare type openGraphFieldKeys =
116
44
  | 'openGraphImage'
117
45
  | 'openGraphImageUrl'
118
46
 
119
- export declare function openGraphSchema(config?: SeoFieldsPluginConfig): {
120
- type: 'object'
121
- name: 'openGraph'
122
- } & Omit<ObjectDefinition, 'preview'> & {
123
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
124
- }
125
-
126
- export declare interface OpenGraphSettings {
127
- _type: 'openGraph'
128
- title?: string
129
- description?: string
130
- siteName?: string
131
- type?: 'website' | 'article' | 'profile' | 'book' | 'music' | 'video' | 'product'
132
- imageType?: 'upload' | 'url'
133
- image?: SanityImageWithAlt
134
- imageUrl?: string
135
- }
47
+ export declare function openGraphSchema(config?: SeoFieldsPluginConfig): SchemaTypeDefinition
136
48
 
137
49
  export declare const robotsSchema: {
138
50
  type: 'object'
@@ -141,36 +53,6 @@ export declare const robotsSchema: {
141
53
  preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
142
54
  }
143
55
 
144
- export declare interface RobotsSettings {
145
- noIndex?: boolean
146
- noFollow?: boolean
147
- }
148
-
149
- export declare interface SanityImage {
150
- _type: 'image'
151
- asset: {
152
- _ref: string
153
- _type: 'reference'
154
- }
155
- hotspot?: {
156
- x: number
157
- y: number
158
- height: number
159
- width: number
160
- }
161
- crop?: {
162
- top: number
163
- bottom: number
164
- left: number
165
- right: number
166
- }
167
- alt?: string
168
- }
169
-
170
- export declare interface SanityImageWithAlt extends SanityImage {
171
- alt: string
172
- }
173
-
174
56
  export declare interface SeoFieldConfig {
175
57
  title?: string
176
58
  description?: string
@@ -185,19 +67,6 @@ export declare type SeoFieldKeys =
185
67
  | 'metaAttributes'
186
68
  | 'robots'
187
69
 
188
- export declare interface SeoFields {
189
- _type: 'seoFields'
190
- robots?: RobotsSettings
191
- preview?: string
192
- title?: string
193
- description?: string
194
- metaImage?: SanityImage
195
- keywords?: string[]
196
- canonicalUrl?: string
197
- openGraph?: OpenGraphSettings
198
- twitter?: TwitterCardSettings
199
- }
200
-
201
70
  declare const seofields: Plugin_2<void | SeoFieldsPluginConfig>
202
71
  export default seofields
203
72
 
@@ -228,21 +97,17 @@ export declare interface SeoFieldsPluginConfig {
228
97
  * This allows customization of field titles and descriptions.
229
98
  * For example, to change the title of the 'title' field:
230
99
  */
231
- fieldOverrides?: {
232
- [key in AllFieldKeys]?: SeoFieldConfig
233
- }
100
+ fieldOverrides?: Partial<Record<AllFieldKeys, SeoFieldConfig>>
234
101
  /**
235
102
  * A mapping of document types to field visibility configurations.
236
103
  * This allows you to specify which fields should be hidden for specific document types.
237
104
  */
238
- fieldVisibility?: {
239
- [postType: string]: FieldVisibilityConfig
240
- }
105
+ fieldVisibility?: Record<string, FieldVisibilityConfig>
241
106
  /**
242
107
  * A list of fields that should be hidden by default in all document types.
243
108
  * This can be overridden by specific document type settings in `fieldVisibility`.
244
109
  */
245
- defaultHiddenFields?: AllFieldKeys[]
110
+ defaultHiddenFields?: ValidHiddenFieldKeys[]
246
111
  /**
247
112
  * The base URL of your website, used for generating full URLs in the SEO preview.
248
113
  * Defaults to 'https://www.example.com' if not provided.
@@ -250,46 +115,7 @@ export declare interface SeoFieldsPluginConfig {
250
115
  baseUrl?: string
251
116
  }
252
117
 
253
- export declare function seoFieldsSchema(config?: SeoFieldsPluginConfig): {
254
- type: 'object'
255
- name: 'seoFields'
256
- } & Omit<ObjectDefinition, 'preview'> & {
257
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
258
- }
259
-
260
- export declare interface SeoValidationRules {
261
- title: {
262
- maxLength: number
263
- warningLength: number
264
- }
265
- description: {
266
- maxLength: number
267
- warningLength: number
268
- }
269
- openGraphTitle: {
270
- maxLength: number
271
- }
272
- openGraphDescription: {
273
- maxLength: number
274
- }
275
- twitterTitle: {
276
- maxLength: number
277
- }
278
- twitterDescription: {
279
- maxLength: number
280
- }
281
- }
282
-
283
- export declare interface TwitterCardSettings {
284
- _type: 'twitter'
285
- card?: 'summary' | 'summary_large_image' | 'app' | 'player'
286
- site?: string
287
- title?: string
288
- description?: string
289
- imageType?: 'upload' | 'url'
290
- image?: SanityImageWithAlt
291
- imageUrl?: string
292
- }
118
+ export declare function seoFieldsSchema(config?: SeoFieldsPluginConfig): SchemaTypeDefinition
293
119
 
294
120
  export declare type twitterFieldKeys =
295
121
  | 'twitterCard'
@@ -301,11 +127,11 @@ export declare type twitterFieldKeys =
301
127
  | 'twitterImage'
302
128
  | 'twitterImageUrl'
303
129
 
304
- export declare function twitterSchema(config?: SeoFieldsPluginConfig): {
305
- type: 'object'
306
- name: 'twitter'
307
- } & Omit<ObjectDefinition, 'preview'> & {
308
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
309
- }
130
+ export declare function twitterSchema(config?: SeoFieldsPluginConfig): SchemaTypeDefinition
131
+
132
+ export declare type ValidHiddenFieldKeys = Exclude<
133
+ AllFieldKeys,
134
+ 'openGraphImageUrl' | 'twitterImageUrl' | 'openGraphImageType' | 'twitterImageType'
135
+ >
310
136
 
311
137
  export {}