Skip to content

Commit 5e08368

Browse files
authored
feat(plugin-seo)!: remove support for payload <2.7.0 (#4765)
1 parent 911764a commit 5e08368

File tree

10 files changed

+33
-37
lines changed

10 files changed

+33
-37
lines changed

packages/plugin-seo/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
A plugin for [Payload](https://github.com/payloadcms/payload) to manage SEO metadata from within your admin panel.
44

5+
If you're using version 2.0.0 or higher of this plugin, you'll need to be using version 2.7.0 or higher of Payload.
6+
7+
If you're still on an older payload version, please use version 1.0.15.
8+
59
- [Source code](https://github.com/payloadcms/payload/tree/main/packages/plugin-seo)
610
- [Documentation](https://payloadcms.com/docs/plugins/seo)
711
- [Documentation source](https://github.com/payloadcms/payload/tree/main/docs/plugins/seo.mdx)

packages/plugin-seo/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@payloadcms/plugin-seo",
3-
"version": "1.1.0",
3+
"version": "2.0.0",
44
"homepage:": "https://payloadcms.com",
55
"repository": "git@github.com:payloadcms/plugin-seo.git",
66
"description": "SEO plugin for Payload",
@@ -28,13 +28,13 @@
2828
"author": "dev@payloadcms.com",
2929
"license": "MIT",
3030
"peerDependencies": {
31-
"payload": "^0.18.5 || ^1.0.0 || ^2.0.0",
32-
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
31+
"payload": "^2.7.0",
32+
"react": "^18.0.0"
3333
},
3434
"devDependencies": {
3535
"@payloadcms/eslint-config": "workspace:*",
36-
"@types/express": "^4.17.9",
37-
"@types/react": "18.0.21",
36+
"@types/express": "4.17.17",
37+
"@types/react": "18.2.15",
3838
"payload": "workspace:*",
3939
"react": "^18.0.0"
4040
},

packages/plugin-seo/src/fields/MetaDescription.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
'use client'
22

3-
// TODO: fix this import to work in dev mode within the monorepo in a way that is backwards compatible with 1.x
4-
// import TextareaInput from 'payload/dist/admin/components/forms/field-types/Textarea/Input'
53
import type { FieldType, Options } from 'payload/dist/admin/components/forms/useField/types'
64
import type { TextareaField } from 'payload/types'
75

86
import { TextareaInput, useAllFormFields, useField } from 'payload/components/forms'
97
import { useDocumentInfo, useLocale } from 'payload/components/utilities'
108
import React, { useCallback } from 'react'
9+
import { useTranslation } from 'react-i18next'
1110

1211
import type { PluginConfig } from '../types'
1312

14-
import { useTranslation } from 'react-i18next'
15-
1613
import { defaults } from '../defaults'
1714
import { LengthIndicator } from '../ui/LengthIndicator'
1815

@@ -96,7 +93,7 @@ export const MetaDescription: React.FC<MetaDescriptionProps> = (props) => {
9693
color: '#9A9A9A',
9794
}}
9895
>
99-
{t('lengthTipDescription', { minLength, maxLength })}
96+
{t('lengthTipDescription', { maxLength, minLength })}
10097
<a
10198
href="https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions"
10299
rel="noopener noreferrer"
@@ -130,7 +127,7 @@ export const MetaDescription: React.FC<MetaDescriptionProps> = (props) => {
130127
width: '100%',
131128
}}
132129
>
133-
<LengthIndicator maxLength={maxLength} minLength={minLength} text={value as string} />
130+
<LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />
134131
</div>
135132
</div>
136133
)

packages/plugin-seo/src/fields/MetaImage.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
'use client'
22

3-
import type { FieldType, Options } from 'payload/dist/admin/components/forms/useField/types'
4-
// TODO: fix this import to work in dev mode within the monorepo in a way that is backwards compatible with 1.x
5-
// import UploadInput from 'payload/dist/admin/components/forms/field-types/Upload/Input'
63
import type { Props as UploadInputProps } from 'payload/components/fields/Upload'
4+
import type { FieldType, Options } from 'payload/dist/admin/components/forms/useField/types'
75

86
import { UploadInput, useAllFormFields, useField } from 'payload/components/forms'
97
import { useConfig, useDocumentInfo, useLocale } from 'payload/components/utilities'
108
import React, { useCallback } from 'react'
9+
import { useTranslation } from 'react-i18next'
1110

1211
import type { PluginConfig } from '../types'
1312

14-
import { useTranslation } from 'react-i18next'
15-
1613
import { Pill } from '../ui/Pill'
1714

1815
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents

packages/plugin-seo/src/fields/MetaTitle.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use client'
22

3-
// TODO: fix this import to work in dev mode within the monorepo in a way that is backwards compatible with 1.x
4-
// import TextInput from 'payload/dist/admin/components/forms/field-types/Text/Input'
53
import type {
64
FieldType as FieldType,
75
Options,
@@ -11,9 +9,9 @@ import type { TextField as TextFieldType } from 'payload/types'
119
import { TextInput, useAllFormFields, useField } from 'payload/components/forms'
1210
import { useDocumentInfo, useLocale } from 'payload/components/utilities'
1311
import React, { useCallback } from 'react'
12+
import { useTranslation } from 'react-i18next'
1413

1514
import type { PluginConfig } from '../types'
16-
import { useTranslation } from 'react-i18next'
1715

1816
import { defaults } from '../defaults'
1917
import { LengthIndicator } from '../ui/LengthIndicator'
@@ -98,7 +96,7 @@ export const MetaTitle: React.FC<MetaTitleProps> = (props) => {
9896
color: '#9A9A9A',
9997
}}
10098
>
101-
{t('lengthTipTitle', { minLength, maxLength })}
99+
{t('lengthTipTitle', { maxLength, minLength })}
102100
<a
103101
href="https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles"
104102
rel="noopener noreferrer"
@@ -133,7 +131,7 @@ export const MetaTitle: React.FC<MetaTitleProps> = (props) => {
133131
width: '100%',
134132
}}
135133
>
136-
<LengthIndicator maxLength={maxLength} minLength={minLength} text={value as string} />
134+
<LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />
137135
</div>
138136
</div>
139137
)

packages/plugin-seo/src/index.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,61 @@
11
import type { Config } from 'payload/config'
22
import type { Field, GroupField, TabsField } from 'payload/dist/fields/config/types'
33

4+
import { deepMerge } from 'payload/utilities'
5+
46
import type { PluginConfig } from './types'
57

68
import { getMetaDescriptionField } from './fields/MetaDescription'
79
import { getMetaImageField } from './fields/MetaImage'
810
import { getMetaTitleField } from './fields/MetaTitle'
11+
import translations from './translations'
912
import { Overview } from './ui/Overview'
1013
import { getPreviewField } from './ui/Preview'
11-
import { deepMerge } from 'payload/dist/utilities/deepMerge'
12-
import translations from './translations'
1314

1415
const seo =
1516
(pluginConfig: PluginConfig) =>
1617
(config: Config): Config => {
1718
const seoFields: GroupField[] = [
1819
{
1920
name: 'meta',
21+
type: 'group',
2022
fields: [
2123
{
2224
name: 'overview',
25+
type: 'ui',
2326
admin: {
2427
components: {
2528
Field: Overview,
2629
},
2730
},
2831
label: 'Overview',
29-
type: 'ui',
3032
},
3133
{
3234
name: 'title',
35+
type: 'text',
3336
admin: {
3437
components: {
3538
Field: (props) => getMetaTitleField({ ...props, pluginConfig }),
3639
},
3740
},
3841
localized: true,
39-
type: 'text',
4042
},
4143
{
4244
name: 'description',
45+
type: 'textarea',
4346
admin: {
4447
components: {
4548
Field: (props) => getMetaDescriptionField({ ...props, pluginConfig }),
4649
},
4750
},
4851
localized: true,
49-
type: 'textarea',
5052
},
5153
...(pluginConfig?.uploadsCollection
5254
? [
5355
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
5456
{
5557
name: 'image',
58+
type: 'upload',
5659
admin: {
5760
components: {
5861
Field: (props) => getMetaImageField({ ...props, pluginConfig }),
@@ -63,24 +66,22 @@ const seo =
6366
label: 'Meta Image',
6467
localized: true,
6568
relationTo: pluginConfig?.uploadsCollection,
66-
type: 'upload',
6769
} as Field,
6870
]
6971
: []),
7072
...(pluginConfig?.fields || []),
7173
{
7274
name: 'preview',
75+
type: 'ui',
7376
admin: {
7477
components: {
7578
Field: (props) => getPreviewField({ ...props, pluginConfig }),
7679
},
7780
},
7881
label: 'Preview',
79-
type: 'ui',
8082
},
8183
],
8284
label: 'SEO',
83-
type: 'group',
8485
},
8586
]
8687

@@ -95,6 +96,7 @@ const seo =
9596
if (pluginConfig?.tabbedUI) {
9697
const seoTabs: TabsField[] = [
9798
{
99+
type: 'tabs',
98100
tabs: [
99101
// append a new tab onto the end of the tabs array, if there is one at the first index
100102
// if needed, create a new `Content` tab in the first index for this collection's base fields
@@ -111,7 +113,6 @@ const seo =
111113
label: 'SEO',
112114
},
113115
],
114-
type: 'tabs',
115116
},
116117
]
117118

@@ -141,6 +142,7 @@ const seo =
141142
if (pluginConfig?.tabbedUI) {
142143
const seoTabs: TabsField[] = [
143144
{
145+
type: 'tabs',
144146
tabs: [
145147
// append a new tab onto the end of the tabs array, if there is one at the first index
146148
// if needed, create a new `Content` tab in the first index for this global's base fields
@@ -157,7 +159,6 @@ const seo =
157159
label: 'SEO',
158160
},
159161
],
160-
type: 'tabs',
161162
},
162163
]
163164

packages/plugin-seo/src/ui/LengthIndicator.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client'
22

33
import React, { Fragment, useEffect, useState } from 'react'
4-
54
import { useTranslation } from 'react-i18next'
65

76
import { Pill } from './Pill'
@@ -98,7 +97,7 @@ export const LengthIndicator: React.FC<{
9897
}}
9998
>
10099
<small>
101-
{t('characterCount', { current: text?.length || 0, minLength, maxLength })}
100+
{t('characterCount', { current: text?.length || 0, maxLength, minLength })}
102101
{(textLength === 0 || charsUntilMin > 0) && (
103102
<Fragment>{t('charactersToGo', { characters: charsUntilMin })}</Fragment>
104103
)}

packages/plugin-seo/src/ui/Overview.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { FormField } from 'payload/types'
44

55
import { useAllFormFields, useForm } from 'payload/components/forms'
66
import React, { useCallback, useEffect, useState } from 'react'
7-
87
import { useTranslation } from 'react-i18next'
98

109
import { defaults } from '../defaults'

packages/plugin-seo/src/ui/Preview.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useAllFormFields } from 'payload/components/forms'
66
import { useDocumentInfo, useLocale } from 'payload/components/utilities'
77
import React, { useEffect, useState } from 'react'
88
import { useTranslation } from 'react-i18next'
9+
910
import type { PluginConfig } from '../types'
1011

1112
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)