@payloadcms/plugin-seo 3.0.0-beta.11 → 3.0.0-beta.110
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/dist/defaults.js.map +1 -1
- package/dist/exports/client.d.ts +6 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +7 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/fields.d.ts +6 -0
- package/dist/exports/fields.d.ts.map +1 -0
- package/dist/exports/fields.js +7 -0
- package/dist/exports/fields.js.map +1 -0
- package/dist/exports/types.d.ts +2 -0
- package/dist/exports/types.d.ts.map +1 -0
- package/dist/exports/types.js +3 -0
- package/dist/exports/types.js.map +1 -0
- package/dist/fields/MetaDescription/MetaDescriptionComponent.d.ts +8 -0
- package/dist/fields/MetaDescription/MetaDescriptionComponent.d.ts.map +1 -0
- package/dist/fields/MetaDescription/MetaDescriptionComponent.js +152 -0
- package/dist/fields/MetaDescription/MetaDescriptionComponent.js.map +1 -0
- package/dist/fields/MetaDescription/index.d.ts +12 -0
- package/dist/fields/MetaDescription/index.d.ts.map +1 -0
- package/dist/fields/MetaDescription/index.js +20 -0
- package/dist/fields/MetaDescription/index.js.map +1 -0
- package/dist/fields/MetaImage/MetaImageComponent.d.ts +8 -0
- package/dist/fields/MetaImage/MetaImageComponent.d.ts.map +1 -0
- package/dist/fields/MetaImage/MetaImageComponent.js +160 -0
- package/dist/fields/MetaImage/MetaImageComponent.js.map +1 -0
- package/dist/fields/MetaImage/index.d.ts +13 -0
- package/dist/fields/MetaImage/index.d.ts.map +1 -0
- package/dist/fields/MetaImage/index.js +23 -0
- package/dist/fields/MetaImage/index.js.map +1 -0
- package/dist/fields/MetaTitle/MetaTitleComponent.d.ts +9 -0
- package/dist/fields/MetaTitle/MetaTitleComponent.d.ts.map +1 -0
- package/dist/fields/MetaTitle/MetaTitleComponent.js +154 -0
- package/dist/fields/MetaTitle/MetaTitleComponent.js.map +1 -0
- package/dist/fields/MetaTitle/index.d.ts +12 -0
- package/dist/fields/MetaTitle/index.d.ts.map +1 -0
- package/dist/fields/MetaTitle/index.js +20 -0
- package/dist/fields/MetaTitle/index.js.map +1 -0
- package/dist/fields/Overview/OverviewComponent.d.ts +10 -0
- package/dist/fields/Overview/OverviewComponent.d.ts.map +1 -0
- package/dist/fields/Overview/OverviewComponent.js +60 -0
- package/dist/fields/Overview/OverviewComponent.js.map +1 -0
- package/dist/fields/Overview/index.d.ts +26 -0
- package/dist/fields/Overview/index.d.ts.map +1 -0
- package/dist/fields/Overview/index.js +22 -0
- package/dist/fields/Overview/index.js.map +1 -0
- package/dist/fields/Preview/PreviewComponent.d.ts +10 -0
- package/dist/fields/Preview/PreviewComponent.d.ts.map +1 -0
- package/dist/fields/Preview/PreviewComponent.js +111 -0
- package/dist/fields/Preview/PreviewComponent.js.map +1 -0
- package/dist/fields/Preview/index.d.ts +24 -0
- package/dist/fields/Preview/index.d.ts.map +1 -0
- package/dist/fields/Preview/index.js +22 -0
- package/dist/fields/Preview/index.js.map +1 -0
- package/dist/fields/index.scss +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -89
- package/dist/index.js.map +1 -1
- package/dist/translations/en.d.ts +3 -0
- package/dist/translations/en.d.ts.map +1 -0
- package/dist/translations/en.js +25 -0
- package/dist/translations/en.js.map +1 -0
- package/dist/translations/es.d.ts +3 -0
- package/dist/translations/es.d.ts.map +1 -0
- package/dist/translations/es.js +25 -0
- package/dist/translations/es.js.map +1 -0
- package/dist/translations/fa.d.ts +3 -0
- package/dist/translations/fa.d.ts.map +1 -0
- package/dist/translations/fa.js +25 -0
- package/dist/translations/fa.js.map +1 -0
- package/dist/translations/fr.d.ts +3 -0
- package/dist/translations/fr.d.ts.map +1 -0
- package/dist/translations/fr.js +25 -0
- package/dist/translations/fr.js.map +1 -0
- package/dist/translations/index.d.ts +12 -132
- package/dist/translations/index.d.ts.map +1 -1
- package/dist/translations/index.js +18 -132
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/it.d.ts +3 -0
- package/dist/translations/it.d.ts.map +1 -0
- package/dist/translations/it.js +25 -0
- package/dist/translations/it.js.map +1 -0
- package/dist/translations/nb.d.ts +3 -0
- package/dist/translations/nb.d.ts.map +1 -0
- package/dist/translations/nb.js +25 -0
- package/dist/translations/nb.js.map +1 -0
- package/dist/translations/pl.d.ts +3 -0
- package/dist/translations/pl.d.ts.map +1 -0
- package/dist/translations/pl.js +25 -0
- package/dist/translations/pl.js.map +1 -0
- package/dist/translations/ru.d.ts +3 -0
- package/dist/translations/ru.d.ts.map +1 -0
- package/dist/translations/ru.js +25 -0
- package/dist/translations/ru.js.map +1 -0
- package/dist/translations/translation-schema.json +5 -1
- package/dist/translations/uk.d.ts +3 -0
- package/dist/translations/uk.d.ts.map +1 -0
- package/dist/translations/uk.js +25 -0
- package/dist/translations/uk.js.map +1 -0
- package/dist/translations/vi.d.ts +3 -0
- package/dist/translations/vi.d.ts.map +1 -0
- package/dist/translations/vi.js +25 -0
- package/dist/translations/vi.js.map +1 -0
- package/dist/types.d.ts +27 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/ui/LengthIndicator.d.ts.map +1 -1
- package/dist/ui/LengthIndicator.js +63 -42
- package/dist/ui/LengthIndicator.js.map +1 -1
- package/dist/ui/Pill.js +7 -3
- package/dist/ui/Pill.js.map +1 -1
- package/package.json +56 -37
- package/dist/fields/MetaDescription.d.ts +0 -9
- package/dist/fields/MetaDescription.d.ts.map +0 -1
- package/dist/fields/MetaDescription.js +0 -115
- package/dist/fields/MetaDescription.js.map +0 -1
- package/dist/fields/MetaImage.d.ts +0 -8
- package/dist/fields/MetaImage.d.ts.map +0 -1
- package/dist/fields/MetaImage.js +0 -119
- package/dist/fields/MetaImage.js.map +0 -1
- package/dist/fields/MetaTitle.d.ts +0 -9
- package/dist/fields/MetaTitle.d.ts.map +0 -1
- package/dist/fields/MetaTitle.js +0 -116
- package/dist/fields/MetaTitle.js.map +0 -1
- package/dist/translations/en.json +0 -22
- package/dist/translations/es.json +0 -22
- package/dist/translations/fa.json +0 -22
- package/dist/translations/fr.json +0 -22
- package/dist/translations/pl.json +0 -22
- package/dist/ui/Overview.d.ts +0 -3
- package/dist/ui/Overview.d.ts.map +0 -1
- package/dist/ui/Overview.js +0 -51
- package/dist/ui/Overview.js.map +0 -1
- package/dist/ui/Preview.d.ts +0 -8
- package/dist/ui/Preview.d.ts.map +0 -1
- package/dist/ui/Preview.js +0 -79
- package/dist/ui/Preview.js.map +0 -1
- package/src/index.tsx +0 -296
- package/types.d.ts +0 -1
- package/types.js +0 -1
package/src/index.tsx
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import type { Config } from 'payload/config'
|
|
2
|
-
import type { Field, GroupField, TabsField, TextField } from 'payload/types'
|
|
3
|
-
|
|
4
|
-
import { deepMerge } from 'payload/utilities'
|
|
5
|
-
import React from 'react'
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
GenerateDescription,
|
|
9
|
-
GenerateImage,
|
|
10
|
-
GenerateTitle,
|
|
11
|
-
GenerateURL,
|
|
12
|
-
PluginConfig,
|
|
13
|
-
} from './types.js'
|
|
14
|
-
|
|
15
|
-
import { MetaDescription } from './fields/MetaDescription.js'
|
|
16
|
-
import { MetaImage } from './fields/MetaImage.js'
|
|
17
|
-
import { MetaTitle } from './fields/MetaTitle.js'
|
|
18
|
-
import { translations } from './translations/index.js'
|
|
19
|
-
import { Overview } from './ui/Overview.js'
|
|
20
|
-
import { Preview } from './ui/Preview.js'
|
|
21
|
-
|
|
22
|
-
const seo =
|
|
23
|
-
(pluginConfig: PluginConfig) =>
|
|
24
|
-
(config: Config): Config => {
|
|
25
|
-
const seoFields: GroupField[] = [
|
|
26
|
-
{
|
|
27
|
-
name: 'meta',
|
|
28
|
-
type: 'group',
|
|
29
|
-
fields: [
|
|
30
|
-
{
|
|
31
|
-
name: 'overview',
|
|
32
|
-
type: 'ui',
|
|
33
|
-
admin: {
|
|
34
|
-
components: {
|
|
35
|
-
Field: Overview,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
label: 'Overview',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: 'title',
|
|
42
|
-
type: 'text',
|
|
43
|
-
admin: {
|
|
44
|
-
components: {
|
|
45
|
-
Field: (props) => (
|
|
46
|
-
<MetaTitle
|
|
47
|
-
{...props}
|
|
48
|
-
hasGenerateTitleFn={typeof pluginConfig?.generateTitle === 'function'}
|
|
49
|
-
/>
|
|
50
|
-
),
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
localized: true,
|
|
54
|
-
...((pluginConfig?.fieldOverrides?.title as unknown as TextField) ?? {}),
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'description',
|
|
58
|
-
type: 'textarea',
|
|
59
|
-
admin: {
|
|
60
|
-
components: {
|
|
61
|
-
Field: (props) => (
|
|
62
|
-
<MetaDescription
|
|
63
|
-
{...props}
|
|
64
|
-
hasGenerateDescriptionFn={
|
|
65
|
-
typeof pluginConfig?.generateDescription === 'function'
|
|
66
|
-
}
|
|
67
|
-
/>
|
|
68
|
-
),
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
localized: true,
|
|
72
|
-
...(pluginConfig?.fieldOverrides?.description ?? {}),
|
|
73
|
-
},
|
|
74
|
-
...(pluginConfig?.uploadsCollection
|
|
75
|
-
? [
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
77
|
-
{
|
|
78
|
-
name: 'image',
|
|
79
|
-
type: 'upload',
|
|
80
|
-
admin: {
|
|
81
|
-
components: {
|
|
82
|
-
Field: (props) => (
|
|
83
|
-
<MetaImage
|
|
84
|
-
{...props}
|
|
85
|
-
hasGenerateImageFn={typeof pluginConfig?.generateImage === 'function'}
|
|
86
|
-
/>
|
|
87
|
-
),
|
|
88
|
-
},
|
|
89
|
-
description:
|
|
90
|
-
'Maximum upload file size: 12MB. Recommended file size for images is <500KB.',
|
|
91
|
-
},
|
|
92
|
-
label: 'Meta Image',
|
|
93
|
-
localized: true,
|
|
94
|
-
relationTo: pluginConfig?.uploadsCollection,
|
|
95
|
-
...(pluginConfig?.fieldOverrides?.image ?? {}),
|
|
96
|
-
} as Field,
|
|
97
|
-
]
|
|
98
|
-
: []),
|
|
99
|
-
...(pluginConfig?.fields || []),
|
|
100
|
-
{
|
|
101
|
-
name: 'preview',
|
|
102
|
-
type: 'ui',
|
|
103
|
-
admin: {
|
|
104
|
-
components: {
|
|
105
|
-
Field: (props) => (
|
|
106
|
-
<Preview
|
|
107
|
-
{...props}
|
|
108
|
-
hasGenerateURLFn={typeof pluginConfig?.generateURL === 'function'}
|
|
109
|
-
/>
|
|
110
|
-
),
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
label: 'Preview',
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
interfaceName: pluginConfig.interfaceName,
|
|
117
|
-
label: 'SEO',
|
|
118
|
-
},
|
|
119
|
-
]
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
...config,
|
|
123
|
-
collections:
|
|
124
|
-
config.collections?.map((collection) => {
|
|
125
|
-
const { slug } = collection
|
|
126
|
-
const isEnabled = pluginConfig?.collections?.includes(slug)
|
|
127
|
-
|
|
128
|
-
if (isEnabled) {
|
|
129
|
-
if (pluginConfig?.tabbedUI) {
|
|
130
|
-
// prevent issues with auth enabled collections having an email field that shouldn't be moved to the SEO tab
|
|
131
|
-
const emailField =
|
|
132
|
-
(collection.auth ||
|
|
133
|
-
!(typeof collection.auth === 'object' && collection.auth.disableLocalStrategy)) &&
|
|
134
|
-
collection.fields?.find((field) => 'name' in field && field.name === 'email')
|
|
135
|
-
const hasOnlyEmailField = collection.fields?.length === 1 && emailField
|
|
136
|
-
|
|
137
|
-
const seoTabs: TabsField[] = hasOnlyEmailField
|
|
138
|
-
? [
|
|
139
|
-
{
|
|
140
|
-
type: 'tabs',
|
|
141
|
-
tabs: [
|
|
142
|
-
{
|
|
143
|
-
fields: seoFields,
|
|
144
|
-
label: 'SEO',
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
},
|
|
148
|
-
]
|
|
149
|
-
: [
|
|
150
|
-
{
|
|
151
|
-
type: 'tabs',
|
|
152
|
-
tabs: [
|
|
153
|
-
// append a new tab onto the end of the tabs array, if there is one at the first index
|
|
154
|
-
// if needed, create a new `Content` tab in the first index for this collection's base fields
|
|
155
|
-
...(collection?.fields?.[0]?.type === 'tabs' &&
|
|
156
|
-
collection?.fields?.[0]?.tabs
|
|
157
|
-
? collection.fields[0].tabs
|
|
158
|
-
: [
|
|
159
|
-
{
|
|
160
|
-
fields: [
|
|
161
|
-
...(emailField
|
|
162
|
-
? collection.fields.filter(
|
|
163
|
-
(field) => 'name' in field && field.name !== 'email',
|
|
164
|
-
)
|
|
165
|
-
: collection.fields),
|
|
166
|
-
],
|
|
167
|
-
label: collection?.labels?.singular || 'Content',
|
|
168
|
-
},
|
|
169
|
-
]),
|
|
170
|
-
{
|
|
171
|
-
fields: seoFields,
|
|
172
|
-
label: 'SEO',
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
},
|
|
176
|
-
]
|
|
177
|
-
|
|
178
|
-
return {
|
|
179
|
-
...collection,
|
|
180
|
-
fields: [
|
|
181
|
-
...(emailField ? [emailField] : []),
|
|
182
|
-
...seoTabs,
|
|
183
|
-
...(collection?.fields?.[0]?.type === 'tabs' ? collection.fields.slice(1) : []),
|
|
184
|
-
],
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
...collection,
|
|
190
|
-
fields: [...(collection?.fields || []), ...seoFields],
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return collection
|
|
195
|
-
}) || [],
|
|
196
|
-
endpoints: [
|
|
197
|
-
...(config.endpoints ?? []),
|
|
198
|
-
{
|
|
199
|
-
handler: async (req) => {
|
|
200
|
-
const args: Parameters<GenerateTitle>[0] =
|
|
201
|
-
req.data as unknown as Parameters<GenerateTitle>[0]
|
|
202
|
-
const result = pluginConfig.generateTitle ? await pluginConfig.generateTitle(args) : ''
|
|
203
|
-
return new Response(JSON.stringify({ result }), { status: 200 })
|
|
204
|
-
},
|
|
205
|
-
method: 'post',
|
|
206
|
-
path: '/plugin-seo/generate-title',
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
handler: async (req) => {
|
|
210
|
-
const args: Parameters<GenerateDescription>[0] =
|
|
211
|
-
req.data as unknown as Parameters<GenerateDescription>[0]
|
|
212
|
-
const result = pluginConfig.generateDescription
|
|
213
|
-
? await pluginConfig.generateDescription(args)
|
|
214
|
-
: ''
|
|
215
|
-
return new Response(JSON.stringify({ result }), { status: 200 })
|
|
216
|
-
},
|
|
217
|
-
method: 'post',
|
|
218
|
-
path: '/plugin-seo/generate-description',
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
handler: async (req) => {
|
|
222
|
-
const args: Parameters<GenerateURL>[0] =
|
|
223
|
-
req.data as unknown as Parameters<GenerateURL>[0]
|
|
224
|
-
const result = pluginConfig.generateURL ? await pluginConfig.generateURL(args) : ''
|
|
225
|
-
return new Response(JSON.stringify({ result }), { status: 200 })
|
|
226
|
-
},
|
|
227
|
-
method: 'post',
|
|
228
|
-
path: '/plugin-seo/generate-url',
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
handler: async (req) => {
|
|
232
|
-
const args: Parameters<GenerateImage>[0] =
|
|
233
|
-
req.data as unknown as Parameters<GenerateImage>[0]
|
|
234
|
-
const result = pluginConfig.generateImage ? await pluginConfig.generateImage(args) : ''
|
|
235
|
-
return new Response(result, { status: 200 })
|
|
236
|
-
},
|
|
237
|
-
method: 'post',
|
|
238
|
-
path: '/plugin-seo/generate-image',
|
|
239
|
-
},
|
|
240
|
-
],
|
|
241
|
-
globals:
|
|
242
|
-
config.globals?.map((global) => {
|
|
243
|
-
const { slug } = global
|
|
244
|
-
const isEnabled = pluginConfig?.globals?.includes(slug)
|
|
245
|
-
|
|
246
|
-
if (isEnabled) {
|
|
247
|
-
if (pluginConfig?.tabbedUI) {
|
|
248
|
-
const seoTabs: TabsField[] = [
|
|
249
|
-
{
|
|
250
|
-
type: 'tabs',
|
|
251
|
-
tabs: [
|
|
252
|
-
// append a new tab onto the end of the tabs array, if there is one at the first index
|
|
253
|
-
// if needed, create a new `Content` tab in the first index for this global's base fields
|
|
254
|
-
...(global?.fields?.[0].type === 'tabs' && global?.fields?.[0].tabs
|
|
255
|
-
? global.fields[0].tabs
|
|
256
|
-
: [
|
|
257
|
-
{
|
|
258
|
-
fields: [...(global?.fields || [])],
|
|
259
|
-
label: global?.label || 'Content',
|
|
260
|
-
},
|
|
261
|
-
]),
|
|
262
|
-
{
|
|
263
|
-
fields: seoFields,
|
|
264
|
-
label: 'SEO',
|
|
265
|
-
},
|
|
266
|
-
],
|
|
267
|
-
},
|
|
268
|
-
]
|
|
269
|
-
|
|
270
|
-
return {
|
|
271
|
-
...global,
|
|
272
|
-
fields: [
|
|
273
|
-
...seoTabs,
|
|
274
|
-
...(global?.fields?.[0].type === 'tabs' ? global.fields.slice(1) : []),
|
|
275
|
-
],
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return {
|
|
280
|
-
...global,
|
|
281
|
-
fields: [...(global?.fields || []), ...seoFields],
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return global
|
|
286
|
-
}) || [],
|
|
287
|
-
i18n: {
|
|
288
|
-
...config.i18n,
|
|
289
|
-
translations: {
|
|
290
|
-
...deepMerge(translations, config.i18n?.translations),
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export { seo }
|
package/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/types'
|
package/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/types')
|