@payloadcms/plugin-seo 3.0.0-canary.a192632 → 3.0.0-canary.a5aaf21
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/fields/MetaDescription/MetaDescriptionComponent.d.ts +3 -3
- package/dist/fields/MetaDescription/MetaDescriptionComponent.d.ts.map +1 -1
- package/dist/fields/MetaDescription/MetaDescriptionComponent.js +15 -6
- package/dist/fields/MetaDescription/MetaDescriptionComponent.js.map +1 -1
- package/dist/fields/MetaImage/MetaImageComponent.d.ts +3 -3
- package/dist/fields/MetaImage/MetaImageComponent.d.ts.map +1 -1
- package/dist/fields/MetaImage/MetaImageComponent.js +24 -10
- package/dist/fields/MetaImage/MetaImageComponent.js.map +1 -1
- package/dist/fields/MetaTitle/MetaTitleComponent.d.ts +3 -3
- package/dist/fields/MetaTitle/MetaTitleComponent.d.ts.map +1 -1
- package/dist/fields/MetaTitle/MetaTitleComponent.js +15 -6
- package/dist/fields/MetaTitle/MetaTitleComponent.js.map +1 -1
- package/dist/fields/Overview/OverviewComponent.d.ts.map +1 -1
- package/dist/fields/Overview/OverviewComponent.js +6 -3
- package/dist/fields/Overview/OverviewComponent.js.map +1 -1
- package/dist/fields/Preview/PreviewComponent.d.ts +3 -3
- package/dist/fields/Preview/PreviewComponent.d.ts.map +1 -1
- package/dist/fields/Preview/PreviewComponent.js +13 -6
- package/dist/fields/Preview/PreviewComponent.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -10
- 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 +11 -178
- package/dist/translations/index.d.ts.map +1 -1
- package/dist/translations/index.js +18 -176
- 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 +18 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/ui/LengthIndicator.js +1 -1
- package/dist/ui/LengthIndicator.js.map +1 -1
- package/package.json +17 -17
- 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/translations/ru.json +0 -22
- package/dist/translations/uk.json +0 -22
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TextareaFieldClientProps } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
type MetaDescriptionProps = {
|
|
4
|
-
hasGenerateDescriptionFn: boolean;
|
|
5
|
-
} &
|
|
4
|
+
readonly hasGenerateDescriptionFn: boolean;
|
|
5
|
+
} & TextareaFieldClientProps;
|
|
6
6
|
export declare const MetaDescriptionComponent: React.FC<MetaDescriptionProps>;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=MetaDescriptionComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaDescriptionComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"MetaDescriptionComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAYvD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAU1C,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,wBAAwB,EAAE,OAAO,CAAA;CAC3C,GAAG,wBAAwB,CAAA;AAE5B,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAkJnE,CAAA"}
|
|
@@ -17,14 +17,22 @@ export const MetaDescriptionComponent = (props)=>{
|
|
|
17
17
|
});
|
|
18
18
|
const { errorMessage, setValue, showError, value } = field;
|
|
19
19
|
const regenerateDescription = useCallback(async ()=>{
|
|
20
|
-
if (!hasGenerateDescriptionFn)
|
|
20
|
+
if (!hasGenerateDescriptionFn) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
21
23
|
const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description', {
|
|
22
24
|
body: JSON.stringify({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
id: docInfo.id,
|
|
26
|
+
collectionSlug: docInfo.collectionSlug,
|
|
27
|
+
doc: getData(),
|
|
28
|
+
docPermissions: docInfo.docPermissions,
|
|
29
|
+
globalSlug: docInfo.globalSlug,
|
|
30
|
+
hasPublishPermission: docInfo.hasPublishPermission,
|
|
31
|
+
hasSavePermission: docInfo.hasSavePermission,
|
|
32
|
+
initialData: docInfo.initialData,
|
|
33
|
+
initialState: docInfo.initialState,
|
|
34
|
+
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
35
|
+
title: docInfo.title
|
|
28
36
|
}),
|
|
29
37
|
credentials: 'include',
|
|
30
38
|
headers: {
|
|
@@ -56,6 +64,7 @@ export const MetaDescriptionComponent = (props)=>{
|
|
|
56
64
|
className: "plugin-seo__field",
|
|
57
65
|
children: [
|
|
58
66
|
/*#__PURE__*/ _jsx(FieldLabel, {
|
|
67
|
+
field: null,
|
|
59
68
|
Label: Label,
|
|
60
69
|
label: label,
|
|
61
70
|
...labelProps || {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextareaFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n TextareaInput,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateDescription } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\n\nconst { maxLength, minLength } = defaults.description\n\ntype MetaDescriptionProps = {\n readonly hasGenerateDescriptionFn: boolean\n} & TextareaFieldClientProps\n\nexport const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n required,\n },\n hasGenerateDescriptionFn,\n labelProps,\n } = props\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const field: FieldType<string> = useField({\n path: pathFromContext,\n } as Options)\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateDescription = useCallback(async () => {\n if (!hasGenerateDescriptionFn) {\n return\n }\n\n const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description', {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateDescription>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n >),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedDescription } = await genDescriptionResponse.json()\n\n setValue(generatedDescription || '')\n }, [hasGenerateDescriptionFn, docInfo, getData, locale, setValue])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel field={null} Label={Label} label={label} {...(labelProps || {})} />\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n — \n <button\n onClick={() => {\n void regenerateDescription()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipDescription', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextareaInput\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n label={label}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextareaInput","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","description","MetaDescriptionComponent","props","field","admin","components","Label","label","required","hasGenerateDescriptionFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateDescription","genDescriptionResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","result","generatedDescription","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","Component","RenderedComponent","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,aAAa,EACbC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,S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
|
|
1
|
-
import type {
|
|
1
|
+
import type { UploadFieldClientProps } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
type MetaImageProps = {
|
|
4
|
-
hasGenerateImageFn: boolean;
|
|
5
|
-
} &
|
|
4
|
+
readonly hasGenerateImageFn: boolean;
|
|
5
|
+
} & UploadFieldClientProps;
|
|
6
6
|
export declare const MetaImageComponent: React.FC<MetaImageProps>;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=MetaImageComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaImageComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MetaImageComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAarD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,sBAAsB,CAAA;AAE1B,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAqKvD,CAAA"}
|
|
@@ -16,14 +16,22 @@ export const MetaImageComponent = (props)=>{
|
|
|
16
16
|
const docInfo = useDocumentInfo();
|
|
17
17
|
const { errorMessage, setValue, showError, value } = field;
|
|
18
18
|
const regenerateImage = useCallback(async ()=>{
|
|
19
|
-
if (!hasGenerateImageFn)
|
|
19
|
+
if (!hasGenerateImageFn) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
20
22
|
const genImageResponse = await fetch('/api/plugin-seo/generate-image', {
|
|
21
23
|
body: JSON.stringify({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
id: docInfo.id,
|
|
25
|
+
collectionSlug: docInfo.collectionSlug,
|
|
26
|
+
doc: getData(),
|
|
27
|
+
docPermissions: docInfo.docPermissions,
|
|
28
|
+
globalSlug: docInfo.globalSlug,
|
|
29
|
+
hasPublishPermission: docInfo.hasPublishPermission,
|
|
30
|
+
hasSavePermission: docInfo.hasSavePermission,
|
|
31
|
+
initialData: docInfo.initialData,
|
|
32
|
+
initialState: docInfo.initialState,
|
|
33
|
+
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
34
|
+
title: docInfo.title
|
|
27
35
|
}),
|
|
28
36
|
credentials: 'include',
|
|
29
37
|
headers: {
|
|
@@ -59,6 +67,7 @@ export const MetaImageComponent = (props)=>{
|
|
|
59
67
|
className: "plugin-seo__field",
|
|
60
68
|
children: [
|
|
61
69
|
/*#__PURE__*/ _jsx(FieldLabel, {
|
|
70
|
+
field: null,
|
|
62
71
|
Label: Label,
|
|
63
72
|
label: label,
|
|
64
73
|
...labelProps || {}
|
|
@@ -100,23 +109,28 @@ export const MetaImageComponent = (props)=>{
|
|
|
100
109
|
position: 'relative'
|
|
101
110
|
},
|
|
102
111
|
children: /*#__PURE__*/ _jsx(UploadInput, {
|
|
112
|
+
api: api,
|
|
113
|
+
collection: collection,
|
|
103
114
|
Error: {
|
|
104
115
|
type: 'client',
|
|
105
116
|
Component: null,
|
|
106
117
|
RenderedComponent: errorMessage
|
|
107
118
|
},
|
|
108
|
-
api: api,
|
|
109
|
-
collection: collection,
|
|
110
119
|
filterOptions: field.filterOptions,
|
|
111
120
|
label: undefined,
|
|
112
121
|
onChange: (incomingImage)=>{
|
|
113
122
|
if (incomingImage !== null) {
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
if (typeof incomingImage === 'object') {
|
|
124
|
+
const { id: incomingID } = incomingImage;
|
|
125
|
+
setValue(incomingID);
|
|
126
|
+
} else {
|
|
127
|
+
setValue(incomingImage);
|
|
128
|
+
}
|
|
116
129
|
} else {
|
|
117
130
|
setValue(null);
|
|
118
131
|
}
|
|
119
132
|
},
|
|
133
|
+
path: field.path,
|
|
120
134
|
relationTo: relationTo,
|
|
121
135
|
required: required,
|
|
122
136
|
serverURL: serverURL,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { UploadFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n UploadInput,\n useConfig,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateImage } from '../../types.js'\n\nimport { Pill } from '../../ui/Pill.js'\n\ntype MetaImageProps = {\n readonly hasGenerateImageFn: boolean\n} & UploadFieldClientProps\n\nexport const MetaImageComponent: React.FC<MetaImageProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n relationTo,\n required,\n },\n hasGenerateImageFn,\n labelProps,\n } = props || {}\n const { path: pathFromContext } = useFieldProps()\n\n const field: FieldType<string> = useField({ ...props, path: pathFromContext } as Options)\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateImage = useCallback(async () => {\n if (!hasGenerateImageFn) {\n return\n }\n\n const genImageResponse = await fetch('/api/plugin-seo/generate-image', {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<Parameters<GenerateImage>[0], 'collectionConfig' | 'globalConfig' | 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const generatedImage = await genImageResponse.text()\n\n setValue(generatedImage || '')\n }, [hasGenerateImageFn, docInfo, getData, locale, setValue])\n\n const hasImage = Boolean(value)\n\n const { config } = useConfig()\n\n const { collections, routes: { api } = {}, serverURL } = config\n\n const collection = collections?.find((coll) => coll.slug === relationTo) || undefined\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel field={null} Label={Label} label={label} {...(labelProps || {})} />\n {hasGenerateImageFn && (\n <React.Fragment>\n — \n <button\n onClick={() => {\n void regenerateImage()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n {hasGenerateImageFn && (\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:imageAutoGenerationTip')}\n </div>\n )}\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <UploadInput\n api={api}\n collection={collection}\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n filterOptions={field.filterOptions}\n label={undefined}\n onChange={(incomingImage) => {\n if (incomingImage !== null) {\n if (typeof incomingImage === 'object') {\n const { id: incomingID } = incomingImage\n setValue(incomingID)\n } else {\n setValue(incomingImage)\n }\n } else {\n setValue(null)\n }\n }}\n path={field.path}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <Pill\n backgroundColor={hasImage ? 'green' : 'red'}\n color=\"white\"\n label={hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')}\n />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","UploadInput","useConfig","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","Pill","MetaImageComponent","props","field","admin","components","Label","label","relationTo","required","hasGenerateImageFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateImage","genImageResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","generatedImage","text","hasImage","Boolean","config","collections","routes","api","serverURL","collection","find","coll","slug","undefined","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","Error","Component","RenderedComponent","filterOptions","onChange","incomingImage","incomingID","alignItems","display","width"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,IAAI,QAAQ,mBAAkB;AAMvC,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EACLC,OAAO,EACLC,YAAY,EAAEC,KAAK,EAAE,EACtB,EACDC,KAAK,EACLC,UAAU,EACVC,QAAQ,EACT,EACDC,kBAAkB,EAClBC,UAAU,EACX,GAAGT,SAAS,CAAC;IACd,MAAM,EAAEU,MAAMC,eAAe,EAAE,GAAGnB;IAElC,MAAMS,QAA2BV,SAAS;QAAE,GAAGS,KAAK;QAAEU,MAAMC;IAAgB;IAE5E,MAAM,EAAEC,CAAC,EAAE,GAAGjB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;;;;AAKrD,EAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TextFieldClientProps } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import '../index.scss';
|
|
4
4
|
type MetaTitleProps = {
|
|
5
|
-
hasGenerateTitleFn: boolean;
|
|
6
|
-
} &
|
|
5
|
+
readonly hasGenerateTitleFn: boolean;
|
|
6
|
+
} & TextFieldClientProps;
|
|
7
7
|
export declare const MetaTitleComponent: React.FC<MetaTitleProps>;
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=MetaTitleComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaTitleComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"MetaTitleComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAYnD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,eAAe,CAAA;AAItB,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,oBAAoB,CAAA;AAExB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAgJvD,CAAA"}
|
|
@@ -18,14 +18,22 @@ export const MetaTitleComponent = (props)=>{
|
|
|
18
18
|
const docInfo = useDocumentInfo();
|
|
19
19
|
const { errorMessage, setValue, showError, value } = field;
|
|
20
20
|
const regenerateTitle = useCallback(async ()=>{
|
|
21
|
-
if (!hasGenerateTitleFn)
|
|
21
|
+
if (!hasGenerateTitleFn) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
22
24
|
const genTitleResponse = await fetch('/api/plugin-seo/generate-title', {
|
|
23
25
|
body: JSON.stringify({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
id: docInfo.id,
|
|
27
|
+
collectionSlug: docInfo.collectionSlug,
|
|
28
|
+
doc: getData(),
|
|
29
|
+
docPermissions: docInfo.docPermissions,
|
|
30
|
+
globalSlug: docInfo.globalSlug,
|
|
31
|
+
hasPublishPermission: docInfo.hasPublishPermission,
|
|
32
|
+
hasSavePermission: docInfo.hasSavePermission,
|
|
33
|
+
initialData: docInfo.initialData,
|
|
34
|
+
initialState: docInfo.initialState,
|
|
35
|
+
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
36
|
+
title: docInfo.title
|
|
29
37
|
}),
|
|
30
38
|
credentials: 'include',
|
|
31
39
|
headers: {
|
|
@@ -57,6 +65,7 @@ export const MetaTitleComponent = (props)=>{
|
|
|
57
65
|
className: "plugin-seo__field",
|
|
58
66
|
children: [
|
|
59
67
|
/*#__PURE__*/ _jsx(FieldLabel, {
|
|
68
|
+
field: null,
|
|
60
69
|
Label: Label,
|
|
61
70
|
label: label,
|
|
62
71
|
...labelProps || {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n TextInput,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateTitle } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\nimport '../index.scss'\n\nconst { maxLength, minLength } = defaults.title\n\ntype MetaTitleProps = {\n readonly hasGenerateTitleFn: boolean\n} & TextFieldClientProps\n\nexport const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n required,\n },\n hasGenerateTitleFn,\n labelProps,\n } = props || {}\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const field: FieldType<string> = useField({\n path: pathFromContext,\n } as Options)\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) {\n return\n }\n\n const genTitleResponse = await fetch('/api/plugin-seo/generate-title', {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<Parameters<GenerateTitle>[0], 'collectionConfig' | 'globalConfig' | 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedTitle } = await genTitleResponse.json()\n\n setValue(generatedTitle || '')\n }, [hasGenerateTitleFn, docInfo, getData, locale, setValue])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel field={null} Label={Label} label={label} {...(labelProps || {})} />\n {hasGenerateTitleFn && (\n <React.Fragment>\n — \n <button\n onClick={() => {\n void regenerateTitle()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipTitle', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n .\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextInput\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n label={label}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextInput","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","title","MetaTitleComponent","props","field","admin","components","Label","label","required","hasGenerateTitleFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateTitle","genTitleResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","credentials","headers","method","result","generatedTitle","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","Component","RenderedComponent","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB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BAAWC,WAAWA;oBAAWuE,MAAMlD;;;;;AAI3E,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Overview/OverviewComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AAGjD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAW/D,KAAK,aAAa,GAAG;IACnB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAA;AAEX,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"OverviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Overview/OverviewComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AAGjD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAW/D,KAAK,aAAa,GAAG;IACnB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAA;AAEX,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA6DrD,CAAA"}
|
|
@@ -15,7 +15,6 @@ export const OverviewComponent = ({ descriptionPath: descriptionPathFromContext,
|
|
|
15
15
|
const [titleIsValid, setTitleIsValid] = useState();
|
|
16
16
|
const [descIsValid, setDescIsValid] = useState();
|
|
17
17
|
const [imageIsValid, setImageIsValid] = useState();
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
18
|
const resetAll = useCallback(()=>{
|
|
20
19
|
const fields = getFields();
|
|
21
20
|
const fieldsWithoutMeta = fields;
|
|
@@ -27,8 +26,12 @@ export const OverviewComponent = ({ descriptionPath: descriptionPathFromContext,
|
|
|
27
26
|
getFields
|
|
28
27
|
]);
|
|
29
28
|
useEffect(()=>{
|
|
30
|
-
if (typeof metaTitle === 'string')
|
|
31
|
-
|
|
29
|
+
if (typeof metaTitle === 'string') {
|
|
30
|
+
setTitleIsValid(metaTitle.length >= minTitle && metaTitle.length <= maxTitle);
|
|
31
|
+
}
|
|
32
|
+
if (typeof metaDesc === 'string') {
|
|
33
|
+
setDescIsValid(metaDesc.length >= minDesc && metaDesc.length <= maxDesc);
|
|
34
|
+
}
|
|
32
35
|
setImageIsValid(Boolean(metaImage));
|
|
33
36
|
}, [
|
|
34
37
|
metaTitle,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Overview/OverviewComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FormField, UIField } from 'payload'\n\nimport { useAllFormFields, useForm, useTranslation } from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\n\nimport { defaults } from '../../defaults.js'\n\nconst {\n description: { maxLength: maxDesc, minLength: minDesc },\n title: { maxLength: maxTitle, minLength: minTitle },\n} = defaults\n\ntype OverviewProps = {\n descriptionPath?: string\n imagePath?: string\n titlePath?: string\n} & UIField\n\nexport const OverviewComponent: React.FC<OverviewProps> = ({\n descriptionPath: descriptionPathFromContext,\n imagePath: imagePathFromContext,\n titlePath: titlePathFromContext,\n}) => {\n const {\n // dispatchFields,\n getFields,\n } = useForm()\n\n const descriptionPath = descriptionPathFromContext || 'meta.description'\n const titlePath = titlePathFromContext || 'meta.title'\n const imagePath = imagePathFromContext || 'meta.image'\n\n const [\n {\n [descriptionPath]: { value: metaDesc } = {} as FormField,\n [imagePath]: { value: metaImage } = {} as FormField,\n [titlePath]: { value: metaTitle } = {} as FormField,\n },\n ] = useAllFormFields()\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const [titleIsValid, setTitleIsValid] = useState<boolean | undefined>()\n const [descIsValid, setDescIsValid] = useState<boolean | undefined>()\n const [imageIsValid, setImageIsValid] = useState<boolean | undefined>()\n\n
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Overview/OverviewComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FormField, UIField } from 'payload'\n\nimport { useAllFormFields, useForm, useTranslation } from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\n\nimport { defaults } from '../../defaults.js'\n\nconst {\n description: { maxLength: maxDesc, minLength: minDesc },\n title: { maxLength: maxTitle, minLength: minTitle },\n} = defaults\n\ntype OverviewProps = {\n descriptionPath?: string\n imagePath?: string\n titlePath?: string\n} & UIField\n\nexport const OverviewComponent: React.FC<OverviewProps> = ({\n descriptionPath: descriptionPathFromContext,\n imagePath: imagePathFromContext,\n titlePath: titlePathFromContext,\n}) => {\n const {\n // dispatchFields,\n getFields,\n } = useForm()\n\n const descriptionPath = descriptionPathFromContext || 'meta.description'\n const titlePath = titlePathFromContext || 'meta.title'\n const imagePath = imagePathFromContext || 'meta.image'\n\n const [\n {\n [descriptionPath]: { value: metaDesc } = {} as FormField,\n [imagePath]: { value: metaImage } = {} as FormField,\n [titlePath]: { value: metaTitle } = {} as FormField,\n },\n ] = useAllFormFields()\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const [titleIsValid, setTitleIsValid] = useState<boolean | undefined>()\n const [descIsValid, setDescIsValid] = useState<boolean | undefined>()\n const [imageIsValid, setImageIsValid] = useState<boolean | undefined>()\n\n const resetAll = useCallback(() => {\n const fields = getFields()\n const fieldsWithoutMeta = fields\n fieldsWithoutMeta['meta.title'].value = ''\n fieldsWithoutMeta['meta.description'].value = ''\n fieldsWithoutMeta['meta.image'].value = ''\n // dispatchFields(fieldsWithoutMeta);\n }, [getFields])\n\n useEffect(() => {\n if (typeof metaTitle === 'string') {\n setTitleIsValid(metaTitle.length >= minTitle && metaTitle.length <= maxTitle)\n }\n if (typeof metaDesc === 'string') {\n setDescIsValid(metaDesc.length >= minDesc && metaDesc.length <= maxDesc)\n }\n setImageIsValid(Boolean(metaImage))\n }, [metaTitle, metaDesc, metaImage])\n\n const testResults = [titleIsValid, descIsValid, imageIsValid]\n\n const numberOfPasses = testResults.filter(Boolean).length\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div>\n {t('plugin-seo:checksPassing', { current: numberOfPasses, max: testResults.length })}\n </div>\n </div>\n )\n}\n"],"names":["useAllFormFields","useForm","useTranslation","React","useCallback","useEffect","useState","defaults","description","maxLength","maxDesc","minLength","minDesc","title","maxTitle","minTitle","OverviewComponent","descriptionPath","descriptionPathFromContext","imagePath","imagePathFromContext","titlePath","titlePathFromContext","getFields","value","metaDesc","metaImage","metaTitle","t","titleIsValid","setTitleIsValid","descIsValid","setDescIsValid","imageIsValid","setImageIsValid","resetAll","fields","fieldsWithoutMeta","length","Boolean","testResults","numberOfPasses","filter","div","style","marginBottom","current","max"],"mappings":"AAAA;;AAIA,SAASA,gBAAgB,EAAEC,OAAO,EAAEC,cAAc,QAAQ,iBAAgB;AAC1E,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI/D,SAASC,QAAQ,QAAQ,oBAAmB;AAE5C,MAAM,EACJC,aAAa,EAAEC,WAAWC,OAAO,EAAEC,WAAWC,OAAO,EAAE,EACvDC,OAAO,EAAEJ,WAAWK,QAAQ,EAAEH,WAAWI,QAAQ,EAAE,EACpD,GAAGR;AAQJ,OAAO,MAAMS,oBAA6C,CAAC,EACzDC,iBAAiBC,0BAA0B,EAC3CC,WAAWC,oBAAoB,EAC/BC,WAAWC,oBAAoB,EAChC;IACC,MAAM,EACJ,mBAAmB;IACnBC,SAAS,EACV,GAAGtB;IAEJ,MAAMgB,kBAAkBC,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AAgBM,KAAKP,YAAYF,MAAM;YAAC;;;AAI1F,EAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { UIField } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
type PreviewProps = {
|
|
4
|
-
descriptionPath?: string;
|
|
5
|
-
hasGenerateURLFn: boolean;
|
|
6
|
-
titlePath?: string;
|
|
4
|
+
readonly descriptionPath?: string;
|
|
5
|
+
readonly hasGenerateURLFn: boolean;
|
|
6
|
+
readonly titlePath?: string;
|
|
7
7
|
} & UIField;
|
|
8
8
|
export declare const PreviewComponent: React.FC<PreviewProps>;
|
|
9
9
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AASjD,OAAO,KAA8B,MAAM,OAAO,CAAA;AAKlD,KAAK,YAAY,GAAG;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"PreviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AASjD,OAAO,KAA8B,MAAM,OAAO,CAAA;AAKlD,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B,GAAG,OAAO,CAAA;AAEX,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAiHnD,CAAA"}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useAllFormFields, useDocumentInfo, useForm, useLocale, useTranslation } from '@payloadcms/ui';
|
|
4
4
|
import React, { useEffect, useState } from 'react';
|
|
5
|
-
export const PreviewComponent = (
|
|
5
|
+
export const PreviewComponent = (props)=>{
|
|
6
|
+
const { descriptionPath: descriptionPathFromContext, hasGenerateURLFn, titlePath: titlePathFromContext } = props;
|
|
6
7
|
const { t } = useTranslation();
|
|
7
8
|
const locale = useLocale();
|
|
8
9
|
const [fields] = useAllFormFields();
|
|
@@ -16,11 +17,17 @@ export const PreviewComponent = ({ descriptionPath: descriptionPathFromContext,
|
|
|
16
17
|
const getHref = async ()=>{
|
|
17
18
|
const genURLResponse = await fetch('/api/plugin-seo/generate-url', {
|
|
18
19
|
body: JSON.stringify({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
id: docInfo.id,
|
|
21
|
+
collectionSlug: docInfo.collectionSlug,
|
|
22
|
+
doc: getData(),
|
|
23
|
+
docPermissions: docInfo.docPermissions,
|
|
24
|
+
globalSlug: docInfo.globalSlug,
|
|
25
|
+
hasPublishPermission: docInfo.hasPublishPermission,
|
|
26
|
+
hasSavePermission: docInfo.hasSavePermission,
|
|
27
|
+
initialData: docInfo.initialData,
|
|
28
|
+
initialState: docInfo.initialState,
|
|
29
|
+
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
30
|
+
title: docInfo.title
|
|
24
31
|
}),
|
|
25
32
|
credentials: 'include',
|
|
26
33
|
headers: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FormField, UIField } from 'payload'\n\nimport {\n useAllFormFields,\n useDocumentInfo,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateURL } from '../../types.js'\n\ntype PreviewProps = {\n descriptionPath?: string\n hasGenerateURLFn: boolean\n titlePath?: string\n} & UIField\n\nexport const PreviewComponent: React.FC<PreviewProps> = ({\n descriptionPath: descriptionPathFromContext,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FormField, UIField } from 'payload'\n\nimport {\n useAllFormFields,\n useDocumentInfo,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateURL } from '../../types.js'\n\ntype PreviewProps = {\n readonly descriptionPath?: string\n readonly hasGenerateURLFn: boolean\n readonly titlePath?: string\n} & UIField\n\nexport const PreviewComponent: React.FC<PreviewProps> = (props) => {\n const {\n descriptionPath: descriptionPathFromContext,\n hasGenerateURLFn,\n titlePath: titlePathFromContext,\n } = props\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const descriptionPath = descriptionPathFromContext || 'meta.description'\n const titlePath = titlePathFromContext || 'meta.title'\n\n const {\n [descriptionPath]: { value: metaDescription } = {} as FormField,\n [titlePath]: { value: metaTitle } = {} as FormField,\n } = fields\n\n const [href, setHref] = useState<string>()\n\n useEffect(() => {\n const getHref = async () => {\n const genURLResponse = await fetch('/api/plugin-seo/generate-url', {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<Parameters<GenerateURL>[0], 'collectionConfig' | 'globalConfig' | 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: newHref } = await genURLResponse.json()\n\n setHref(newHref)\n }\n\n if (hasGenerateURLFn && !href) {\n void getHref()\n }\n }, [fields, href, locale, docInfo, hasGenerateURLFn, getData])\n\n return (\n <div>\n <div>{t('plugin-seo:preview')}</div>\n <div\n style={{\n color: '#9A9A9A',\n marginBottom: '5px',\n }}\n >\n {t('plugin-seo:previewDescription')}\n </div>\n <div\n style={{\n background: 'var(--theme-elevation-50)',\n borderRadius: '5px',\n boxShadow: '0px 0px 10px rgba(0, 0, 0, 0.1)',\n maxWidth: '600px',\n padding: '20px',\n pointerEvents: 'none',\n width: '100%',\n }}\n >\n <div>\n <a\n href={href}\n style={{\n textDecoration: 'none',\n }}\n >\n {href || 'https://...'}\n </a>\n </div>\n <h4\n style={{\n margin: 0,\n }}\n >\n <a\n href=\"/\"\n style={{\n textDecoration: 'none',\n }}\n >\n {metaTitle as string}\n </a>\n </h4>\n <p\n style={{\n margin: 0,\n }}\n >\n {metaDescription as string}\n </p>\n </div>\n </div>\n )\n}\n"],"names":["useAllFormFields","useDocumentInfo","useForm","useLocale","useTranslation","React","useEffect","useState","PreviewComponent","props","descriptionPath","descriptionPathFromContext","hasGenerateURLFn","titlePath","titlePathFromContext","t","locale","fields","getData","docInfo","value","metaDescription","metaTitle","href","setHref","getHref","genURLResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","result","newHref","json","div","style","color","marginBottom","background","borderRadius","boxShadow","maxWidth","padding","pointerEvents","width","a","textDecoration","h4","margin","p"],"mappings":"AAAA;;AAIA,SACEA,gBAAgB,EAChBC,eAAe,EACfC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAWlD,OAA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AAG;QAACR;QAAQM;QAAMP;QAAQG;QAASP;QAAkBM;KAAQ;IAE7D,qBACE,MAAC8B;;0BACC,KAACA;0BAAKjC,EAAE;;0BACR,KAACiC;gBACCC,OAAO;oBACLC,OAAO;oBACPC,cAAc;gBAChB;0BAECpC,EAAE;;0BAEL,MAACiC;gBACCC,OAAO;oBACLG,YAAY;oBACZC,cAAc;oBACdC,WAAW;oBACXC,UAAU;oBACVC,SAAS;oBACTC,eAAe;oBACfC,OAAO;gBACT;;kCAEA,KAACV;kCACC,cAAA,KAACW;4BACCpC,MAAMA;4BACN0B,OAAO;gCACLW,gBAAgB;4BAClB;sCAECrC,QAAQ;;;kCAGb,KAACsC;wBACCZ,OAAO;4BACLa,QAAQ;wBACV;kCAEA,cAAA,KAACH;4BACCpC,MAAK;4BACL0B,OAAO;gCACLW,gBAAgB;4BAClB;sCAECtC;;;kCAGL,KAACyC;wBACCd,OAAO;4BACLa,QAAQ;wBACV;kCAECzC;;;;;;AAKX,EAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAoC,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAoC,MAAM,SAAS,CAAA;AAIvE,OAAO,KAAK,EAKV,eAAe,EAChB,MAAM,YAAY,CAAA;AASnB,eAAO,MAAM,SAAS,iBACL,eAAe,cACrB,MAAM,KAAG,MAmRjB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { addDataAndFileToRequest } from '@payloadcms/next/utilities';
|
|
2
1
|
import { deepMergeSimple } from 'payload/shared';
|
|
3
2
|
import { MetaDescriptionField } from './fields/MetaDescription/index.js';
|
|
4
3
|
import { MetaImageField } from './fields/MetaImage/index.js';
|
|
@@ -103,9 +102,16 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
103
102
|
...config.endpoints ?? [],
|
|
104
103
|
{
|
|
105
104
|
handler: async (req)=>{
|
|
106
|
-
await
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
const data = await req.json();
|
|
106
|
+
if (data) {
|
|
107
|
+
req.data = data;
|
|
108
|
+
}
|
|
109
|
+
const result = pluginConfig.generateTitle ? await pluginConfig.generateTitle({
|
|
110
|
+
...data,
|
|
111
|
+
collectionConfig: req.data.collectionSlug ? config.collections?.find((c)=>c.slug === req.data.collectionSlug) : null,
|
|
112
|
+
globalConfig: req.data.globalSlug ? config.globals?.find((g)=>g.slug === req.data.globalSlug) : null,
|
|
113
|
+
req
|
|
114
|
+
}) : '';
|
|
109
115
|
return new Response(JSON.stringify({
|
|
110
116
|
result
|
|
111
117
|
}), {
|
|
@@ -117,8 +123,16 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
117
123
|
},
|
|
118
124
|
{
|
|
119
125
|
handler: async (req)=>{
|
|
120
|
-
await
|
|
121
|
-
|
|
126
|
+
const data = await req.json();
|
|
127
|
+
if (data) {
|
|
128
|
+
req.data = data;
|
|
129
|
+
}
|
|
130
|
+
const result = pluginConfig.generateDescription ? await pluginConfig.generateDescription({
|
|
131
|
+
...data,
|
|
132
|
+
collectionConfig: req.data.collectionSlug ? config.collections?.find((c)=>c.slug === req.data.collectionSlug) : null,
|
|
133
|
+
globalConfig: req.data.globalSlug ? config.globals?.find((g)=>g.slug === req.data.globalSlug) : null,
|
|
134
|
+
req
|
|
135
|
+
}) : '';
|
|
122
136
|
return new Response(JSON.stringify({
|
|
123
137
|
result
|
|
124
138
|
}), {
|
|
@@ -130,8 +144,16 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
130
144
|
},
|
|
131
145
|
{
|
|
132
146
|
handler: async (req)=>{
|
|
133
|
-
await
|
|
134
|
-
|
|
147
|
+
const data = await req.json();
|
|
148
|
+
if (data) {
|
|
149
|
+
req.data = data;
|
|
150
|
+
}
|
|
151
|
+
const result = pluginConfig.generateURL ? await pluginConfig.generateURL({
|
|
152
|
+
...data,
|
|
153
|
+
collectionConfig: req.data.collectionSlug ? config.collections?.find((c)=>c.slug === req.data.collectionSlug) : null,
|
|
154
|
+
globalConfig: req.data.globalSlug ? config.globals?.find((g)=>g.slug === req.data.globalSlug) : null,
|
|
155
|
+
req
|
|
156
|
+
}) : '';
|
|
135
157
|
return new Response(JSON.stringify({
|
|
136
158
|
result
|
|
137
159
|
}), {
|
|
@@ -143,8 +165,16 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
143
165
|
},
|
|
144
166
|
{
|
|
145
167
|
handler: async (req)=>{
|
|
146
|
-
await
|
|
147
|
-
|
|
168
|
+
const data = await req.json();
|
|
169
|
+
if (data) {
|
|
170
|
+
req.data = data;
|
|
171
|
+
}
|
|
172
|
+
const result = pluginConfig.generateImage ? await pluginConfig.generateImage({
|
|
173
|
+
...data,
|
|
174
|
+
collectionConfig: req.data.collectionSlug ? config.collections?.find((c)=>c.slug === req.data.collectionSlug) : null,
|
|
175
|
+
globalConfig: req.data.globalSlug ? config.globals?.find((g)=>g.slug === req.data.globalSlug) : null,
|
|
176
|
+
req
|
|
177
|
+
}) : '';
|
|
148
178
|
return new Response(result, {
|
|
149
179
|
status: 200
|
|
150
180
|
});
|