@payloadcms/plugin-seo 3.0.0-canary.aceaf5d → 3.0.0-canary.af2bebe

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.
@@ -1,7 +1,7 @@
1
1
  import type { TextareaFieldProps } from 'payload';
2
2
  import React from 'react';
3
3
  type MetaDescriptionProps = {
4
- hasGenerateDescriptionFn: boolean;
4
+ readonly hasGenerateDescriptionFn: boolean;
5
5
  } & TextareaFieldProps;
6
6
  export declare const MetaDescriptionComponent: React.FC<MetaDescriptionProps>;
7
7
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"MetaDescriptionComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAYjD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAU1C,KAAK,oBAAoB,GAAG;IAC1B,wBAAwB,EAAE,OAAO,CAAA;CAClC,GAAG,kBAAkB,CAAA;AAEtB,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAqInE,CAAA"}
1
+ {"version":3,"file":"MetaDescriptionComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAYjD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAU1C,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,wBAAwB,EAAE,OAAO,CAAA;CAC3C,GAAG,kBAAkB,CAAA;AAEtB,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA4InE,CAAA"}
@@ -20,11 +20,16 @@ export const MetaDescriptionComponent = (props)=>{
20
20
  if (!hasGenerateDescriptionFn) return;
21
21
  const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description', {
22
22
  body: JSON.stringify({
23
- ...docInfo,
24
- doc: {
25
- ...getData()
26
- },
27
- locale: typeof locale === 'object' ? locale?.code : locale
23
+ id: docInfo.id,
24
+ slug: docInfo.slug,
25
+ doc: getData(),
26
+ docPermissions: docInfo.docPermissions,
27
+ hasPublishPermission: docInfo.hasPublishPermission,
28
+ hasSavePermission: docInfo.hasSavePermission,
29
+ initialData: docInfo.initialData,
30
+ initialState: docInfo.initialState,
31
+ locale: typeof locale === 'object' ? locale?.code : locale,
32
+ title: docInfo.title
28
33
  }),
29
34
  credentials: 'include',
30
35
  headers: {
@@ -57,6 +62,7 @@ export const MetaDescriptionComponent = (props)=>{
57
62
  children: [
58
63
  /*#__PURE__*/ _jsx(FieldLabel, {
59
64
  Label: Label,
65
+ field: null,
60
66
  label: label,
61
67
  ...labelProps || {}
62
68
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextareaFieldProps } from 'payload'\n\nimport {\n FieldLabel,\n TextareaInput,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateDescription } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\n\nconst { maxLength, minLength } = defaults.description\n\ntype MetaDescriptionProps = {\n hasGenerateDescriptionFn: boolean\n} & TextareaFieldProps\n\nexport const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n required,\n },\n hasGenerateDescriptionFn,\n labelProps,\n } = props\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const field: FieldType<string> = useField({\n path: pathFromContext,\n } as Options)\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateDescription = useCallback(async () => {\n if (!hasGenerateDescriptionFn) return\n\n const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...getData() },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Omit<Parameters<GenerateDescription>[0], 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedDescription } = await genDescriptionResponse.json()\n\n setValue(generatedDescription || '')\n }, [hasGenerateDescriptionFn, docInfo, getData, locale, setValue])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel Label={Label} label={label} {...(labelProps || {})} />\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateDescription()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipDescription', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextareaInput\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n label={label}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextareaInput","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","description","MetaDescriptionComponent","props","field","admin","components","Label","label","required","hasGenerateDescriptionFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateDescription","genDescriptionResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedDescription","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","Component","RenderedComponent","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,aAAa,EACbC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAE7D,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGH,SAASI,WAAW;AAMrD,OAAO,MAAMC,2BAA2D,CAACC;IACvE,MAAM,EACJC,OAAO,EACLC,OAAO,EACLC,YAAY,EAAEC,KAAK,EAAE,EACtB,EACDC,KAAK,EACLC,QAAQ,EACT,EACDC,wBAAwB,EACxBC,UAAU,EACX,GAAGR;IACJ,MAAM,EAAES,MAAMC,eAAe,EAAE,GAAGtB;IAElC,MAAM,EAAEuB,CAAC,EAAE,GAAGpB;IAEd,MAAMqB,SAAStB;IACf,MAAM,EAAEuB,OAAO,EAAE,GAAGxB;IACpB,MAAMyB,UAAU5B;IAEhB,MAAMe,QAA2Bd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CC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACnD;oBACCoE,OAAO;wBACLL,MAAM;wBACNM,WAAW;wBACXC,mBAAmBxC;oBACrB;oBACAV,OAAOA;oBACPmD,UAAUxC;oBACVP,MAAMC;oBACNJ,UAAUA;oBACVW,WAAWA;oBACXiB,OAAO;wBACLC,cAAc;oBAChB;oBACAjB,OAAOA;;;0BAGX,KAACe;gBACCC,OAAO;oBACLuB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAAChE;oBAAgBC,WAAWA;oBAAWC,WAAWA;oBAAW+D,MAAM1C;;;;;AAI3E,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextareaFieldProps } from 'payload'\n\nimport {\n FieldLabel,\n TextareaInput,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateDescription } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\n\nconst { maxLength, minLength } = defaults.description\n\ntype MetaDescriptionProps = {\n readonly hasGenerateDescriptionFn: boolean\n} & TextareaFieldProps\n\nexport const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n required,\n },\n hasGenerateDescriptionFn,\n labelProps,\n } = props\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const field: FieldType<string> = useField({\n path: pathFromContext,\n } as Options)\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateDescription = useCallback(async () => {\n if (!hasGenerateDescriptionFn) return\n\n const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description', {\n body: JSON.stringify({\n id: docInfo.id,\n slug: docInfo.slug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<Parameters<GenerateDescription>[0], 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedDescription } = await genDescriptionResponse.json()\n\n setValue(generatedDescription || '')\n }, [hasGenerateDescriptionFn, docInfo, getData, locale, setValue])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel Label={Label} field={null} label={label} {...(labelProps || {})} />\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateDescription()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipDescription', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextareaInput\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n label={label}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextareaInput","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","description","MetaDescriptionComponent","props","field","admin","components","Label","label","required","hasGenerateDescriptionFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateDescription","genDescriptionResponse","fetch","body","JSON","stringify","id","slug","doc","docPermissions","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","result","generatedDescription","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","Component","RenderedComponent","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,aAAa,EACbC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAE7D,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGH,SAASI,WAAW;AAMrD,OAAO,MAAMC,2BAA2D,CAACC;IACvE,MAAM,EACJC,OAAO,EACLC,OAAO,EACLC,YAAY,EAAEC,KAAK,EAAE,EACtB,EACDC,KAAK,EACLC,QAAQ,EACT,EACDC,wBAAwB,EACxBC,UAAU,EACX,GAAGR;IACJ,MAAM,EAAES,MAAMC,eAAe,EAAE,GAAGtB;IAElC,MAAM,EAAEuB,CAAC,EAAE,GAAGpB;IAEd,MAAMqB,SAAStB;IACf,MAAM,EAAEu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QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJ7C,EAAE;;;;;;kCAKX,MAAC8B;wBACCC,OAAO;4BACLU,OAAO;wBACT;;4BAECzC,EAAE,mCAAmC;gCAAEf;gCAAWC;4BAAU;0CAC7D,KAAC4D;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAENjD,EAAE;;;;;;0BAIT,KAAC8B;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAAC3D;oBACC4E,OAAO;wBACLL,MAAM;wBACNM,WAAW;wBACXC,mBAAmBhD;oBACrB;oBACAV,OAAOA;oBACP2D,UAAUhD;oBACVP,MAAMC;oBACNJ,UAAUA;oBACVW,WAAWA;oBACXyB,OAAO;wBACLC,cAAc;oBAChB;oBACAzB,OAAOA;;;0BAGX,KAACuB;gBACCC,OAAO;oBACLuB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACxE;oBAAgBC,WAAWA;oBAAWC,WAAWA;oBAAWuE,MAAMlD;;;;;AAI3E,EAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { UploadFieldProps } from '@payloadcms/ui';
2
2
  import React from 'react';
3
3
  type MetaImageProps = {
4
- hasGenerateImageFn: boolean;
4
+ readonly hasGenerateImageFn: boolean;
5
5
  } & UploadFieldProps;
6
6
  export declare const MetaImageComponent: React.FC<MetaImageProps>;
7
7
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"MetaImageComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAa1E,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,KAAK,cAAc,GAAG;IACpB,kBAAkB,EAAE,OAAO,CAAA;CAC5B,GAAG,gBAAgB,CAAA;AAEpB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAsJvD,CAAA"}
1
+ {"version":3,"file":"MetaImageComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAa1E,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,gBAAgB,CAAA;AAEpB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA6JvD,CAAA"}
@@ -19,11 +19,16 @@ export const MetaImageComponent = (props)=>{
19
19
  if (!hasGenerateImageFn) return;
20
20
  const genImageResponse = await fetch('/api/plugin-seo/generate-image', {
21
21
  body: JSON.stringify({
22
- ...docInfo,
23
- doc: {
24
- ...getData()
25
- },
26
- locale: typeof locale === 'object' ? locale?.code : locale
22
+ id: docInfo.id,
23
+ slug: docInfo.slug,
24
+ doc: getData(),
25
+ docPermissions: docInfo.docPermissions,
26
+ hasPublishPermission: docInfo.hasPublishPermission,
27
+ hasSavePermission: docInfo.hasSavePermission,
28
+ initialData: docInfo.initialData,
29
+ initialState: docInfo.initialState,
30
+ locale: typeof locale === 'object' ? locale?.code : locale,
31
+ title: docInfo.title
27
32
  }),
28
33
  credentials: 'include',
29
34
  headers: {
@@ -60,6 +65,7 @@ export const MetaImageComponent = (props)=>{
60
65
  children: [
61
66
  /*#__PURE__*/ _jsx(FieldLabel, {
62
67
  Label: Label,
68
+ field: null,
63
69
  label: label,
64
70
  ...labelProps || {}
65
71
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options, UploadFieldProps } from '@payloadcms/ui'\n\nimport {\n FieldLabel,\n UploadInput,\n useConfig,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateImage } from '../../types.js'\n\nimport { Pill } from '../../ui/Pill.js'\n\ntype MetaImageProps = {\n hasGenerateImageFn: boolean\n} & UploadFieldProps\n\nexport const MetaImageComponent: React.FC<MetaImageProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n relationTo,\n required,\n },\n hasGenerateImageFn,\n labelProps,\n } = props || {}\n const { path: pathFromContext } = useFieldProps()\n\n const field: FieldType<string> = useField({ ...props, path: pathFromContext } as Options)\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateImage = useCallback(async () => {\n if (!hasGenerateImageFn) return\n\n const genImageResponse = await fetch('/api/plugin-seo/generate-image', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...getData() },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Omit<Parameters<GenerateImage>[0], 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const generatedImage = await genImageResponse.text()\n\n setValue(generatedImage || '')\n }, [hasGenerateImageFn, docInfo, getData, locale, setValue])\n\n const hasImage = Boolean(value)\n\n const { config } = useConfig()\n\n const { collections, routes: { api } = {}, serverURL } = config\n\n const collection = collections?.find((coll) => coll.slug === relationTo) || undefined\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel Label={Label} label={label} {...(labelProps || {})} />\n {hasGenerateImageFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateImage()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n {hasGenerateImageFn && (\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:imageAutoGenerationTip')}\n </div>\n )}\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <UploadInput\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n api={api}\n collection={collection}\n filterOptions={field.filterOptions}\n label={undefined}\n onChange={(incomingImage) => {\n if (incomingImage !== null) {\n const { id: incomingID } = incomingImage\n setValue(incomingID)\n } else {\n setValue(null)\n }\n }}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <Pill\n backgroundColor={hasImage ? 'green' : 'red'}\n color=\"white\"\n label={hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')}\n />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","UploadInput","useConfig","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","Pill","MetaImageComponent","props","field","admin","components","Label","label","relationTo","required","hasGenerateImageFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateImage","genImageResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","generatedImage","text","hasImage","Boolean","config","collections","routes","api","serverURL","collection","find","coll","slug","undefined","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","Error","Component","RenderedComponent","filterOptions","onChange","incomingImage","id","incomingID","alignItems","display","width"],"mappings":"AAAA;;AAIA,SACEA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0B;gBACCC,OAAO;oBACLuB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACzE;oBACCwD,iBAAiBrB,WAAW,UAAU;oBACtCuB,OAAM;oBACNnD,OAAO4B,WAAWrB,EAAE,qBAAqBA,EAAE;;;;;AAKrD,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options, UploadFieldProps } from '@payloadcms/ui'\n\nimport {\n FieldLabel,\n UploadInput,\n useConfig,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateImage } from '../../types.js'\n\nimport { Pill } from '../../ui/Pill.js'\n\ntype MetaImageProps = {\n readonly hasGenerateImageFn: boolean\n} & UploadFieldProps\n\nexport const MetaImageComponent: React.FC<MetaImageProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n relationTo,\n required,\n },\n hasGenerateImageFn,\n labelProps,\n } = props || {}\n const { path: pathFromContext } = useFieldProps()\n\n const field: FieldType<string> = useField({ ...props, path: pathFromContext } as Options)\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateImage = useCallback(async () => {\n if (!hasGenerateImageFn) return\n\n const genImageResponse = await fetch('/api/plugin-seo/generate-image', {\n body: JSON.stringify({\n id: docInfo.id,\n slug: docInfo.slug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<Parameters<GenerateImage>[0], 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const generatedImage = await genImageResponse.text()\n\n setValue(generatedImage || '')\n }, [hasGenerateImageFn, docInfo, getData, locale, setValue])\n\n const hasImage = Boolean(value)\n\n const { config } = useConfig()\n\n const { collections, routes: { api } = {}, serverURL } = config\n\n const collection = collections?.find((coll) => coll.slug === relationTo) || undefined\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel Label={Label} field={null} label={label} {...(labelProps || {})} />\n {hasGenerateImageFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateImage()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n {hasGenerateImageFn && (\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:imageAutoGenerationTip')}\n </div>\n )}\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <UploadInput\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n api={api}\n collection={collection}\n filterOptions={field.filterOptions}\n label={undefined}\n onChange={(incomingImage) => {\n if (incomingImage !== null) {\n const { id: incomingID } = incomingImage\n setValue(incomingID)\n } else {\n setValue(null)\n }\n }}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <Pill\n backgroundColor={hasImage ? 'green' : 'red'}\n color=\"white\"\n label={hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')}\n />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","UploadInput","useConfig","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","Pill","MetaImageComponent","props","field","admin","components","Label","label","relationTo","required","hasGenerateImageFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateImage","genImageResponse","fetch","body","JSON","stringify","id","slug","doc","docPermissions","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","generatedImage","text","hasImage","Boolean","config","collections","routes","api","serverURL","collection","find","coll","undefined","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","Error","Component","RenderedComponent","filterOptions","onChange","incomingImage","incomingID","alignItems","display","width"],"mappings":"AAAA;;AAIA,SACEA,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,IAAI,QAAQ,mBAAkB;AAMvC,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EACLC,OAAO,EACLC,YAAY,EAAEC,KAAK,EAAE,EACtB,EACDC,KAAK,EACLC,UAAU,EACVC,QAAQ,EACT,EACDC,kBAAkB,EAClBC,UAAU,EACX,GAAGT,SAAS,CAAC;IACd,MAAM,EAAEU,MAAMC,eAAe,EAAE,GAAGnB;IAElC,MAAMS,QAA2BV,SAAS;QAAE,GAAGS,KAAK;QAAEU,MAAMC;IAAgB;IAE5E,MAAM,EAAEC,CAAC,EAAE,GAAGjB;IAEd,MAAMkB,SAASnB;IACf,MAAM,EAAEoB,OAAO,EAAE,GAAGrB;IACpB,MAAMsB,UAAUzB;IAEhB,MAAM,EAAE0B,YAAY,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,KAAK,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CACP,KAAKvC;wCACP;wCACAiC,OAAO;4CACLO,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJvD,EAAE;;;;;;oBAKVJ,oCACC,KAAC4C;wBACCC,OAAO;4BACLU,OAAO;wBACT;kCAECnD,EAAE;;;;0BAIT,KAACwC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACnE;oBACCgF,OAAO;wBACLD,MAAM;wBACNE,WAAW;wBACXC,mBAAmBtD;oBACrB;oBACA8B,KAAKA;oBACLE,YAAYA;oBACZuB,eAAetE,MAAMsE,aAAa;oBAClClE,OAAO8C;oBACPqB,UAAU,CAACC;wBACT,IAAIA,kBAAkB,MAAM;4BAC1B,MAAM,EAAE/C,IAAIgD,UAAU,EAAE,GAAGD;4BAC3BxD,SAASyD;wBACX,OAAO;4BACLzD,SAAS;wBACX;oBACF;oBACAX,YAAYA;oBACZC,UAAUA;oBACVwC,WAAWA;oBACX7B,WAAWA;oBACXmC,OAAO;wBACLC,cAAc;oBAChB;oBACAnC,OAAOA;;;0BAGX,KAACiC;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAAC/E;oBACC+D,iBAAiBpB,WAAW,UAAU;oBACtCsB,OAAM;oBACN1D,OAAOoC,WAAW7B,EAAE,qBAAqBA,EAAE;;;;;AAKrD,EAAC"}
@@ -2,7 +2,7 @@ import type { TextFieldProps } from 'payload';
2
2
  import React from 'react';
3
3
  import '../index.scss';
4
4
  type MetaTitleProps = {
5
- hasGenerateTitleFn: boolean;
5
+ readonly hasGenerateTitleFn: boolean;
6
6
  } & TextFieldProps;
7
7
  export declare const MetaTitleComponent: React.FC<MetaTitleProps>;
8
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"MetaTitleComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAY7C,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,eAAe,CAAA;AAItB,KAAK,cAAc,GAAG;IACpB,kBAAkB,EAAE,OAAO,CAAA;CAC5B,GAAG,cAAc,CAAA;AAElB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAsIvD,CAAA"}
1
+ {"version":3,"file":"MetaTitleComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAY7C,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,eAAe,CAAA;AAItB,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,cAAc,CAAA;AAElB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA6IvD,CAAA"}
@@ -21,11 +21,16 @@ export const MetaTitleComponent = (props)=>{
21
21
  if (!hasGenerateTitleFn) return;
22
22
  const genTitleResponse = await fetch('/api/plugin-seo/generate-title', {
23
23
  body: JSON.stringify({
24
- ...docInfo,
25
- doc: {
26
- ...getData()
27
- },
28
- locale: typeof locale === 'object' ? locale?.code : locale
24
+ id: docInfo.id,
25
+ slug: docInfo.slug,
26
+ doc: getData(),
27
+ docPermissions: docInfo.docPermissions,
28
+ hasPublishPermission: docInfo.hasPublishPermission,
29
+ hasSavePermission: docInfo.hasSavePermission,
30
+ initialData: docInfo.initialData,
31
+ initialState: docInfo.initialState,
32
+ locale: typeof locale === 'object' ? locale?.code : locale,
33
+ title: docInfo.title
29
34
  }),
30
35
  credentials: 'include',
31
36
  headers: {
@@ -58,6 +63,7 @@ export const MetaTitleComponent = (props)=>{
58
63
  children: [
59
64
  /*#__PURE__*/ _jsx(FieldLabel, {
60
65
  Label: Label,
66
+ field: null,
61
67
  label: label,
62
68
  ...labelProps || {}
63
69
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextFieldProps } from 'payload'\n\nimport {\n FieldLabel,\n TextInput,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateTitle } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\nimport '../index.scss'\n\nconst { maxLength, minLength } = defaults.title\n\ntype MetaTitleProps = {\n hasGenerateTitleFn: boolean\n} & TextFieldProps\n\nexport const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n required,\n },\n hasGenerateTitleFn,\n labelProps,\n } = props || {}\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const field: FieldType<string> = useField({\n path: pathFromContext,\n } as Options)\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) return\n\n const genTitleResponse = await fetch('/api/plugin-seo/generate-title', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...getData() },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Omit<Parameters<GenerateTitle>[0], 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedTitle } = await genTitleResponse.json()\n\n setValue(generatedTitle || '')\n }, [hasGenerateTitleFn, docInfo, getData, locale, setValue])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel Label={Label} label={label} {...(labelProps || {})} />\n {hasGenerateTitleFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateTitle()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipTitle', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n .\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextInput\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n label={label}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextInput","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","title","MetaTitleComponent","props","field","admin","components","Label","label","required","hasGenerateTitleFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateTitle","genTitleResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedTitle","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","Component","RenderedComponent","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,OAAO,gBAAe;AAEtB,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGH,SAASI,KAAK;AAM/C,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EACLC,OAAO,EACLC,YAAY,EAAEC,KAAK,EAAE,EACtB,EACDC,KAAK,EACLC,QAAQ,EACT,EACDC,kBAAkB,EAClBC,UAAU,EACX,GAAGR,SAAS,CAAC;IACd,MAAM,EAAES,MAAMC,eAAe,EAAE,GAAGtB;IAElC,MAAM,EAAEuB,CAAC,EAAE,GAAGpB;IAEd,MAAMU,QAA2Bd,SAAS;QACxCsB,MAAMC;IACR;IAEA,MAAME,SAAStB;IACf,MAAM,EAAEuB,OAAO,EAAE,GAAGxB;IACpB,MAAMyB,UAAU5B;IAEhB,MAAM,EAAE6B,YAAY,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGjB;IAErD,MAAMkB,kBAAkB1B,YAAY;QAClC,IAAI,CAACc,oBAAoB;QAEzB,MAAMa,mBAAmB,MAAMC,MAAM,kCAAkC;YACrEC,MAAMC,KAAKC,SAAS,CAAC;gBACnB,GAAGV,OAAO;gBACVW,KAAK;oBAAE,GAAGZ,SAAS;gBAAC;gBACpBD,QAAQ,OAAOA,WAAW,WAAWA,QAAQc,OAAOd;YACtD;YACAe,aAAa;YACbC,SAAS;gBACP,gBAAgB;YAClB;YACA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AAI3E,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextFieldProps } from 'payload'\n\nimport {\n FieldLabel,\n TextInput,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateTitle } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\nimport '../index.scss'\n\nconst { maxLength, minLength } = defaults.title\n\ntype MetaTitleProps = {\n readonly hasGenerateTitleFn: boolean\n} & TextFieldProps\n\nexport const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n required,\n },\n hasGenerateTitleFn,\n labelProps,\n } = props || {}\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const field: FieldType<string> = useField({\n path: pathFromContext,\n } as Options)\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) return\n\n const genTitleResponse = await fetch('/api/plugin-seo/generate-title', {\n body: JSON.stringify({\n id: docInfo.id,\n slug: docInfo.slug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<Parameters<GenerateTitle>[0], 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedTitle } = await genTitleResponse.json()\n\n setValue(generatedTitle || '')\n }, [hasGenerateTitleFn, docInfo, getData, locale, setValue])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel Label={Label} field={null} label={label} {...(labelProps || {})} />\n {hasGenerateTitleFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateTitle()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipTitle', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n .\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextInput\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n label={label}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextInput","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","title","MetaTitleComponent","props","field","admin","components","Label","label","required","hasGenerateTitleFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateTitle","genTitleResponse","fetch","body","JSON","stringify","id","slug","doc","docPermissions","hasPublishPermission","hasSavePermission","initialData","initialState","code","credentials","headers","method","result","generatedTitle","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","Component","RenderedComponent","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,OAAO,gBAAe;AAEtB,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGH,SAASI,KAAK;AAM/C,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EACLC,OAAO,EACLC,YAAY,EAAEC,KAAK,EAAE,EACtB,EACDC,KAAK,EACLC,QAAQ,EACT,EACDC,kBAAkB,EAClBC,UAAU,EACX,GAAGR,SAAS,CAAC;IACd,MAAM,EAAES,MAAMC,eAAe,EAAE,GAAGtB;IAElC,MAAM,EAAEuB,CAAC,EAAE,GAAGpB;IAEd,MAAMU,QAA2Bd,SAAS;QACxCsB,MAAMC;IACR;IAEA,MAAME,SAAStB;IACf,MAAM,EAAEuB,OAAO,EAAE,GAAGxB;IACpB,MAAMyB,UAAU5B;IAEhB,MAAM,EAAE6B,YAAY,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGjB;IAErD,MAAMkB,kBAAkB1B,YAAY;QAClC,IAAI,CAACc,oBAAoB;QAEzB,MAAMa,mBAAmB,MAAMC,MAAM,kCAAkC;YACrEC,MAAMC,KAAKC,SAAS,CAAC;gBACnBC,IAAIX,QAAQW,EAAE;gBACdC,MAAMZ,QAAQY,IAAI;gBAClBC,KAAKd;gBACLe,gBAAgBd,QAAQ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W;wBACXC,mBAAmB/C;oBACrB;oBACAV,OAAOA;oBACP0D,UAAU/C;oBACVP,MAAMC;oBACNJ,UAAUA;oBACVW,WAAWA;oBACXwB,OAAO;wBACLC,cAAc;oBAChB;oBACAxB,OAAOA;;;0BAGX,KAACsB;gBACCC,OAAO;oBACLuB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACvE;oBAAgBC,WAAWA;oBAAWC,WAAWA;oBAAWsE,MAAMjD;;;;;AAI3E,EAAC"}
@@ -1,9 +1,9 @@
1
1
  import type { UIField } from 'payload';
2
2
  import React from 'react';
3
3
  type PreviewProps = {
4
- descriptionPath?: string;
5
- hasGenerateURLFn: boolean;
6
- titlePath?: string;
4
+ readonly descriptionPath?: string;
5
+ readonly hasGenerateURLFn: boolean;
6
+ readonly titlePath?: string;
7
7
  } & UIField;
8
8
  export declare const PreviewComponent: React.FC<PreviewProps>;
9
9
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AASjD,OAAO,KAA8B,MAAM,OAAO,CAAA;AAKlD,KAAK,YAAY,GAAG;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,OAAO,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAA;AAEX,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAuGnD,CAAA"}
1
+ {"version":3,"file":"PreviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AASjD,OAAO,KAA8B,MAAM,OAAO,CAAA;AAKlD,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B,GAAG,OAAO,CAAA;AAEX,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA+GnD,CAAA"}
@@ -2,7 +2,8 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useAllFormFields, useDocumentInfo, useForm, useLocale, useTranslation } from '@payloadcms/ui';
4
4
  import React, { useEffect, useState } from 'react';
5
- export const PreviewComponent = ({ descriptionPath: descriptionPathFromContext, hasGenerateURLFn, titlePath: titlePathFromContext })=>{
5
+ export const PreviewComponent = (props)=>{
6
+ const { descriptionPath: descriptionPathFromContext, hasGenerateURLFn, titlePath: titlePathFromContext } = props;
6
7
  const { t } = useTranslation();
7
8
  const locale = useLocale();
8
9
  const [fields] = useAllFormFields();
@@ -16,11 +17,15 @@ export const PreviewComponent = ({ descriptionPath: descriptionPathFromContext,
16
17
  const getHref = async ()=>{
17
18
  const genURLResponse = await fetch('/api/plugin-seo/generate-url', {
18
19
  body: JSON.stringify({
19
- ...docInfo,
20
- doc: {
21
- ...getData()
22
- },
23
- locale: typeof locale === 'object' ? locale?.code : locale
20
+ id: docInfo.id,
21
+ doc: getData(),
22
+ docPermissions: docInfo.docPermissions,
23
+ hasPublishPermission: docInfo.hasPublishPermission,
24
+ hasSavePermission: docInfo.hasSavePermission,
25
+ initialData: docInfo.initialData,
26
+ initialState: docInfo.initialState,
27
+ locale: typeof locale === 'object' ? locale?.code : locale,
28
+ title: docInfo.title
24
29
  }),
25
30
  credentials: 'include',
26
31
  headers: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FormField, UIField } from 'payload'\n\nimport {\n useAllFormFields,\n useDocumentInfo,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateURL } from '../../types.js'\n\ntype PreviewProps = {\n descriptionPath?: string\n hasGenerateURLFn: boolean\n titlePath?: string\n} & UIField\n\nexport const PreviewComponent: React.FC<PreviewProps> = ({\n descriptionPath: descriptionPathFromContext,\n hasGenerateURLFn,\n titlePath: titlePathFromContext,\n}) => {\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const descriptionPath = descriptionPathFromContext || 'meta.description'\n const titlePath = titlePathFromContext || 'meta.title'\n\n const {\n [descriptionPath]: { value: metaDescription } = {} as FormField,\n [titlePath]: { value: metaTitle } = {} as FormField,\n } = fields\n\n const [href, setHref] = useState<string>()\n\n useEffect(() => {\n const getHref = async () => {\n const genURLResponse = await fetch('/api/plugin-seo/generate-url', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...getData() },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Omit<Parameters<GenerateURL>[0], 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: newHref } = await genURLResponse.json()\n\n setHref(newHref)\n }\n\n if (hasGenerateURLFn && !href) {\n void getHref()\n }\n }, [fields, href, locale, docInfo, hasGenerateURLFn, getData])\n\n return (\n <div>\n <div>{t('plugin-seo:preview')}</div>\n <div\n style={{\n color: '#9A9A9A',\n marginBottom: '5px',\n }}\n >\n {t('plugin-seo:previewDescription')}\n </div>\n <div\n style={{\n background: 'var(--theme-elevation-50)',\n borderRadius: '5px',\n boxShadow: '0px 0px 10px rgba(0, 0, 0, 0.1)',\n maxWidth: '600px',\n padding: '20px',\n pointerEvents: 'none',\n width: '100%',\n }}\n >\n <div>\n <a\n href={href}\n style={{\n textDecoration: 'none',\n }}\n >\n {href || 'https://...'}\n </a>\n </div>\n <h4\n style={{\n margin: 0,\n }}\n >\n <a\n href=\"/\"\n style={{\n textDecoration: 'none',\n }}\n >\n {metaTitle as string}\n </a>\n </h4>\n <p\n style={{\n margin: 0,\n }}\n >\n {metaDescription as string}\n </p>\n </div>\n </div>\n )\n}\n"],"names":["useAllFormFields","useDocumentInfo","useForm","useLocale","useTranslation","React","useEffect","useState","PreviewComponent","descriptionPath","descriptionPathFromContext","hasGenerateURLFn","titlePath","titlePathFromContext","t","locale","fields","getData","docInfo","value","metaDescription","metaTitle","href","setHref","getHref","genURLResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","newHref","json","div","style","color","marginBottom","background","borderRadius","boxShadow","maxWidth","padding","pointerEvents","width","a","textDecoration","h4","margin","p"],"mappings":"AAAA;;AAIA,SACEA,gBAAgB,EAChBC,eAAe,EACfC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAWlD,OAAO,MAAMC,mBAA2C,CAAC,EACvDC,iBAAiBC,0BAA0B,EAC3CC,gBAAgB,EAChBC,WAAWC,oBAAoB,EAChC;IACC,MAAM,EAAEC,CAAC,EAAE,GAAGV;IAEd,MAAMW,SAASZ;IACf,MAAM,CAACa,OAAO,GAAGhB;IACjB,MAAM,EAAEiB,OAAO,EAAE,GAAGf;IACpB,MAAMgB,UAAUjB;IAEhB,MAAMQ,kBAAkBC,8BAA8B;IACtD,MAAME,YAAYC,wBAAwB;IAE1C,MAAM,EACJ,CAACJ,gBAAgB,EAAE,EAAEU,OAAOC,eAAe,EAAE,GAAG,CAAC,CAAc,EAC/D,CAACR,UAAU,EAAE,EAAEO,OAAOE,SAAS,EAAE,GAAG,CAAC,CAAc,EACpD,GAAGL;IAEJ,MAAM,CAACM,MAAMC,QAAQ,GAAGhB;IAExBD,UAAU;QACR,MAAMkB,UAAU;YACd,MAAMC,iBAAiB,MAAMC,MAAM,gCAAgC;gBACjEC,MAAMC,KAAKC,SAAS,CAAC;oBACnB,GAAGX,OAAO;oBACVY,KAAK;wBAAE,GAAGb,SAAS;oBAAC;oBACpBF,QAAQ,OAAOA,WAAW,WAAWA,QAAQgB,OAAOhB;gBACtD;gBACAiB,aAAa;gBACbC,SAAS;oBACP,gBAAgB;gBAClB;gBACAC,QAAQ;YACV;YAEA,MAAM,EAAEC,QAAQC,OAAO,EAAE,GAAG,MAAMX,eAAeY,IAAI;YAErDd,QAAQa;QACV;QAEA,IAAIzB,oBAAoB,CAACW,MAAM;YAC7B,KAAKE;QACP;IACF,GAAG;QAACR;QAAQM;QAAMP;QAAQG;QAASP;QAAkBM;KAAQ;IAE7D,qBACE,MAACqB;;0BACC,KAACA;0BAAKxB,EAAE;;0BACR,KAACwB;gBACCC,OAAO;oBACLC,OAAO;oBACPC,cAAc;gBAChB;0BAEC3B,EAAE;;0BAEL,MAACwB;gBACCC,OAAO;oBACLG,YAAY;oBACZC,cAAc;oBACdC,WAAW;oBACXC,UAAU;oBACVC,SAAS;oBACTC,eAAe;oBACfC,OAAO;gBACT;;kCAEA,KAACV;kCACC,cAAA,KAACW;4BACC3B,MAAMA;4BACNiB,OAAO;gCACLW,gBAAgB;4BAClB;sCAEC5B,QAAQ;;;kCAGb,KAAC6B;wBACCZ,OAAO;4BACLa,QAAQ;wBACV;kCAEA,cAAA,KAACH;4BACC3B,MAAK;4BACLiB,OAAO;gCACLW,gBAAgB;4BAClB;sCAEC7B;;;kCAGL,KAACgC;wBACCd,OAAO;4BACLa,QAAQ;wBACV;kCAEChC;;;;;;AAKX,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FormField, UIField } from 'payload'\n\nimport {\n useAllFormFields,\n useDocumentInfo,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateURL } from '../../types.js'\n\ntype PreviewProps = {\n readonly descriptionPath?: string\n readonly hasGenerateURLFn: boolean\n readonly titlePath?: string\n} & UIField\n\nexport const PreviewComponent: React.FC<PreviewProps> = (props) => {\n const {\n descriptionPath: descriptionPathFromContext,\n hasGenerateURLFn,\n titlePath: titlePathFromContext,\n } = props\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const descriptionPath = descriptionPathFromContext || 'meta.description'\n const titlePath = titlePathFromContext || 'meta.title'\n\n const {\n [descriptionPath]: { value: metaDescription } = {} as FormField,\n [titlePath]: { value: metaTitle } = {} as FormField,\n } = fields\n\n const [href, setHref] = useState<string>()\n\n useEffect(() => {\n const getHref = async () => {\n const genURLResponse = await fetch('/api/plugin-seo/generate-url', {\n body: JSON.stringify({\n id: docInfo.id,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<Parameters<GenerateURL>[0], 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: newHref } = await genURLResponse.json()\n\n setHref(newHref)\n }\n\n if (hasGenerateURLFn && !href) {\n void getHref()\n }\n }, [fields, href, locale, docInfo, hasGenerateURLFn, getData])\n\n return (\n <div>\n <div>{t('plugin-seo:preview')}</div>\n <div\n style={{\n color: '#9A9A9A',\n marginBottom: '5px',\n }}\n >\n {t('plugin-seo:previewDescription')}\n </div>\n <div\n style={{\n background: 'var(--theme-elevation-50)',\n borderRadius: '5px',\n boxShadow: '0px 0px 10px rgba(0, 0, 0, 0.1)',\n maxWidth: '600px',\n padding: '20px',\n pointerEvents: 'none',\n width: '100%',\n }}\n >\n <div>\n <a\n href={href}\n style={{\n textDecoration: 'none',\n }}\n >\n {href || 'https://...'}\n </a>\n </div>\n <h4\n style={{\n margin: 0,\n }}\n >\n <a\n href=\"/\"\n style={{\n textDecoration: 'none',\n }}\n >\n {metaTitle as string}\n </a>\n </h4>\n <p\n style={{\n margin: 0,\n }}\n >\n {metaDescription as string}\n </p>\n </div>\n </div>\n )\n}\n"],"names":["useAllFormFields","useDocumentInfo","useForm","useLocale","useTranslation","React","useEffect","useState","PreviewComponent","props","descriptionPath","descriptionPathFromContext","hasGenerateURLFn","titlePath","titlePathFromContext","t","locale","fields","getData","docInfo","value","metaDescription","metaTitle","href","setHref","getHref","genURLResponse","fetch","body","JSON","stringify","id","doc","docPermissions","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","result","newHref","json","div","style","color","marginBottom","background","borderRadius","boxShadow","maxWidth","padding","pointerEvents","width","a","textDecoration","h4","margin","p"],"mappings":"AAAA;;AAIA,SACEA,gBAAgB,EAChBC,eAAe,EACfC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAWlD,OAAO,MAAMC,mBAA2C,CAACC;IACvD,MAAM,EACJC,iBAAiBC,0BAA0B,EAC3CC,gBAAgB,EAChBC,WAAWC,oBAAoB,EAChC,GAAGL;IAEJ,MAAM,EAAEM,CAAC,EAAE,GAAGX;IAEd,MAAMY,SAASb;IACf,MAAM,CAACc,OAAO,GAAGjB;IACjB,MAAM,EAAEkB,OAAO,EAAE,GAAGhB;IACpB,MAAMiB,UAAUlB;IAEhB,MAAMS,kBAAkBC,8BAA8B;IACtD,MAAME,YAAYC,wBAAwB;IAE1C,MAAM,EACJ,CAACJ,gBAAgB,EAAE,EAAEU,OAAOC,eAAe,EAAE,GAAG,CAAC,CAAc,EAC/D,CAACR,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BACLwB,OAAO;gCACLW,gBAAgB;4BAClB;sCAECpC;;;kCAGL,KAACuC;wBACCd,OAAO;4BACLa,QAAQ;wBACV;kCAECvC;;;;;;AAKX,EAAC"}
package/dist/types.d.ts CHANGED
@@ -1,25 +1,26 @@
1
1
  import type { DocumentInfoContext } from '@payloadcms/ui';
2
2
  import type { Field, PayloadRequest, TextField, TextareaField, UploadField } from 'payload';
3
+ export type PartialDocumentInfoContext = Pick<DocumentInfoContext, 'docPermissions' | 'hasPublishPermission' | 'hasSavePermission' | 'id' | 'initialData' | 'initialState' | 'preferencesKey' | 'publishedDoc' | 'slug' | 'title' | 'versionsCount'>;
3
4
  export type GenerateTitle<T = any> = (args: {
4
5
  doc: T;
5
6
  locale?: string;
6
7
  req: PayloadRequest;
7
- } & DocumentInfoContext) => Promise<string> | string;
8
+ } & PartialDocumentInfoContext) => Promise<string> | string;
8
9
  export type GenerateDescription<T = any> = (args: {
9
10
  doc: T;
10
11
  locale?: string;
11
12
  req: PayloadRequest;
12
- } & DocumentInfoContext) => Promise<string> | string;
13
+ } & PartialDocumentInfoContext) => Promise<string> | string;
13
14
  export type GenerateImage<T = any> = (args: {
14
15
  doc: T;
15
16
  locale?: string;
16
17
  req: PayloadRequest;
17
- } & DocumentInfoContext) => Promise<string> | string;
18
+ } & PartialDocumentInfoContext) => Promise<string> | string;
18
19
  export type GenerateURL<T = any> = (args: {
19
20
  doc: T;
20
21
  locale?: string;
21
22
  req: PayloadRequest;
22
- } & DocumentInfoContext) => Promise<string> | string;
23
+ } & PartialDocumentInfoContext) => Promise<string> | string;
23
24
  export type SEOPluginConfig = {
24
25
  collections?: string[];
25
26
  fieldOverrides?: {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,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AE,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,IAAI,GAAG;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { DocumentInfoContext } from '@payloadcms/ui'\nimport type { Field, PayloadRequest, TextField, TextareaField, UploadField } from 'payload'\n\nexport type GenerateTitle<T = any> = (\n args: { doc: T; locale?: string; req: PayloadRequest } & DocumentInfoContext,\n) => Promise<string> | string\n\nexport type GenerateDescription<T = any> = (\n args: {\n doc: T\n locale?: string\n req: PayloadRequest\n } & DocumentInfoContext,\n) => Promise<string> | string\n\nexport type GenerateImage<T = any> = (\n args: { doc: T; locale?: string; req: PayloadRequest } & DocumentInfoContext,\n) => Promise<string> | string\n\nexport type GenerateURL<T = any> = (\n args: { doc: T; locale?: string; req: PayloadRequest } & DocumentInfoContext,\n) => Promise<string> | string\n\nexport type SEOPluginConfig = {\n collections?: string[]\n fieldOverrides?: {\n description?: Partial<TextareaField>\n image?: Partial<UploadField>\n title?: Partial<TextField>\n }\n fields?: Field[]\n generateDescription?: GenerateDescription\n generateImage?: GenerateImage\n generateTitle?: GenerateTitle\n generateURL?: GenerateURL\n globals?: string[]\n interfaceName?: string\n tabbedUI?: boolean\n uploadsCollection?: string\n}\n\nexport type Meta = {\n description?: string\n image?: any // TODO: type this\n keywords?: string\n title?: string\n}\n"],"names":[],"mappings":"AAyCA,WAKC"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { DocumentInfoContext } from '@payloadcms/ui'\nimport type { Field, PayloadRequest, TextField, TextareaField, UploadField } from 'payload'\n\nexport type PartialDocumentInfoContext = Pick<\n DocumentInfoContext,\n | 'docPermissions'\n | 'hasPublishPermission'\n | 'hasSavePermission'\n | 'id'\n | 'initialData'\n | 'initialState'\n | 'preferencesKey'\n | 'publishedDoc'\n | 'slug'\n | 'title'\n | 'versionsCount'\n>\n\nexport type GenerateTitle<T = any> = (\n args: { doc: T; locale?: string; req: PayloadRequest } & PartialDocumentInfoContext,\n) => Promise<string> | string\n\nexport type GenerateDescription<T = any> = (\n args: {\n doc: T\n locale?: string\n req: PayloadRequest\n } & PartialDocumentInfoContext,\n) => Promise<string> | string\n\nexport type GenerateImage<T = any> = (\n args: { doc: T; locale?: string; req: PayloadRequest } & PartialDocumentInfoContext,\n) => Promise<string> | string\n\nexport type GenerateURL<T = any> = (\n args: { doc: T; locale?: string; req: PayloadRequest } & PartialDocumentInfoContext,\n) => Promise<string> | string\n\nexport type SEOPluginConfig = {\n collections?: string[]\n fieldOverrides?: {\n description?: Partial<TextareaField>\n image?: Partial<UploadField>\n title?: Partial<TextField>\n }\n fields?: Field[]\n generateDescription?: GenerateDescription\n generateImage?: GenerateImage\n generateTitle?: GenerateTitle\n generateURL?: GenerateURL\n globals?: string[]\n interfaceName?: string\n tabbedUI?: boolean\n uploadsCollection?: string\n}\n\nexport type Meta = {\n description?: string\n image?: any // TODO: type this\n keywords?: string\n title?: string\n}\n"],"names":[],"mappings":"AAwDA,WAKC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-seo",
3
- "version": "3.0.0-canary.aceaf5d",
3
+ "version": "3.0.0-canary.af2bebe",
4
4
  "description": "SEO plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -50,17 +50,17 @@
50
50
  "@types/react": "npm:types-react@19.0.0-rc.0",
51
51
  "@types/react-dom": "npm:types-react-dom@19.0.0-rc.0",
52
52
  "@payloadcms/eslint-config": "3.0.0-beta.59",
53
- "@payloadcms/next": "3.0.0-canary.aceaf5d",
54
- "@payloadcms/translations": "3.0.0-canary.aceaf5d",
55
- "payload": "3.0.0-canary.aceaf5d",
56
- "@payloadcms/ui": "3.0.0-canary.aceaf5d"
53
+ "@payloadcms/next": "3.0.0-canary.af2bebe",
54
+ "@payloadcms/translations": "3.0.0-canary.af2bebe",
55
+ "payload": "3.0.0-canary.af2bebe",
56
+ "@payloadcms/ui": "3.0.0-canary.af2bebe"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "react": "^19.0.0 || ^19.0.0-rc-06d0b89e-20240801",
60
60
  "react-dom": "^19.0.0 || ^19.0.0-rc-06d0b89e-20240801",
61
- "@payloadcms/translations": "3.0.0-canary.aceaf5d",
62
- "payload": "3.0.0-canary.aceaf5d",
63
- "@payloadcms/ui": "3.0.0-canary.aceaf5d"
61
+ "@payloadcms/translations": "3.0.0-canary.af2bebe",
62
+ "payload": "3.0.0-canary.af2bebe",
63
+ "@payloadcms/ui": "3.0.0-canary.af2bebe"
64
64
  },
65
65
  "publishConfig": {
66
66
  "registry": "https://registry.npmjs.org/"