@payloadcms/plugin-seo 3.34.0-canary.4 → 3.34.0
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.map +1 -1
- package/dist/fields/MetaDescription/MetaDescriptionComponent.js +3 -2
- package/dist/fields/MetaDescription/MetaDescriptionComponent.js.map +1 -1
- package/dist/fields/MetaDescription/index.js.map +1 -1
- package/dist/fields/MetaImage/MetaImageComponent.js +3 -2
- package/dist/fields/MetaImage/MetaImageComponent.js.map +1 -1
- package/dist/fields/MetaImage/index.js.map +1 -1
- package/dist/fields/MetaTitle/MetaTitleComponent.js +1 -1
- package/dist/fields/MetaTitle/MetaTitleComponent.js.map +1 -1
- package/dist/fields/MetaTitle/index.js.map +1 -1
- package/dist/fields/Overview/OverviewComponent.d.ts.map +1 -1
- package/dist/fields/Overview/OverviewComponent.js +1 -11
- package/dist/fields/Overview/OverviewComponent.js.map +1 -1
- package/dist/fields/Overview/index.js.map +1 -1
- package/dist/fields/Preview/PreviewComponent.js +1 -1
- package/dist/fields/Preview/PreviewComponent.js.map +1 -1
- package/dist/fields/Preview/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -29
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
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;AAavD,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,
|
|
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;AAavD,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,CAgLnE,CAAA"}
|
|
@@ -15,9 +15,10 @@ export const MetaDescriptionComponent = (props)=>{
|
|
|
15
15
|
const docInfo = useDocumentInfo();
|
|
16
16
|
const maxLength = maxLengthFromProps || maxLengthDefault;
|
|
17
17
|
const minLength = minLengthFromProps || minLengthDefault;
|
|
18
|
-
const { customComponents
|
|
18
|
+
const { customComponents, errorMessage, setValue, showError, value } = useField({
|
|
19
19
|
path
|
|
20
20
|
});
|
|
21
|
+
const { AfterInput, BeforeInput, Label } = customComponents ?? {};
|
|
21
22
|
const regenerateDescription = useCallback(async ()=>{
|
|
22
23
|
if (!hasGenerateDescriptionFn) {
|
|
23
24
|
return;
|
|
@@ -33,7 +34,7 @@ export const MetaDescriptionComponent = (props)=>{
|
|
|
33
34
|
hasPublishPermission: docInfo.hasPublishPermission,
|
|
34
35
|
hasSavePermission: docInfo.hasSavePermission,
|
|
35
36
|
initialData: docInfo.initialData,
|
|
36
|
-
initialState: reduceToSerializableFields(docInfo.initialState),
|
|
37
|
+
initialState: reduceToSerializableFields(docInfo.initialState ?? {}),
|
|
37
38
|
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
38
39
|
title: docInfo.title
|
|
39
40
|
}),
|
|
@@ -1 +1 @@
|
|
|
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 useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\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: maxLengthDefault, minLength: minLengthDefault } = defaults.description\n\ntype MetaDescriptionProps = {\n readonly hasGenerateDescriptionFn: boolean\n} & TextareaFieldClientProps\n\nexport const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props) => {\n const {\n field: {\n label,\n localized,\n maxLength: maxLengthFromProps,\n minLength: minLengthFromProps,\n required,\n },\n hasGenerateDescriptionFn,\n path,\n readOnly,\n } = props\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const maxLength = maxLengthFromProps || maxLengthDefault\n const minLength = minLengthFromProps || minLengthDefault\n\n const {
|
|
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 useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\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: maxLengthDefault, minLength: minLengthDefault } = defaults.description\n\ntype MetaDescriptionProps = {\n readonly hasGenerateDescriptionFn: boolean\n} & TextareaFieldClientProps\n\nexport const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props) => {\n const {\n field: {\n label,\n localized,\n maxLength: maxLengthFromProps,\n minLength: minLengthFromProps,\n required,\n },\n hasGenerateDescriptionFn,\n path,\n readOnly,\n } = props\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const maxLength = maxLengthFromProps || maxLengthDefault\n const minLength = minLengthFromProps || minLengthDefault\n\n const { customComponents, errorMessage, setValue, showError, value }: FieldType<string> =\n useField({\n path,\n } as Options)\n\n const { AfterInput, BeforeInput, Label } = customComponents ?? {}\n\n const regenerateDescription = useCallback(async () => {\n if (!hasGenerateDescriptionFn) {\n return\n }\n\n const endpoint = `${serverURL}${api}/plugin-seo/generate-description`\n\n const genDescriptionResponse = await fetch(endpoint, {\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: reduceToSerializableFields(docInfo.initialState ?? {}),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateDescription>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\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 }, [\n hasGenerateDescriptionFn,\n serverURL,\n api,\n docInfo.id,\n docInfo.collectionSlug,\n docInfo.docPermissions,\n docInfo.globalSlug,\n docInfo.hasPublishPermission,\n docInfo.hasSavePermission,\n docInfo.initialData,\n docInfo.initialState,\n docInfo.title,\n getData,\n locale,\n setValue,\n ])\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 {Label ?? (\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n )}\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n — \n <button\n disabled={readOnly}\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 AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n Error={errorMessage}\n onChange={setValue}\n path={path}\n readOnly={readOnly}\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","useConfig","useDocumentInfo","useField","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useCallback","defaults","LengthIndicator","maxLength","maxLengthDefault","minLength","minLengthDefault","description","MetaDescriptionComponent","props","field","label","localized","maxLengthFromProps","minLengthFromProps","required","hasGenerateDescriptionFn","path","readOnly","config","routes","api","serverURL","t","locale","getData","docInfo","customComponents","errorMessage","setValue","showError","value","AfterInput","BeforeInput","Label","regenerateDescription","endpoint","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","disabled","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAE7D,MAAM,EAAEC,WAAWC,gBAAgB,EAAEC,WAAWC,gBAAgB,EAAE,GAAGL,SAASM,WAAW;AAMzF,OAAO,MAAMC,2BAA2D,CAACC;IACvE,MAAM,EACJC,OAAO,EACLC,KAAK,EACLC,SAAS,EACTT,WAAWU,kBAAkB,EAC7BR,WAAWS,kBAAkB,EAC7BC,QAAQ,EACT,EACDC,wBAAwB,EACxBC,IAAI,EACJC,QAAQ,EACT,GAAGT;IAEJ,MAAM,EACJU,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAG9B;IAEJ,MAAM,EAAE+B,CAAC,EAAE,GAAG1B;IAEd,MAAM2B,SAAS5B;IACf,MAAM,EAAE6B,OAAO,EAAE,GAAG9B;IACpB,MAAM+B,UAAUjC;IAEhB,MAAMU,YAAYU,sBAAsBT;IACxC,MAAMC,YAAYS,sBAAsBR;IAExC,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AC8B;QACCC,OAAO;YACLC,cAAc;QAChB;;0BAEA,MAACF;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;;kCAEA,MAACH;wBAAII,WAAU;;4BACZ7B,uBACC,KAAC5C;gCAAWqB,OAAOA;gCAAOC,WAAWA;gCAAWK,MAAMA;gCAAMF,UAAUA;;4BAEvEC,0CACC,MAACjB,MAAMiE,QAAQ;;oCAAC;kDAEd,KAACC;wCACCC,UAAUhD;wCACViD,SAAS;4CACP,KAAKhC;wCACP;wCACAyB,OAAO;4CACLQ,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJpD,EAAE;;;;;;kCAKX,MAACoC;wBACCC,OAAO;4BACLW,OAAO;wBACT;;4BAEChD,EAAE,mCAAmC;gCAAEpB;gCAAWE;4BAAU;0CAC7D,KAACuE;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAENxD,EAAE;;;;;;0BAIT,KAACoC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACvE;oBACCyC,YAAYA;oBACZC,aAAaA;oBACb+C,OAAOpD;oBACPqD,UAAUpD;oBACVZ,MAAMA;oBACNC,UAAUA;oBACVH,UAAUA;oBACVe,WAAWA;oBACX8B,OAAO;wBACLC,cAAc;oBAChB;oBACA9B,OAAOA;;;0BAGX,KAAC4B;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAAClF;oBAAgBC,WAAWA;oBAAWE,WAAWA;oBAAWgF,MAAMtD;;;;;AAI3E,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/MetaDescription/index.ts"],"sourcesContent":["import type { TextareaField } from 'payload'\n\ninterface FieldFunctionProps {\n /**\n * Tell the component if the generate function is available as configured in the plugin config\n */\n hasGenerateFn?: boolean\n overrides?: Partial<TextareaField>\n}\n\ntype FieldFunction = ({ hasGenerateFn, overrides }: FieldFunctionProps) => TextareaField\n\nexport const MetaDescriptionField: FieldFunction = ({ hasGenerateFn = false, overrides }) => {\n return {\n name: 'description',\n type: 'textarea',\n admin: {\n components: {\n Field: {\n clientProps: {\n hasGenerateDescriptionFn: hasGenerateFn,\n },\n path: '@payloadcms/plugin-seo/client#MetaDescriptionComponent',\n },\n },\n },\n localized: true,\n ...(
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/MetaDescription/index.ts"],"sourcesContent":["import type { TextareaField } from 'payload'\n\ninterface FieldFunctionProps {\n /**\n * Tell the component if the generate function is available as configured in the plugin config\n */\n hasGenerateFn?: boolean\n overrides?: Partial<TextareaField>\n}\n\ntype FieldFunction = ({ hasGenerateFn, overrides }: FieldFunctionProps) => TextareaField\n\nexport const MetaDescriptionField: FieldFunction = ({ hasGenerateFn = false, overrides }) => {\n return {\n name: 'description',\n type: 'textarea',\n admin: {\n components: {\n Field: {\n clientProps: {\n hasGenerateDescriptionFn: hasGenerateFn,\n },\n path: '@payloadcms/plugin-seo/client#MetaDescriptionComponent',\n },\n },\n },\n localized: true,\n ...(overrides ?? {}),\n }\n}\n"],"names":["MetaDescriptionField","hasGenerateFn","overrides","name","type","admin","components","Field","clientProps","hasGenerateDescriptionFn","path","localized"],"mappings":"AAYA,OAAO,MAAMA,uBAAsC,CAAC,EAAEC,gBAAgB,KAAK,EAAEC,SAAS,EAAE;IACtF,OAAO;QACLC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXC,0BAA0BR;oBAC5B;oBACAS,MAAM;gBACR;YACF;QACF;QACAC,WAAW;QACX,GAAIT,aAAa,CAAC,CAAC;IACrB;AACF,EAAC"}
|
|
@@ -11,7 +11,8 @@ export const MetaImageComponent = (props)=>{
|
|
|
11
11
|
...props,
|
|
12
12
|
path
|
|
13
13
|
});
|
|
14
|
-
const { customComponents
|
|
14
|
+
const { customComponents } = field;
|
|
15
|
+
const { Error, Label } = customComponents ?? {};
|
|
15
16
|
const { t } = useTranslation();
|
|
16
17
|
const locale = useLocale();
|
|
17
18
|
const { getData } = useForm();
|
|
@@ -32,7 +33,7 @@ export const MetaImageComponent = (props)=>{
|
|
|
32
33
|
hasPublishPermission: docInfo.hasPublishPermission,
|
|
33
34
|
hasSavePermission: docInfo.hasSavePermission,
|
|
34
35
|
initialData: docInfo.initialData,
|
|
35
|
-
initialState: reduceToSerializableFields(docInfo.initialState),
|
|
36
|
+
initialState: reduceToSerializableFields(docInfo.initialState ?? {}),
|
|
36
37
|
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
37
38
|
title: docInfo.title
|
|
38
39
|
}),
|
|
@@ -1 +1 @@
|
|
|
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 RenderCustomComponent,\n UploadInput,\n useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\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: { label, localized, relationTo, required },\n hasGenerateImageFn,\n path,\n readOnly,\n } = props || {}\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const field: FieldType<string> = useField({ ...props, path } as Options)\n const {\n
|
|
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 RenderCustomComponent,\n UploadInput,\n useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\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: { label, localized, relationTo, required },\n hasGenerateImageFn,\n path,\n readOnly,\n } = props || {}\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const field: FieldType<string> = useField({ ...props, path } as Options)\n const { customComponents } = field\n\n const { Error, Label } = customComponents ?? {}\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const { setValue, showError, value } = field\n\n const regenerateImage = useCallback(async () => {\n if (!hasGenerateImageFn) {\n return\n }\n\n const endpoint = `${serverURL}${api}/plugin-seo/generate-image`\n\n const genImageResponse = await fetch(endpoint, {\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: reduceToSerializableFields(docInfo.initialState ?? {}),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateImage>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\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 }, [\n hasGenerateImageFn,\n serverURL,\n api,\n docInfo.id,\n docInfo.collectionSlug,\n docInfo.docPermissions,\n docInfo.globalSlug,\n docInfo.hasPublishPermission,\n docInfo.hasSavePermission,\n docInfo.initialData,\n docInfo.initialState,\n docInfo.title,\n getData,\n locale,\n setValue,\n ])\n\n const hasImage = Boolean(value)\n\n const collection = getEntityConfig({ collectionSlug: relationTo })\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 <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n {hasGenerateImageFn && (\n <React.Fragment>\n — \n <button\n disabled={readOnly}\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={Error}\n filterOptions={field.filterOptions}\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={path}\n readOnly={readOnly}\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","RenderCustomComponent","UploadInput","useConfig","useDocumentInfo","useField","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useCallback","Pill","MetaImageComponent","props","field","label","localized","relationTo","required","hasGenerateImageFn","path","readOnly","config","routes","api","serverURL","getEntityConfig","customComponents","Error","Label","t","locale","getData","docInfo","setValue","showError","value","regenerateImage","endpoint","genImageResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","generatedImage","text","hasImage","Boolean","collection","div","style","marginBottom","position","className","CustomComponent","Fallback","Fragment","button","disabled","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","filterOptions","onChange","incomingImage","incomingID","alignItems","display","width"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,qBAAqB,EACrBC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,IAAI,QAAQ,mBAAkB;AAMvC,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAE,EACjDC,kBAAkB,EAClBC,IAAI,EACJC,QAAQ,EACT,GAAGR,SAAS,CAAC;IAEd,MAAM,EACJS,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACDC,eAAe,EAChB,GAAGxB;IAEJ,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AUA;oBACVO,WAAWA;oBACXU,WAAWA;oBACX6B,OAAO;wBACLC,cAAc;oBAChB;oBACA7B,OAAOA;;;0BAGX,KAAC2B;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAAC7E;oBACCgE,iBAAiBf,WAAW,UAAU;oBACtCiB,OAAM;oBACN9D,OAAO6C,WAAW9B,EAAE,qBAAqBA,EAAE;;;;;AAKrD,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/MetaImage/index.ts"],"sourcesContent":["import type { UploadField } from 'payload'\n\ninterface FieldFunctionProps {\n /**\n * Tell the component if the generate function is available as configured in the plugin config\n */\n hasGenerateFn?: boolean\n overrides?: Partial<UploadField>\n relationTo: string\n}\n\ntype FieldFunction = ({ hasGenerateFn, overrides }: FieldFunctionProps) => UploadField\n\nexport const MetaImageField: FieldFunction = ({ hasGenerateFn = false, overrides, relationTo }) => {\n return {\n name: 'image',\n type: 'upload',\n admin: {\n components: {\n Field: {\n clientProps: {\n hasGenerateImageFn: hasGenerateFn,\n },\n path: '@payloadcms/plugin-seo/client#MetaImageComponent',\n },\n },\n description: 'Maximum upload file size: 12MB. Recommended file size for images is <500KB.',\n },\n label: 'Meta Image',\n localized: true,\n relationTo,\n ...((overrides
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/MetaImage/index.ts"],"sourcesContent":["import type { UploadField } from 'payload'\n\ninterface FieldFunctionProps {\n /**\n * Tell the component if the generate function is available as configured in the plugin config\n */\n hasGenerateFn?: boolean\n overrides?: Partial<UploadField>\n relationTo: string\n}\n\ntype FieldFunction = ({ hasGenerateFn, overrides }: FieldFunctionProps) => UploadField\n\nexport const MetaImageField: FieldFunction = ({ hasGenerateFn = false, overrides, relationTo }) => {\n return {\n name: 'image',\n type: 'upload',\n admin: {\n components: {\n Field: {\n clientProps: {\n hasGenerateImageFn: hasGenerateFn,\n },\n path: '@payloadcms/plugin-seo/client#MetaImageComponent',\n },\n },\n description: 'Maximum upload file size: 12MB. Recommended file size for images is <500KB.',\n },\n label: 'Meta Image',\n localized: true,\n relationTo,\n ...((overrides ?? {}) as { hasMany: boolean } & Partial<UploadField>),\n }\n}\n"],"names":["MetaImageField","hasGenerateFn","overrides","relationTo","name","type","admin","components","Field","clientProps","hasGenerateImageFn","path","description","label","localized"],"mappings":"AAaA,OAAO,MAAMA,iBAAgC,CAAC,EAAEC,gBAAgB,KAAK,EAAEC,SAAS,EAAEC,UAAU,EAAE;IAC5F,OAAO;QACLC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXC,oBAAoBT;oBACtB;oBACAU,MAAM;gBACR;YACF;YACAC,aAAa;QACf;QACAC,OAAO;QACPC,WAAW;QACXX;QACA,GAAKD,aAAa,CAAC,CAAC;IACtB;AACF,EAAC"}
|
|
@@ -36,7 +36,7 @@ export const MetaTitleComponent = (props)=>{
|
|
|
36
36
|
hasPublishPermission: docInfo.hasPublishPermission,
|
|
37
37
|
hasSavePermission: docInfo.hasSavePermission,
|
|
38
38
|
initialData: docInfo.initialData,
|
|
39
|
-
initialState: reduceToSerializableFields(docInfo.initialState),
|
|
39
|
+
initialState: reduceToSerializableFields(docInfo.initialState ?? {}),
|
|
40
40
|
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
41
41
|
title: docInfo.title
|
|
42
42
|
}),
|
|
@@ -1 +1 @@
|
|
|
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 useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\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: maxLengthDefault, minLength: minLengthDefault } = defaults.title\n\ntype MetaTitleProps = {\n readonly hasGenerateTitleFn: boolean\n} & TextFieldClientProps\n\nexport const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {\n const {\n field: { label, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required },\n hasGenerateTitleFn,\n path,\n readOnly,\n } = props || {}\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const field: FieldType<string> = useField({ path } as Options)\n const { customComponents: { AfterInput, BeforeInput, Label } = {} } = field\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const minLength = minLengthFromProps || minLengthDefault\n const maxLength = maxLengthFromProps || maxLengthDefault\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) {\n return\n }\n\n const endpoint = `${serverURL}${api}/plugin-seo/generate-title`\n\n const genTitleResponse = await fetch(endpoint, {\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: reduceToSerializableFields(docInfo.initialState),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\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 }, [\n hasGenerateTitleFn,\n serverURL,\n api,\n docInfo.id,\n docInfo.collectionSlug,\n docInfo.docPermissions,\n docInfo.globalSlug,\n docInfo.hasPublishPermission,\n docInfo.hasSavePermission,\n docInfo.initialData,\n docInfo.initialState,\n docInfo.title,\n getData,\n locale,\n setValue,\n ])\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 {Label ?? <FieldLabel label={label} path={path} required={required} />}\n {hasGenerateTitleFn && (\n <React.Fragment>\n — \n <button\n disabled={readOnly}\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 AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n Error={errorMessage}\n onChange={setValue}\n path={path}\n readOnly={readOnly}\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","useConfig","useDocumentInfo","useField","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useCallback","defaults","LengthIndicator","maxLength","maxLengthDefault","minLength","minLengthDefault","title","MetaTitleComponent","props","field","label","maxLengthFromProps","minLengthFromProps","required","hasGenerateTitleFn","path","readOnly","t","config","routes","api","serverURL","customComponents","AfterInput","BeforeInput","Label","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateTitle","endpoint","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","disabled","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,OAAO,gBAAe;AAEtB,MAAM,EAAEC,WAAWC,gBAAgB,EAAEC,WAAWC,gBAAgB,EAAE,GAAGL,SAASM,KAAK;AAMnF,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EAAEC,KAAK,EAAER,WAAWS,kBAAkB,EAAEP,WAAWQ,kBAAkB,EAAEC,QAAQ,EAAE,EACxFC,kBAAkB,EAClBC,IAAI,EACJC,QAAQ,EACT,GAAGR,SAAS,CAAC;IAEd,MAAM,EAAES,CAAC,EAAE,GAAGrB;IAEd,MAAM,EACJsB,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAG9B;IAEJ,MAAMkB,QAA2BhB,SAAS;QAAEsB;IAAK;IACjD,MAAM,EAAEO,kBAAkB,EAAEC,UAAU,EAAEC,WAAW,EAAEC,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,GAAGhB;IAEtE,MAAMiB,SAAS/B;IACf,MAAM,EAAEgC,OAAO,EAAE,GAAGjC;IACpB,MAAMkC,UAAUpC;IAEhB,MAAMY,YAAYQ,sBAAsBP;IACxC,MAAMH,YAAYS,sBAAsBR;IAExC,MAAM,EAAE0B,YAAY,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGvB;IAErD,MAAMwB,kBAAkBlC,YAAY;QAClC,IAAI,CAACe,oBAAoB;YACvB;QACF;QAEA,MAAMoB,WAAW,GAAGb,YAAYD,IAAI,0BAA0B,CAAC;QAE/D,MAAMe,mBAAmB,MAAMC,MAAMF,UAAU;YAC7CG,MAAMC,KAAKC,SAAS,CAAC;gBACnBC,IAAIZ,QAAQY,EAAE;gBACdC,gBAAgBb,QAAQa,cAAc;gBACtCC,KAAKf;gBACLgB,gBAAgBf,QAAQe,cAAc;gBACtCC,YAAYhB,QAAQgB,UAAU;gBAC9BC,sBAAsBjB,QAAQiB,oBAAoB;gBAClDC,mBAAmBlB,QAAQkB,iBAAiB;gBAC5CC,aAAanB,QAAQmB,WAAW;gBAChCC,cAAcnD,2BAA2B+B,QAAQoB,YAAY;
|
|
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 useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\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: maxLengthDefault, minLength: minLengthDefault } = defaults.title\n\ntype MetaTitleProps = {\n readonly hasGenerateTitleFn: boolean\n} & TextFieldClientProps\n\nexport const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {\n const {\n field: { label, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required },\n hasGenerateTitleFn,\n path,\n readOnly,\n } = props || {}\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const field: FieldType<string> = useField({ path } as Options)\n const { customComponents: { AfterInput, BeforeInput, Label } = {} } = field\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const minLength = minLengthFromProps || minLengthDefault\n const maxLength = maxLengthFromProps || maxLengthDefault\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) {\n return\n }\n\n const endpoint = `${serverURL}${api}/plugin-seo/generate-title`\n\n const genTitleResponse = await fetch(endpoint, {\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: reduceToSerializableFields(docInfo.initialState ?? {}),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\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 }, [\n hasGenerateTitleFn,\n serverURL,\n api,\n docInfo.id,\n docInfo.collectionSlug,\n docInfo.docPermissions,\n docInfo.globalSlug,\n docInfo.hasPublishPermission,\n docInfo.hasSavePermission,\n docInfo.initialData,\n docInfo.initialState,\n docInfo.title,\n getData,\n locale,\n setValue,\n ])\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 {Label ?? <FieldLabel label={label} path={path} required={required} />}\n {hasGenerateTitleFn && (\n <React.Fragment>\n — \n <button\n disabled={readOnly}\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 AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n Error={errorMessage}\n onChange={setValue}\n path={path}\n readOnly={readOnly}\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","useConfig","useDocumentInfo","useField","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useCallback","defaults","LengthIndicator","maxLength","maxLengthDefault","minLength","minLengthDefault","title","MetaTitleComponent","props","field","label","maxLengthFromProps","minLengthFromProps","required","hasGenerateTitleFn","path","readOnly","t","config","routes","api","serverURL","customComponents","AfterInput","BeforeInput","Label","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateTitle","endpoint","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","disabled","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,OAAO,gBAAe;AAEtB,MAAM,EAAEC,WAAWC,gBAAgB,EAAEC,WAAWC,gBAAgB,EAAE,GAAGL,SAASM,KAAK;AAMnF,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EAAEC,KAAK,EAAER,WAAWS,kBAAkB,EAAEP,WAAWQ,kBAAkB,EAAEC,QAAQ,EAAE,EACxFC,kBAAkB,EAClBC,IAAI,EACJC,QAAQ,EACT,GAAGR,SAAS,CAAC;IAEd,MAAM,EAAES,CAAC,EAAE,GAAGrB;IAEd,MAAM,EACJsB,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAG9B;IAEJ,MAAMkB,QAA2BhB,SAAS;QAAEsB;IAAK;IACjD,MAAM,EAAEO,kBAAkB,EAAEC,UAAU,EAAEC,WAAW,EAAEC,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,GAAGhB;IAEtE,MAAMiB,SAAS/B;IACf,MAAM,EAAEgC,OAAO,EAAE,GAAGjC;IACpB,MAAMkC,UAAUpC;IAEhB,MAAMY,YAAYQ,sBAAsBP;IAC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;kCAEA,MAACH;wBAAII,WAAU;;4BACZnC,uBAAS,KAACpC;gCAAWqB,OAAOA;gCAAOK,MAAMA;gCAAMF,UAAUA;;4BACzDC,oCACC,MAAChB,MAAM+D,QAAQ;;oCAAC;kDAEd,KAACC;wCACCC,UAAU/C;wCACVgD,SAAS;4CACP,KAAK/B;wCACP;wCACAwB,OAAO;4CACLQ,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJvD,EAAE;;;;;;kCAKX,MAACuC;wBACCC,OAAO;4BACLW,OAAO;wBACT;;4BAECnD,EAAE,6BAA6B;gCAAEf;gCAAWE;4BAAU;0CACvD,KAACqE;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAEN3D,EAAE;;4BACD;;;;;0BAIR,KAACuC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACrE;oBACCiC,YAAYA;oBACZC,aAAaA;oBACbqD,OAAOhD;oBACPiD,UAAUhD;oBACVf,MAAMA;oBACNC,UAAUA;oBACVH,UAAUA;oBACVkB,WAAWA;oBACX0B,OAAO;wBACLC,cAAc;oBAChB;oBACA1B,OAAOA;;;0BAGX,KAACwB;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAAChF;oBAAgBC,WAAWA;oBAAWE,WAAWA;oBAAW8E,MAAMlD;;;;;AAI3E,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/MetaTitle/index.ts"],"sourcesContent":["import type { TextField } from 'payload'\n\ninterface FieldFunctionProps {\n /**\n * Tell the component if the generate function is available as configured in the plugin config\n */\n hasGenerateFn?: boolean\n overrides?: Partial<TextField>\n}\n\ntype FieldFunction = ({ hasGenerateFn, overrides }: FieldFunctionProps) => TextField\n\nexport const MetaTitleField: FieldFunction = ({ hasGenerateFn = false, overrides }) => {\n return {\n name: 'title',\n type: 'text',\n admin: {\n components: {\n Field: {\n clientProps: {\n hasGenerateTitleFn: hasGenerateFn,\n },\n path: '@payloadcms/plugin-seo/client#MetaTitleComponent',\n },\n },\n },\n localized: true,\n ...((overrides
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/MetaTitle/index.ts"],"sourcesContent":["import type { TextField } from 'payload'\n\ninterface FieldFunctionProps {\n /**\n * Tell the component if the generate function is available as configured in the plugin config\n */\n hasGenerateFn?: boolean\n overrides?: Partial<TextField>\n}\n\ntype FieldFunction = ({ hasGenerateFn, overrides }: FieldFunctionProps) => TextField\n\nexport const MetaTitleField: FieldFunction = ({ hasGenerateFn = false, overrides }) => {\n return {\n name: 'title',\n type: 'text',\n admin: {\n components: {\n Field: {\n clientProps: {\n hasGenerateTitleFn: hasGenerateFn,\n },\n path: '@payloadcms/plugin-seo/client#MetaTitleComponent',\n },\n },\n },\n localized: true,\n ...((overrides ?? {}) as { hasMany: boolean } & Partial<TextField>),\n }\n}\n"],"names":["MetaTitleField","hasGenerateFn","overrides","name","type","admin","components","Field","clientProps","hasGenerateTitleFn","path","localized"],"mappings":"AAYA,OAAO,MAAMA,iBAAgC,CAAC,EAAEC,gBAAgB,KAAK,EAAEC,SAAS,EAAE;IAChF,OAAO;QACLC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXC,oBAAoBR;oBACtB;oBACAS,MAAM;gBACR;YACF;QACF;QACAC,WAAW;QACX,GAAKT,aAAa,CAAC,CAAC;IACtB;AACF,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,oBAAoB,CAAC,EAAE;QACrB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE;QACf,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,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,oBAAoB,CAAC,EAAE;QACrB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE;QACf,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAA;AAEX,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAwDrD,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useAllFormFields, useForm, useTranslation } from '@payloadcms/ui';
|
|
4
|
-
import React, {
|
|
4
|
+
import React, { useEffect, useState } from 'react';
|
|
5
5
|
import { defaults } from '../../defaults.js';
|
|
6
6
|
const { description: { maxLength: maxDescDefault, minLength: minDescDefault }, title: { maxLength: maxTitleDefault, minLength: minTitleDefault } } = defaults;
|
|
7
7
|
export const OverviewComponent = ({ descriptionOverrides, descriptionPath: descriptionPathFromContext, imagePath: imagePathFromContext, titleOverrides, titlePath: titlePathFromContext })=>{
|
|
@@ -18,16 +18,6 @@ export const OverviewComponent = ({ descriptionOverrides, descriptionPath: descr
|
|
|
18
18
|
const maxDesc = descriptionOverrides?.maxLength || maxDescDefault;
|
|
19
19
|
const minTitle = titleOverrides?.minLength || minTitleDefault;
|
|
20
20
|
const maxTitle = titleOverrides?.maxLength || maxTitleDefault;
|
|
21
|
-
const resetAll = useCallback(()=>{
|
|
22
|
-
const fields = getFields();
|
|
23
|
-
const fieldsWithoutMeta = fields;
|
|
24
|
-
fieldsWithoutMeta['meta.title'].value = '';
|
|
25
|
-
fieldsWithoutMeta['meta.description'].value = '';
|
|
26
|
-
fieldsWithoutMeta['meta.image'].value = '';
|
|
27
|
-
// dispatchFields(fieldsWithoutMeta);
|
|
28
|
-
}, [
|
|
29
|
-
getFields
|
|
30
|
-
]);
|
|
31
21
|
useEffect(()=>{
|
|
32
22
|
if (typeof metaTitle === 'string') {
|
|
33
23
|
setTitleIsValid(metaTitle.length >= minTitle && metaTitle.length <= maxTitle);
|
|
@@ -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: maxDescDefault, minLength: minDescDefault },\n title: { maxLength: maxTitleDefault, minLength: minTitleDefault },\n} = defaults\n\ntype OverviewProps = {\n descriptionOverrides?: {\n maxLength?: number\n minLength?: number\n }\n descriptionPath?: string\n imagePath?: string\n titleOverrides?: {\n maxLength?: number\n minLength?: number\n }\n titlePath?: string\n} & UIField\n\nexport const OverviewComponent: React.FC<OverviewProps> = ({\n descriptionOverrides,\n descriptionPath: descriptionPathFromContext,\n imagePath: imagePathFromContext,\n titleOverrides,\n titlePath: titlePathFromContext,\n}) => {\n const { getFields } = 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 minDesc = descriptionOverrides?.minLength || minDescDefault\n const maxDesc = descriptionOverrides?.maxLength || maxDescDefault\n const minTitle = titleOverrides?.minLength || minTitleDefault\n const maxTitle = titleOverrides?.maxLength || maxTitleDefault\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: maxDescDefault, minLength: minDescDefault },\n title: { maxLength: maxTitleDefault, minLength: minTitleDefault },\n} = defaults\n\ntype OverviewProps = {\n descriptionOverrides?: {\n maxLength?: number\n minLength?: number\n }\n descriptionPath?: string\n imagePath?: string\n titleOverrides?: {\n maxLength?: number\n minLength?: number\n }\n titlePath?: string\n} & UIField\n\nexport const OverviewComponent: React.FC<OverviewProps> = ({\n descriptionOverrides,\n descriptionPath: descriptionPathFromContext,\n imagePath: imagePathFromContext,\n titleOverrides,\n titlePath: titlePathFromContext,\n}) => {\n const { getFields } = 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 minDesc = descriptionOverrides?.minLength || minDescDefault\n const maxDesc = descriptionOverrides?.maxLength || maxDescDefault\n const minTitle = titleOverrides?.minLength || minTitleDefault\n const maxTitle = titleOverrides?.maxLength || maxTitleDefault\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","useEffect","useState","defaults","description","maxLength","maxDescDefault","minLength","minDescDefault","title","maxTitleDefault","minTitleDefault","OverviewComponent","descriptionOverrides","descriptionPath","descriptionPathFromContext","imagePath","imagePathFromContext","titleOverrides","titlePath","titlePathFromContext","getFields","value","metaDesc","metaImage","metaTitle","t","titleIsValid","setTitleIsValid","descIsValid","setDescIsValid","imageIsValid","setImageIsValid","minDesc","maxDesc","minTitle","maxTitle","length","Boolean","testResults","numberOfPasses","filter","div","style","marginBottom","current","max"],"mappings":"AAAA;;AAIA,SAASA,gBAAgB,EAAEC,OAAO,EAAEC,cAAc,QAAQ,iBAAgB;AAC1E,OAAOC,SAAsBC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI/D,SAASC,QAAQ,QAAQ,oBAAmB;AAE5C,MAAM,EACJC,aAAa,EAAEC,WAAWC,cAAc,EAAEC,WAAWC,cAAc,EAAE,EACrEC,OAAO,EAAEJ,WAAWK,eAAe,EAAEH,WAAWI,eAAe,EAAE,EAClE,GAAGR;AAgBJ,OAAO,MAAMS,oBAA6C,CAAC,EACzDC,oBAAoB,EACpBC,iBAAiBC,0BAA0B,EAC3CC,WAAWC,oBAAoB,EAC/BC,cAAc,EACdC,WAAWC,oBAAoB,EAChC;IACC,MAAM,EAAEC,SAAS,EAAE,GAAGvB;IAEtB,MAAMgB,kBAAkBC,8BAA8B;IACtD,MAAMI,YAAYC,wBAAwB;IAC1C,MAAMJ,YAAYC,wBAAwB;IAE1C,MAAM,CACJ,EACE,CAACH,gBAAgB,EAAE,EAAEQ,OAAOC,QAAQ,EAAE,GAAG,CAAC,CAAc,EACxD,CAACP,UAAU,EAAE,EAAEM,OAAOE,SAAS,EAAE,GAAG,CAAC,CAAc,EACnD,CAACL,UAAU,EAAE,EAAEG,OAAOG,SAAS,EAAE,GAAG,CAAC,CAAc,EACpD,CACF,GAAG5B;IACJ,MAAM,EAAE6B,CAAC,EAAE,GAAG3B;IAEd,MAAM,CAAC4B,cAAcC,gBAAgB,GAAG1B;IACxC,MAAM,CAAC2B,aAAaC,eAAe,GAAG5B;IACtC,MAAM,CAAC6B,cAAcC,gBAAgB,GAAG9B;IAExC,MAAM+B,UAAUpB,sBAAsBN,aAAaC;IACnD,MAAM0B,UAAUrB,sBAAsBR,aAAaC;IACnD,MAAM6B,WAAWjB,gBAAgBX,aAAaI;IAC9C,MAAMyB,WAAWlB,gBAAgBb,aAAaK;IAE9CT,UAAU;QACR,IAAI,OAAOwB,cAAc,UAAU;YACjCG,gBAAgBH,UAAUY,MAAM,IAAIF,YAAYV,UAAUY,MAAM,IAAID;QACtE;QACA,IAAI,OAAOb,aAAa,UAAU;YAChCO,eAAeP,SAASc,MAAM,IAAIJ,WAAWV,SAASc,MAAM,IAAIH;QAClE;QACAF,gBAAgBM,QAAQd;IAC1B,GAAG;QAACC;QAAWF;QAAUC;KAAU;IAEnC,MAAMe,cAAc;QAACZ;QAAcE;QAAaE;KAAa;IAE7D,MAAMS,iBAAiBD,YAAYE,MAAM,CAACH,SAASD,MAAM;IAEzD,qBACE,KAACK;QACCC,OAAO;YACLC,cAAc;QAChB;kBAEA,cAAA,KAACF;sBACEhB,EAAE,4BAA4B;gBAAEmB,SAASL;gBAAgBM,KAAKP,YAAYF,MAAM;YAAC;;;AAI1F,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Overview/index.tsx"],"sourcesContent":["import type { UIField } from 'payload'\n\ninterface FieldFunctionProps {\n descriptionOverrides?: {\n maxLength?: number\n minLength?: number\n }\n /**\n * Path to the description field to use for the preview\n *\n * @default 'meta.description'\n */\n descriptionPath?: string\n /**\n * Path to the image field to use for the preview\n *\n * @default 'meta.image'\n */\n imagePath?: string\n overrides?: Partial<UIField>\n titleOverrides?: {\n maxLength?: number\n minLength?: number\n }\n /**\n * Path to the title field to use for the preview\n *\n * @default 'meta.title'\n */\n titlePath?: string\n}\n\ntype FieldFunction = ({ overrides }: FieldFunctionProps) => UIField\n\nexport const OverviewField: FieldFunction = ({\n descriptionOverrides,\n descriptionPath,\n imagePath,\n overrides,\n titleOverrides,\n titlePath,\n}) => {\n return {\n name: 'overview',\n type: 'ui',\n admin: {\n components: {\n Field: {\n clientProps: {\n descriptionOverrides,\n descriptionPath,\n imagePath,\n titleOverrides,\n titlePath,\n },\n path: '@payloadcms/plugin-seo/client#OverviewComponent',\n },\n },\n },\n label: 'Overview',\n ...(
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Overview/index.tsx"],"sourcesContent":["import type { UIField } from 'payload'\n\ninterface FieldFunctionProps {\n descriptionOverrides?: {\n maxLength?: number\n minLength?: number\n }\n /**\n * Path to the description field to use for the preview\n *\n * @default 'meta.description'\n */\n descriptionPath?: string\n /**\n * Path to the image field to use for the preview\n *\n * @default 'meta.image'\n */\n imagePath?: string\n overrides?: Partial<UIField>\n titleOverrides?: {\n maxLength?: number\n minLength?: number\n }\n /**\n * Path to the title field to use for the preview\n *\n * @default 'meta.title'\n */\n titlePath?: string\n}\n\ntype FieldFunction = ({ overrides }: FieldFunctionProps) => UIField\n\nexport const OverviewField: FieldFunction = ({\n descriptionOverrides,\n descriptionPath,\n imagePath,\n overrides,\n titleOverrides,\n titlePath,\n}) => {\n return {\n name: 'overview',\n type: 'ui',\n admin: {\n components: {\n Field: {\n clientProps: {\n descriptionOverrides,\n descriptionPath,\n imagePath,\n titleOverrides,\n titlePath,\n },\n path: '@payloadcms/plugin-seo/client#OverviewComponent',\n },\n },\n },\n label: 'Overview',\n ...(overrides ?? {}),\n }\n}\n"],"names":["OverviewField","descriptionOverrides","descriptionPath","imagePath","overrides","titleOverrides","titlePath","name","type","admin","components","Field","clientProps","path","label"],"mappings":"AAkCA,OAAO,MAAMA,gBAA+B,CAAC,EAC3CC,oBAAoB,EACpBC,eAAe,EACfC,SAAS,EACTC,SAAS,EACTC,cAAc,EACdC,SAAS,EACV;IACC,OAAO;QACLC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXX;wBACAC;wBACAC;wBACAE;wBACAC;oBACF;oBACAO,MAAM;gBACR;YACF;QACF;QACAC,OAAO;QACP,GAAIV,aAAa,CAAC,CAAC;IACrB;AACF,EAAC"}
|
|
@@ -28,7 +28,7 @@ export const PreviewComponent = (props)=>{
|
|
|
28
28
|
hasPublishPermission: docInfo.hasPublishPermission,
|
|
29
29
|
hasSavePermission: docInfo.hasSavePermission,
|
|
30
30
|
initialData: docInfo.initialData,
|
|
31
|
-
initialState: reduceToSerializableFields(docInfo.initialState),
|
|
31
|
+
initialState: reduceToSerializableFields(docInfo.initialState ?? {}),
|
|
32
32
|
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
33
33
|
title: docInfo.title
|
|
34
34
|
}),
|
|
@@ -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 useConfig,\n useDocumentInfo,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\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 {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\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 endpoint = `${serverURL}${api}/plugin-seo/generate-url`\n\n const getHref = async () => {\n const genURLResponse = await fetch(endpoint, {\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: reduceToSerializableFields(docInfo.initialState),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateURL>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\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, serverURL, api])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\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","useConfig","useDocumentInfo","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useEffect","useState","PreviewComponent","props","descriptionPath","descriptionPathFromContext","hasGenerateURLFn","titlePath","titlePathFromContext","t","config","routes","api","serverURL","locale","fields","getData","docInfo","value","metaDescription","metaTitle","href","setHref","endpoint","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","marginBottom","color","background","borderRadius","boxShadow","maxWidth","padding","pointerEvents","width","a","textDecoration","h4","margin","p"],"mappings":"AAAA;;AAIA,SACEA,gBAAgB,EAChBC,SAAS,EACTC,eAAe,EACfC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAWlD,OAAO,MAAMC,mBAA2C,CAACC;IACvD,MAAM,EACJC,iBAAiBC,0BAA0B,EAC3CC,gBAAgB,EAChBC,WAAWC,oBAAoB,EAChC,GAAGL;IAEJ,MAAM,EAAEM,CAAC,EAAE,GAAGZ;IAEd,MAAM,EACJa,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAGpB;IAEJ,MAAMqB,SAASlB;IACf,MAAM,CAACmB,OAAO,GAAGvB;IACjB,MAAM,EAAEwB,OAAO,EAAE,GAAGrB;IACpB,MAAMsB,UAAUvB;IAEhB,MAAMU,kBAAkBC,8BAA8B;IACtD,MAAME,YAAYC,wBAAwB;IAE1C,MAAM,EACJ,CAACJ,gBAAgB,EAAE,EAAEc,OAAOC,eAAe,EAAE,GAAG,CAAC,CAAc,EAC/D,CAACZ,UAAU,EAAE,EAAEW,OAAOE,SAAS,EAAE,GAAG,CAAC,CAAc,EACpD,GAAGL;IAEJ,MAAM,CAACM,MAAMC,QAAQ,GAAGrB;IAExBD,UAAU;QACR,MAAMuB,WAAW,GAAGV,YAAYD,IAAI,wBAAwB,CAAC;QAE7D,MAAMY,UAAU;YACd,MAAMC,iBAAiB,MAAMC,MAAMH,UAAU;gBAC3CI,MAAMC,KAAKC,SAAS,CAAC;oBACnBC,IAAIb,QAAQa,EAAE;oBACdC,gBAAgBd,QAAQc,cAAc;oBACtCC,KAAKhB;oBACLiB,gBAAgBhB,QAAQgB,cAAc;oBACtCC,YAAYjB,QAAQiB,UAAU;oBAC9BC,sBAAsBlB,QAAQkB,oBAAoB;oBAClDC,mBAAmBnB,QAAQmB,iBAAiB;oBAC5CC,aAAapB,QAAQoB,WAAW;oBAChCC,cAAcxC,2BAA2BmB,QAAQqB,YAAY;
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FormField, UIField } from 'payload'\n\nimport {\n useAllFormFields,\n useConfig,\n useDocumentInfo,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\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 {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\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 endpoint = `${serverURL}${api}/plugin-seo/generate-url`\n\n const getHref = async () => {\n const genURLResponse = await fetch(endpoint, {\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: reduceToSerializableFields(docInfo.initialState ?? {}),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateURL>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\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, serverURL, api])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\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","useConfig","useDocumentInfo","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useEffect","useState","PreviewComponent","props","descriptionPath","descriptionPathFromContext","hasGenerateURLFn","titlePath","titlePathFromContext","t","config","routes","api","serverURL","locale","fields","getData","docInfo","value","metaDescription","metaTitle","href","setHref","endpoint","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","marginBottom","color","background","borderRadius","boxShadow","maxWidth","padding","pointerEvents","width","a","textDecoration","h4","margin","p"],"mappings":"AAAA;;AAIA,SACEA,gBAAgB,EAChBC,SAAS,EACTC,eAAe,EACfC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAWlD,OAAO,MAAMC,mBAA2C,CAACC;IACvD,MAAM,EACJC,iBAAiBC,0BAA0B,EAC3CC,gBAAgB,EAChBC,WAAWC,oBAAoB,EAChC,GAAGL;IAEJ,MAAM,EAAEM,CAAC,EAAE,GAAGZ;IAEd,MAAM,EACJa,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAGpB;IAEJ,MAAMqB,SAASlB;IACf,MAAM,CAACmB,OAAO,GAAGvB;IACjB,MAAM,EAAEwB,OAAO,EAAE,GAAGrB;IACpB,MAAMsB,UAAUvB;IAEhB,MAAMU,kBAAkBC,8BAA8B;IACtD,MAAME,YAAYC,wBAAwB;IAE1C,MAAM,EACJ,CAACJ,gBAAgB,EAAE,EAAEc,OAAOC,eAAe,EAAE,GAAG,CAAC,CAAc,EAC/D,CAACZ,UAAU,EAAE,EAAEW,OAAOE,SAAS,EAAE,GAAG,CAAC,CAAc,EACpD,GAAGL;IAEJ,MAAM,CAACM,MAAMC,QAAQ,GAAGrB;IAExBD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ACuC;wBACCZ,OAAO;4BACLa,QAAQ;wBACV;kCAEA,cAAA,KAACH;4BACCrC,MAAK;4BACL2B,OAAO;gCACLW,gBAAgB;4BAClB;sCAECvC;;;kCAGL,KAAC0C;wBACCd,OAAO;4BACLa,QAAQ;wBACV;kCAEC1C;;;;;;AAKX,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Preview/index.tsx"],"sourcesContent":["import type { UIField } from 'payload'\n\ninterface FieldFunctionProps {\n /**\n * Path to the description field to use for the preview\n *\n * @default 'meta.description'\n */\n descriptionPath?: string\n /**\n * Tell the component if the generate function is available as configured in the plugin config\n */\n hasGenerateFn?: boolean\n overrides?: Partial<UIField>\n /**\n * Path to the title field to use for the preview\n *\n * @default 'meta.title'\n */\n titlePath?: string\n}\n\ntype FieldFunction = ({ hasGenerateFn, overrides }: FieldFunctionProps) => UIField\n\nexport const PreviewField: FieldFunction = ({\n descriptionPath,\n hasGenerateFn = false,\n overrides,\n titlePath,\n}) => {\n return {\n name: 'preview',\n type: 'ui',\n admin: {\n components: {\n Field: {\n clientProps: {\n descriptionPath,\n hasGenerateURLFn: hasGenerateFn,\n titlePath,\n },\n path: '@payloadcms/plugin-seo/client#PreviewComponent',\n },\n },\n },\n label: 'Preview',\n ...(
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Preview/index.tsx"],"sourcesContent":["import type { UIField } from 'payload'\n\ninterface FieldFunctionProps {\n /**\n * Path to the description field to use for the preview\n *\n * @default 'meta.description'\n */\n descriptionPath?: string\n /**\n * Tell the component if the generate function is available as configured in the plugin config\n */\n hasGenerateFn?: boolean\n overrides?: Partial<UIField>\n /**\n * Path to the title field to use for the preview\n *\n * @default 'meta.title'\n */\n titlePath?: string\n}\n\ntype FieldFunction = ({ hasGenerateFn, overrides }: FieldFunctionProps) => UIField\n\nexport const PreviewField: FieldFunction = ({\n descriptionPath,\n hasGenerateFn = false,\n overrides,\n titlePath,\n}) => {\n return {\n name: 'preview',\n type: 'ui',\n admin: {\n components: {\n Field: {\n clientProps: {\n descriptionPath,\n hasGenerateURLFn: hasGenerateFn,\n titlePath,\n },\n path: '@payloadcms/plugin-seo/client#PreviewComponent',\n },\n },\n },\n label: 'Preview',\n ...(overrides ?? {}),\n }\n}\n"],"names":["PreviewField","descriptionPath","hasGenerateFn","overrides","titlePath","name","type","admin","components","Field","clientProps","hasGenerateURLFn","path","label"],"mappings":"AAwBA,OAAO,MAAMA,eAA8B,CAAC,EAC1CC,eAAe,EACfC,gBAAgB,KAAK,EACrBC,SAAS,EACTC,SAAS,EACV;IACC,OAAO;QACLC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXT;wBACAU,kBAAkBT;wBAClBE;oBACF;oBACAQ,MAAM;gBACR;YACF;QACF;QACAC,OAAO;QACP,GAAIV,aAAa,CAAC,CAAC;IACrB;AACF,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,EAAgC,MAAM,SAAS,CAAA;AAInE,OAAO,KAAK,EAKV,eAAe,EAChB,MAAM,YAAY,CAAA;AASnB,eAAO,MAAM,SAAS,iBACL,eAAe,cACrB,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAgC,MAAM,SAAS,CAAA;AAInE,OAAO,KAAK,EAKV,eAAe,EAChB,MAAM,YAAY,CAAA;AASnB,eAAO,MAAM,SAAS,iBACL,eAAe,cACrB,MAAM,KAAG,MAqQjB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
45
45
|
if (isEnabled) {
|
|
46
46
|
if (pluginConfig?.tabbedUI) {
|
|
47
47
|
// prevent issues with auth enabled collections having an email field that shouldn't be moved to the SEO tab
|
|
48
|
-
const emailField =
|
|
48
|
+
const emailField = collection.auth && !(typeof collection.auth === 'object' && collection.auth.disableLocalStrategy) && collection.fields?.find((field)=>'name' in field && field.name === 'email');
|
|
49
49
|
const hasOnlyEmailField = collection.fields?.length === 1 && emailField;
|
|
50
50
|
const seoTabs = hasOnlyEmailField ? [
|
|
51
51
|
{
|
|
@@ -103,14 +103,12 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
103
103
|
...config.endpoints ?? [],
|
|
104
104
|
{
|
|
105
105
|
handler: async (req)=>{
|
|
106
|
-
const data = await req.json();
|
|
107
|
-
|
|
108
|
-
req.data = data;
|
|
109
|
-
}
|
|
106
|
+
const data = await req.json?.();
|
|
107
|
+
const reqData = data ?? req.data;
|
|
110
108
|
const result = pluginConfig.generateTitle ? await pluginConfig.generateTitle({
|
|
111
109
|
...data,
|
|
112
|
-
collectionConfig:
|
|
113
|
-
globalConfig:
|
|
110
|
+
collectionConfig: config.collections?.find((c)=>c.slug === reqData.collectionSlug),
|
|
111
|
+
globalConfig: config.globals?.find((g)=>g.slug === reqData.globalSlug),
|
|
114
112
|
req
|
|
115
113
|
}) : '';
|
|
116
114
|
return new Response(JSON.stringify({
|
|
@@ -124,14 +122,12 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
124
122
|
},
|
|
125
123
|
{
|
|
126
124
|
handler: async (req)=>{
|
|
127
|
-
const data = await req.json();
|
|
128
|
-
|
|
129
|
-
req.data = data;
|
|
130
|
-
}
|
|
125
|
+
const data = await req.json?.();
|
|
126
|
+
const reqData = data ?? req.data;
|
|
131
127
|
const result = pluginConfig.generateDescription ? await pluginConfig.generateDescription({
|
|
132
128
|
...data,
|
|
133
|
-
collectionConfig:
|
|
134
|
-
globalConfig:
|
|
129
|
+
collectionConfig: config.collections?.find((c)=>c.slug === reqData.collectionSlug),
|
|
130
|
+
globalConfig: config.globals?.find((g)=>g.slug === reqData.globalSlug),
|
|
135
131
|
req
|
|
136
132
|
}) : '';
|
|
137
133
|
return new Response(JSON.stringify({
|
|
@@ -145,14 +141,12 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
145
141
|
},
|
|
146
142
|
{
|
|
147
143
|
handler: async (req)=>{
|
|
148
|
-
const data = await req.json();
|
|
149
|
-
|
|
150
|
-
req.data = data;
|
|
151
|
-
}
|
|
144
|
+
const data = await req.json?.();
|
|
145
|
+
const reqData = data ?? req.data;
|
|
152
146
|
const result = pluginConfig.generateURL ? await pluginConfig.generateURL({
|
|
153
147
|
...data,
|
|
154
|
-
collectionConfig:
|
|
155
|
-
globalConfig:
|
|
148
|
+
collectionConfig: config.collections?.find((c)=>c.slug === reqData.collectionSlug),
|
|
149
|
+
globalConfig: config.globals?.find((g)=>g.slug === reqData.globalSlug),
|
|
156
150
|
req
|
|
157
151
|
}) : '';
|
|
158
152
|
return new Response(JSON.stringify({
|
|
@@ -166,17 +160,17 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
166
160
|
},
|
|
167
161
|
{
|
|
168
162
|
handler: async (req)=>{
|
|
169
|
-
const data = await req.json();
|
|
170
|
-
|
|
171
|
-
req.data = data;
|
|
172
|
-
}
|
|
163
|
+
const data = await req.json?.();
|
|
164
|
+
const reqData = data ?? req.data;
|
|
173
165
|
const result = pluginConfig.generateImage ? await pluginConfig.generateImage({
|
|
174
166
|
...data,
|
|
175
|
-
collectionConfig:
|
|
176
|
-
globalConfig:
|
|
167
|
+
collectionConfig: config.collections?.find((c)=>c.slug === reqData.collectionSlug),
|
|
168
|
+
globalConfig: config.globals?.find((g)=>g.slug === reqData.globalSlug),
|
|
177
169
|
req
|
|
178
170
|
}) : '';
|
|
179
|
-
return new Response(
|
|
171
|
+
return new Response(JSON.stringify({
|
|
172
|
+
result
|
|
173
|
+
}), {
|
|
180
174
|
status: 200
|
|
181
175
|
});
|
|
182
176
|
},
|
|
@@ -195,7 +189,7 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
195
189
|
tabs: [
|
|
196
190
|
// append a new tab onto the end of the tabs array, if there is one at the first index
|
|
197
191
|
// if needed, create a new `Content` tab in the first index for this global's base fields
|
|
198
|
-
...global?.fields?.[0]
|
|
192
|
+
...global?.fields?.[0]?.type === 'tabs' && global?.fields?.[0].tabs ? global.fields[0].tabs : [
|
|
199
193
|
{
|
|
200
194
|
fields: [
|
|
201
195
|
...global?.fields || []
|
|
@@ -214,7 +208,7 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
214
208
|
...global,
|
|
215
209
|
fields: [
|
|
216
210
|
...seoTabs,
|
|
217
|
-
...global?.fields?.[0]
|
|
211
|
+
...global?.fields?.[0]?.type === 'tabs' ? global.fields.slice(1) : []
|
|
218
212
|
]
|
|
219
213
|
};
|
|
220
214
|
}
|
|
@@ -230,7 +224,7 @@ export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
|
230
224
|
}) || [],
|
|
231
225
|
i18n: {
|
|
232
226
|
...config.i18n,
|
|
233
|
-
translations: deepMergeSimple(translations, config.i18n?.translations)
|
|
227
|
+
translations: deepMergeSimple(translations, config.i18n?.translations ?? {})
|
|
234
228
|
}
|
|
235
229
|
};
|
|
236
230
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import type { Config, Field, GroupField, TabsField } from 'payload'\n\nimport { deepMergeSimple } from 'payload/shared'\n\nimport type {\n GenerateDescription,\n GenerateImage,\n GenerateTitle,\n GenerateURL,\n SEOPluginConfig,\n} from './types.js'\n\nimport { MetaDescriptionField } from './fields/MetaDescription/index.js'\nimport { MetaImageField } from './fields/MetaImage/index.js'\nimport { MetaTitleField } from './fields/MetaTitle/index.js'\nimport { OverviewField } from './fields/Overview/index.js'\nimport { PreviewField } from './fields/Preview/index.js'\nimport { translations } from './translations/index.js'\n\nexport const seoPlugin =\n (pluginConfig: SEOPluginConfig) =>\n (config: Config): Config => {\n const defaultFields: Field[] = [\n OverviewField({}),\n MetaTitleField({\n hasGenerateFn: typeof pluginConfig?.generateTitle === 'function',\n }),\n MetaDescriptionField({\n hasGenerateFn: typeof pluginConfig?.generateDescription === 'function',\n }),\n ...(pluginConfig?.uploadsCollection\n ? [\n MetaImageField({\n hasGenerateFn: typeof pluginConfig?.generateImage === 'function',\n relationTo: pluginConfig.uploadsCollection as string,\n }),\n ]\n : []),\n PreviewField({\n hasGenerateFn: typeof pluginConfig?.generateURL === 'function',\n }),\n ]\n\n const seoFields: GroupField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n ...(pluginConfig?.fields && typeof pluginConfig.fields === 'function'\n ? pluginConfig.fields({ defaultFields })\n : defaultFields),\n ],\n interfaceName: pluginConfig.interfaceName,\n label: 'SEO',\n },\n ]\n\n return {\n ...config,\n collections:\n config.collections?.map((collection) => {\n const { slug } = collection\n const isEnabled = pluginConfig?.collections?.includes(slug)\n\n if (isEnabled) {\n if (pluginConfig?.tabbedUI) {\n // prevent issues with auth enabled collections having an email field that shouldn't be moved to the SEO tab\n const emailField =\n (collection.auth ||\n !(typeof collection.auth === 'object' && collection.auth.disableLocalStrategy)) &&\n collection.fields?.find((field) => 'name' in field && field.name === 'email')\n const hasOnlyEmailField = collection.fields?.length === 1 && emailField\n\n const seoTabs: TabsField[] = hasOnlyEmailField\n ? [\n {\n type: 'tabs',\n tabs: [\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n : [\n {\n type: 'tabs',\n tabs: [\n // append a new tab onto the end of the tabs array, if there is one at the first index\n // if needed, create a new `Content` tab in the first index for this collection's base fields\n ...(collection?.fields?.[0]?.type === 'tabs' &&\n collection?.fields?.[0]?.tabs\n ? collection.fields[0].tabs\n : [\n {\n fields: [\n ...(emailField\n ? collection.fields.filter(\n (field) => 'name' in field && field.name !== 'email',\n )\n : collection.fields),\n ],\n label: collection?.labels?.singular || 'Content',\n },\n ]),\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n\n return {\n ...collection,\n fields: [\n ...(emailField ? [emailField] : []),\n ...seoTabs,\n ...(collection?.fields?.[0]?.type === 'tabs' ? collection.fields.slice(1) : []),\n ],\n }\n }\n\n return {\n ...collection,\n fields: [...(collection?.fields || []), ...seoFields],\n }\n }\n\n return collection\n }) || [],\n endpoints: [\n ...(config.endpoints ?? []),\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateTitle\n ? await pluginConfig.generateTitle({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } satisfies Parameters<GenerateTitle>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-title',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateDescription\n ? await pluginConfig.generateDescription({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } satisfies Parameters<GenerateDescription>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-description',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateURL\n ? await pluginConfig.generateURL({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } satisfies Parameters<GenerateURL>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-url',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateImage\n ? await pluginConfig.generateImage({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } as Parameters<GenerateImage>[0])\n : ''\n return new Response(result, { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-image',\n },\n ],\n globals:\n config.globals?.map((global) => {\n const { slug } = global\n const isEnabled = pluginConfig?.globals?.includes(slug)\n\n if (isEnabled) {\n if (pluginConfig?.tabbedUI) {\n const seoTabs: TabsField[] = [\n {\n type: 'tabs',\n tabs: [\n // append a new tab onto the end of the tabs array, if there is one at the first index\n // if needed, create a new `Content` tab in the first index for this global's base fields\n ...(global?.fields?.[0].type === 'tabs' && global?.fields?.[0].tabs\n ? global.fields[0].tabs\n : [\n {\n fields: [...(global?.fields || [])],\n label: global?.label || 'Content',\n },\n ]),\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n\n return {\n ...global,\n fields: [\n ...seoTabs,\n ...(global?.fields?.[0].type === 'tabs' ? global.fields.slice(1) : []),\n ],\n }\n }\n\n return {\n ...global,\n fields: [...(global?.fields || []), ...seoFields],\n }\n }\n\n return global\n }) || [],\n i18n: {\n ...config.i18n,\n translations: deepMergeSimple(translations, config.i18n?.translations),\n },\n }\n }\n"],"names":["deepMergeSimple","MetaDescriptionField","MetaImageField","MetaTitleField","OverviewField","PreviewField","translations","seoPlugin","pluginConfig","config","defaultFields","hasGenerateFn","generateTitle","generateDescription","uploadsCollection","generateImage","relationTo","generateURL","seoFields","name","type","fields","interfaceName","label","collections","map","collection","slug","isEnabled","includes","tabbedUI","emailField","auth","disableLocalStrategy","find","field","hasOnlyEmailField","length","seoTabs","tabs","filter","labels","singular","slice","endpoints","handler","req","data","json","result","collectionConfig","collectionSlug","c","globalConfig","globalSlug","globals","g","Response","JSON","stringify","status","method","path","global","i18n"],"mappings":"AAEA,SAASA,eAAe,QAAQ,iBAAgB;AAUhD,SAASC,oBAAoB,QAAQ,oCAAmC;AACxE,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,SAASC,YAAY,QAAQ,4BAA2B;AACxD,SAASC,YAAY,QAAQ,0BAAyB;AAEtD,OAAO,MAAMC,YACX,CAACC,eACD,CAACC;QACC,MAAMC,gBAAyB;YAC7BN,cAAc,CAAC;YACfD,eAAe;gBACbQ,eAAe,OAAOH,cAAcI,kBAAkB;YACxD;YACAX,qBAAqB;gBACnBU,eAAe,OAAOH,cAAcK,wBAAwB;YAC9D;eACIL,cAAcM,oBACd;gBACEZ,eAAe;oBACbS,eAAe,OAAOH,cAAcO,kBAAkB;oBACtDC,YAAYR,aAAaM,iBAAiB;gBAC5C;aACD,GACD,EAAE;YACNT,aAAa;gBACXM,eAAe,OAAOH,cAAcS,gBAAgB;YACtD;SACD;QAED,MAAMC,YAA0B;YAC9B;gBACEC,MAAM;gBACNC,MAAM;gBACNC,QAAQ;uBACFb,cAAca,UAAU,OAAOb,aAAaa,MAAM,KAAK,aACvDb,aAAaa,MAAM,CAAC;wBAAEX;oBAAc,KACpCA;iBACL;gBACDY,eAAed,aAAac,aAAa;gBACzCC,OAAO;YACT;SACD;QAED,OAAO;YACL,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;gBACF;gBAEA,OAAO6C;YACT,MAAM,EAAE;YACVC,MAAM;gBACJ,GAAGvD,OAAOuD,IAAI;gBACd1D,cAAcN,gBAAgBM,cAAcG,OAAOuD,IAAI,EAAE1D;YAC3D;QACF;IACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import type { Config, Field, GroupField, TabsField } from 'payload'\n\nimport { deepMergeSimple } from 'payload/shared'\n\nimport type {\n GenerateDescription,\n GenerateImage,\n GenerateTitle,\n GenerateURL,\n SEOPluginConfig,\n} from './types.js'\n\nimport { MetaDescriptionField } from './fields/MetaDescription/index.js'\nimport { MetaImageField } from './fields/MetaImage/index.js'\nimport { MetaTitleField } from './fields/MetaTitle/index.js'\nimport { OverviewField } from './fields/Overview/index.js'\nimport { PreviewField } from './fields/Preview/index.js'\nimport { translations } from './translations/index.js'\n\nexport const seoPlugin =\n (pluginConfig: SEOPluginConfig) =>\n (config: Config): Config => {\n const defaultFields: Field[] = [\n OverviewField({}),\n MetaTitleField({\n hasGenerateFn: typeof pluginConfig?.generateTitle === 'function',\n }),\n MetaDescriptionField({\n hasGenerateFn: typeof pluginConfig?.generateDescription === 'function',\n }),\n ...(pluginConfig?.uploadsCollection\n ? [\n MetaImageField({\n hasGenerateFn: typeof pluginConfig?.generateImage === 'function',\n relationTo: pluginConfig.uploadsCollection as string,\n }),\n ]\n : []),\n PreviewField({\n hasGenerateFn: typeof pluginConfig?.generateURL === 'function',\n }),\n ]\n\n const seoFields: GroupField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n ...(pluginConfig?.fields && typeof pluginConfig.fields === 'function'\n ? pluginConfig.fields({ defaultFields })\n : defaultFields),\n ],\n interfaceName: pluginConfig.interfaceName,\n label: 'SEO',\n },\n ]\n\n return {\n ...config,\n collections:\n config.collections?.map((collection) => {\n const { slug } = collection\n const isEnabled = pluginConfig?.collections?.includes(slug)\n\n if (isEnabled) {\n if (pluginConfig?.tabbedUI) {\n // prevent issues with auth enabled collections having an email field that shouldn't be moved to the SEO tab\n const emailField =\n collection.auth &&\n !(typeof collection.auth === 'object' && collection.auth.disableLocalStrategy) &&\n collection.fields?.find((field) => 'name' in field && field.name === 'email')\n const hasOnlyEmailField = collection.fields?.length === 1 && emailField\n\n const seoTabs: TabsField[] = hasOnlyEmailField\n ? [\n {\n type: 'tabs',\n tabs: [\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n : [\n {\n type: 'tabs',\n tabs: [\n // append a new tab onto the end of the tabs array, if there is one at the first index\n // if needed, create a new `Content` tab in the first index for this collection's base fields\n ...(collection?.fields?.[0]?.type === 'tabs' &&\n collection?.fields?.[0]?.tabs\n ? collection.fields[0].tabs\n : [\n {\n fields: [\n ...(emailField\n ? collection.fields.filter(\n (field) => 'name' in field && field.name !== 'email',\n )\n : collection.fields),\n ],\n label: collection?.labels?.singular || 'Content',\n },\n ]),\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n\n return {\n ...collection,\n fields: [\n ...(emailField ? [emailField] : []),\n ...seoTabs,\n ...(collection?.fields?.[0]?.type === 'tabs' ? collection.fields.slice(1) : []),\n ],\n }\n }\n\n return {\n ...collection,\n fields: [...(collection?.fields || []), ...seoFields],\n }\n }\n\n return collection\n }) || [],\n endpoints: [\n ...(config.endpoints ?? []),\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json?.()\n\n const reqData = data ?? req.data\n\n const result = pluginConfig.generateTitle\n ? await pluginConfig.generateTitle({\n ...data,\n collectionConfig: config.collections?.find(\n (c) => c.slug === reqData.collectionSlug,\n ),\n globalConfig: config.globals?.find((g) => g.slug === reqData.globalSlug),\n req,\n } satisfies Parameters<GenerateTitle>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-title',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json?.()\n\n const reqData = data ?? req.data\n\n const result = pluginConfig.generateDescription\n ? await pluginConfig.generateDescription({\n ...data,\n collectionConfig: config.collections?.find(\n (c) => c.slug === reqData.collectionSlug,\n ),\n globalConfig: config.globals?.find((g) => g.slug === reqData.globalSlug),\n req,\n } satisfies Parameters<GenerateDescription>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-description',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json?.()\n\n const reqData = data ?? req.data\n\n const result = pluginConfig.generateURL\n ? await pluginConfig.generateURL({\n ...data,\n collectionConfig: config.collections?.find(\n (c) => c.slug === reqData.collectionSlug,\n ),\n globalConfig: config.globals?.find((g) => g.slug === reqData.globalSlug),\n req,\n } satisfies Parameters<GenerateURL>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-url',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json?.()\n\n const reqData = data ?? req.data\n\n const result = pluginConfig.generateImage\n ? await pluginConfig.generateImage({\n ...data,\n collectionConfig: config.collections?.find(\n (c) => c.slug === reqData.collectionSlug,\n ),\n globalConfig: config.globals?.find((g) => g.slug === reqData.globalSlug),\n req,\n } satisfies Parameters<GenerateImage>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-image',\n },\n ],\n globals:\n config.globals?.map((global) => {\n const { slug } = global\n const isEnabled = pluginConfig?.globals?.includes(slug)\n\n if (isEnabled) {\n if (pluginConfig?.tabbedUI) {\n const seoTabs: TabsField[] = [\n {\n type: 'tabs',\n tabs: [\n // append a new tab onto the end of the tabs array, if there is one at the first index\n // if needed, create a new `Content` tab in the first index for this global's base fields\n ...(global?.fields?.[0]?.type === 'tabs' && global?.fields?.[0].tabs\n ? global.fields[0].tabs\n : [\n {\n fields: [...(global?.fields || [])],\n label: global?.label || 'Content',\n },\n ]),\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n\n return {\n ...global,\n fields: [\n ...seoTabs,\n ...(global?.fields?.[0]?.type === 'tabs' ? global.fields.slice(1) : []),\n ],\n }\n }\n\n return {\n ...global,\n fields: [...(global?.fields || []), ...seoFields],\n }\n }\n\n return global\n }) || [],\n i18n: {\n ...config.i18n,\n translations: deepMergeSimple(translations, config.i18n?.translations ?? {}),\n },\n }\n }\n"],"names":["deepMergeSimple","MetaDescriptionField","MetaImageField","MetaTitleField","OverviewField","PreviewField","translations","seoPlugin","pluginConfig","config","defaultFields","hasGenerateFn","generateTitle","generateDescription","uploadsCollection","generateImage","relationTo","generateURL","seoFields","name","type","fields","interfaceName","label","collections","map","collection","slug","isEnabled","includes","tabbedUI","emailField","auth","disableLocalStrategy","find","field","hasOnlyEmailField","length","seoTabs","tabs","filter","labels","singular","slice","endpoints","handler","req","data","json","reqData","result","collectionConfig","c","collectionSlug","globalConfig","globals","g","globalSlug","Response","JSON","stringify","status","method","path","global","i18n"],"mappings":"AAEA,SAASA,eAAe,QAAQ,iBAAgB;AAUhD,SAASC,oBAAoB,QAAQ,oCAAmC;AACxE,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,SAASC,YAAY,QAAQ,4BAA2B;AACxD,SAASC,YAAY,QAAQ,0BAAyB;AAEtD,OAAO,MAAMC,YACX,CAACC,eACD,CAACC;QACC,MAAMC,gBAAyB;YAC7BN,cAAc,CAAC;YACfD,eAAe;gBACbQ,eAAe,OAAOH,cAAcI,kBAAkB;YACxD;YACAX,qBAAqB;gBACnBU,eAAe,OAAOH,cAAcK,wBAAwB;YAC9D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gBACF;gBAEA,OAAO8C;YACT,MAAM,EAAE;YACVC,MAAM;gBACJ,GAAGxD,OAAOwD,IAAI;gBACd3D,cAAcN,gBAAgBM,cAAcG,OAAOwD,IAAI,EAAE3D,gBAAgB,CAAC;YAC5E;QACF;IACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-seo",
|
|
3
|
-
"version": "3.34.0
|
|
3
|
+
"version": "3.34.0",
|
|
4
4
|
"description": "SEO plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
"dist"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@payloadcms/
|
|
58
|
-
"@payloadcms/
|
|
57
|
+
"@payloadcms/translations": "3.34.0",
|
|
58
|
+
"@payloadcms/ui": "3.34.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@types/react": "19.0
|
|
62
|
-
"@types/react-dom": "19.
|
|
61
|
+
"@types/react": "19.1.0",
|
|
62
|
+
"@types/react-dom": "19.1.2",
|
|
63
63
|
"@payloadcms/eslint-config": "3.28.0",
|
|
64
|
-
"@payloadcms/next": "3.34.0
|
|
65
|
-
"payload": "3.34.0
|
|
64
|
+
"@payloadcms/next": "3.34.0",
|
|
65
|
+
"payload": "3.34.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
69
69
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
70
|
-
"payload": "3.34.0
|
|
70
|
+
"payload": "3.34.0"
|
|
71
71
|
},
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"registry": "https://registry.npmjs.org/"
|