sanity-plugin-seofields 1.0.1 → 1.0.2

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
@@ -37,7 +37,7 @@ Add the plugin to your `sanity.config.ts` (or `.js`) file:
37
37
 
38
38
  ```typescript
39
39
  import {defineConfig} from 'sanity'
40
- import {seofields} from 'sanity-plugin-seofields'
40
+ import seofields from 'sanity-plugin-seofields'
41
41
 
42
42
  export default defineConfig({
43
43
  name: 'your-project',
@@ -140,17 +140,69 @@ export default defineType({
140
140
  ### Basic Configuration
141
141
 
142
142
  ```typescript
143
- import {seofields} from 'sanity-plugin-seofields'
143
+ import seofields from 'sanity-plugin-seofields'
144
+
145
+ export default defineConfig({
146
+ plugins: [
147
+ seofields(), // Use default configuration
148
+ ],
149
+ })
150
+ ```
151
+
152
+ ### Advanced Configuration
153
+
154
+ You can customize field titles and descriptions, and control SEO preview functionality:
155
+
156
+ ```typescript
157
+ import seofields, {SeoFieldsPluginConfig} from 'sanity-plugin-seofields'
144
158
 
145
159
  export default defineConfig({
146
160
  plugins: [
147
161
  seofields({
148
- // Plugin options (none required currently)
149
- }),
162
+ seoPreview: true, // Enable/disable SEO preview (default: true)
163
+ fieldOverrides: {
164
+ title: {
165
+ title: 'Page Title',
166
+ description: 'The main title that appears in search results',
167
+ },
168
+ description: {
169
+ title: 'Meta Description',
170
+ description: 'A brief description of the page content for search engines',
171
+ },
172
+ canonicalUrl: {
173
+ title: 'Canonical URL',
174
+ description: 'The preferred URL for this page to avoid duplicate content issues',
175
+ },
176
+ metaImage: {
177
+ title: 'Social Media Image',
178
+ description: 'Image used when sharing this page on social media',
179
+ },
180
+ keywords: {
181
+ title: 'SEO Keywords',
182
+ description: 'Keywords that describe the content of this page',
183
+ },
184
+ },
185
+ } satisfies SeoFieldsPluginConfig),
150
186
  ],
151
187
  })
152
188
  ```
153
189
 
190
+ ### Configuration Options
191
+
192
+ | Option | Type | Default | Description |
193
+ | ---------------- | --------- | ------- | ------------------------------------------- |
194
+ | `seoPreview` | `boolean` | `true` | Enable/disable the live SEO preview feature |
195
+ | `fieldOverrides` | `object` | `{}` | Customize field titles and descriptions |
196
+
197
+ #### Field Configuration
198
+
199
+ Each field in the `fieldOverrides` object can have:
200
+
201
+ - `title` - Custom title for the field
202
+ - `description` - Custom description/help text for the field
203
+
204
+ Available field keys: `title`, `description`, `canonicalUrl`, `metaImage`, `keywords`
205
+
154
206
  ### Field Specifications
155
207
 
156
208
  #### Meta Title
@@ -183,7 +235,27 @@ export default defineConfig({
183
235
  The plugin includes full TypeScript support:
184
236
 
185
237
  ```typescript
186
- import type {SeoFields, OpenGraphSettings, TwitterCardSettings} from 'sanity-plugin-seofields'
238
+ import type {
239
+ SeoFields,
240
+ OpenGraphSettings,
241
+ TwitterCardSettings,
242
+ SeoFieldsPluginConfig,
243
+ } from 'sanity-plugin-seofields'
244
+
245
+ // Plugin configuration
246
+ const pluginConfig: SeoFieldsPluginConfig = {
247
+ seoPreview: true,
248
+ fields: {
249
+ title: {
250
+ title: 'Page Title',
251
+ description: 'The main title for search engines',
252
+ },
253
+ description: {
254
+ title: 'Meta Description',
255
+ description: 'Brief description for search results',
256
+ },
257
+ },
258
+ }
187
259
 
188
260
  // Use in your document interfaces
189
261
  interface PageDocument {
@@ -211,6 +283,9 @@ const seoData: SeoFields = {
211
283
  ```typescript
212
284
  import type {
213
285
  SeoFields,
286
+ SeoFieldsPluginConfig,
287
+ SeoField,
288
+ SeoFieldKeys,
214
289
  OpenGraphSettings,
215
290
  TwitterCardSettings,
216
291
  MetaAttribute,
@@ -338,7 +413,7 @@ export function SEO({seo}: SEOProps) {
338
413
  ### Main Export
339
414
 
340
415
  ```typescript
341
- import {seofields} from 'sanity-plugin-seofields'
416
+ import seofields from 'sanity-plugin-seofields'
342
417
  ```
343
418
 
344
419
  ### Schema Types
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import {ObjectDefinition} from 'sanity'
2
2
  import {Plugin as Plugin_2} from 'sanity'
3
3
  import {PreviewConfig} from 'sanity'
4
4
 
5
- export declare const allSchemas: (
5
+ export declare function allSchemas(config?: SeoFieldsPluginConfig): (
6
6
  | ({
7
7
  type: 'object'
8
8
  name: 'seoFields'
@@ -99,8 +99,6 @@ export declare const metaTagSchema: {
99
99
  preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
100
100
  }
101
101
 
102
- declare interface MyPluginConfig {}
103
-
104
102
  export declare const openGraphSchema: {
105
103
  type: 'object'
106
104
  name: 'openGraph'
@@ -119,6 +117,13 @@ export declare interface OpenGraphSettings {
119
117
  imageUrl?: string
120
118
  }
121
119
 
120
+ export declare const robotsSchema: {
121
+ type: 'object'
122
+ name: 'robots'
123
+ } & Omit<ObjectDefinition, 'preview'> & {
124
+ preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
125
+ }
126
+
122
127
  export declare interface RobotsSettings {
123
128
  noIndex?: boolean
124
129
  noFollow?: boolean
@@ -149,6 +154,18 @@ export declare interface SanityImageWithAlt extends SanityImage {
149
154
  alt: string
150
155
  }
151
156
 
157
+ export declare interface SeoField {
158
+ title?: string
159
+ description?: string
160
+ }
161
+
162
+ export declare type SeoFieldKeys =
163
+ | 'title'
164
+ | 'description'
165
+ | 'canonicalUrl'
166
+ | 'metaImage'
167
+ | 'keywords'
168
+
152
169
  export declare interface SeoFields {
153
170
  _type: 'seoFields'
154
171
  robots?: RobotsSettings
@@ -162,22 +179,17 @@ export declare interface SeoFields {
162
179
  twitter?: TwitterCardSettings
163
180
  }
164
181
 
165
- /**
166
- * Usage in `sanity.config.ts` (or .js)
167
- *
168
- * ```ts
169
- * import {defineConfig} from 'sanity'
170
- * import {myPlugin} from 'sanity-plugin-seofields'
171
- *
172
- * export default defineConfig({
173
- * // ...
174
- * plugins: [seofields()],
175
- * })
176
- * ```
177
- */
178
- export declare const seofields: Plugin_2<void | MyPluginConfig>
179
-
180
- export declare const seoFieldsSchema: {
182
+ declare const seofields: Plugin_2<void | SeoFieldsPluginConfig>
183
+ export default seofields
184
+
185
+ export declare interface SeoFieldsPluginConfig {
186
+ seoPreview?: boolean
187
+ fieldOverrides?: {
188
+ [key in SeoFieldKeys]?: SeoField
189
+ }
190
+ }
191
+
192
+ export declare function seoFieldsSchema(config?: SeoFieldsPluginConfig): {
181
193
  type: 'object'
182
194
  name: 'seoFields'
183
195
  } & Omit<ObjectDefinition, 'preview'> & {
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import {ObjectDefinition} from 'sanity'
2
2
  import {Plugin as Plugin_2} from 'sanity'
3
3
  import {PreviewConfig} from 'sanity'
4
4
 
5
- export declare const allSchemas: (
5
+ export declare function allSchemas(config?: SeoFieldsPluginConfig): (
6
6
  | ({
7
7
  type: 'object'
8
8
  name: 'seoFields'
@@ -99,8 +99,6 @@ export declare const metaTagSchema: {
99
99
  preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
100
100
  }
101
101
 
102
- declare interface MyPluginConfig {}
103
-
104
102
  export declare const openGraphSchema: {
105
103
  type: 'object'
106
104
  name: 'openGraph'
@@ -119,6 +117,13 @@ export declare interface OpenGraphSettings {
119
117
  imageUrl?: string
120
118
  }
121
119
 
120
+ export declare const robotsSchema: {
121
+ type: 'object'
122
+ name: 'robots'
123
+ } & Omit<ObjectDefinition, 'preview'> & {
124
+ preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
125
+ }
126
+
122
127
  export declare interface RobotsSettings {
123
128
  noIndex?: boolean
124
129
  noFollow?: boolean
@@ -149,6 +154,18 @@ export declare interface SanityImageWithAlt extends SanityImage {
149
154
  alt: string
150
155
  }
151
156
 
157
+ export declare interface SeoField {
158
+ title?: string
159
+ description?: string
160
+ }
161
+
162
+ export declare type SeoFieldKeys =
163
+ | 'title'
164
+ | 'description'
165
+ | 'canonicalUrl'
166
+ | 'metaImage'
167
+ | 'keywords'
168
+
152
169
  export declare interface SeoFields {
153
170
  _type: 'seoFields'
154
171
  robots?: RobotsSettings
@@ -162,22 +179,17 @@ export declare interface SeoFields {
162
179
  twitter?: TwitterCardSettings
163
180
  }
164
181
 
165
- /**
166
- * Usage in `sanity.config.ts` (or .js)
167
- *
168
- * ```ts
169
- * import {defineConfig} from 'sanity'
170
- * import {myPlugin} from 'sanity-plugin-seofields'
171
- *
172
- * export default defineConfig({
173
- * // ...
174
- * plugins: [seofields()],
175
- * })
176
- * ```
177
- */
178
- export declare const seofields: Plugin_2<void | MyPluginConfig>
179
-
180
- export declare const seoFieldsSchema: {
182
+ declare const seofields: Plugin_2<void | SeoFieldsPluginConfig>
183
+ export default seofields
184
+
185
+ export declare interface SeoFieldsPluginConfig {
186
+ seoPreview?: boolean
187
+ fieldOverrides?: {
188
+ [key in SeoFieldKeys]?: SeoField
189
+ }
190
+ }
191
+
192
+ export declare function seoFieldsSchema(config?: SeoFieldsPluginConfig): {
181
193
  type: 'object'
182
194
  name: 'seoFields'
183
195
  } & Omit<ObjectDefinition, 'preview'> & {