@justanarthur/payload-plugin-seo 1.3.9 → 1.3.10

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.
Files changed (43) hide show
  1. package/README.md +16 -16
  2. package/dist/defaults.js.map +1 -1
  3. package/dist/exports/client.js.map +1 -1
  4. package/dist/exports/fields-components.js.map +1 -1
  5. package/dist/exports/fields.js.map +1 -1
  6. package/dist/exports/types.js.map +1 -1
  7. package/dist/fields/MetaDescription/MetaDescriptionComponent.js.map +1 -1
  8. package/dist/fields/MetaDescription/index.js.map +1 -1
  9. package/dist/fields/MetaImage/MetaImageComponent.js.map +1 -1
  10. package/dist/fields/MetaImage/index.js.map +1 -1
  11. package/dist/fields/MetaTitle/MetaTitleComponent.js.map +1 -1
  12. package/dist/fields/MetaTitle/index.js.map +1 -1
  13. package/dist/fields/Overview/OverviewComponent.js.map +1 -1
  14. package/dist/fields/Overview/index.js.map +1 -1
  15. package/dist/fields/Preview/PreviewComponent.d.ts.map +1 -1
  16. package/dist/fields/Preview/PreviewComponent.js +1 -13
  17. package/dist/fields/Preview/PreviewComponent.js.map +1 -1
  18. package/dist/fields/Preview/index.js.map +1 -1
  19. package/dist/fields/index.scss +7 -7
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +86 -44
  22. package/dist/index.js.map +1 -1
  23. package/dist/openai/message.js.map +1 -1
  24. package/dist/translations/cs.js.map +1 -1
  25. package/dist/translations/de.js.map +1 -1
  26. package/dist/translations/en.js.map +1 -1
  27. package/dist/translations/es.js.map +1 -1
  28. package/dist/translations/fa.js.map +1 -1
  29. package/dist/translations/fr.js.map +1 -1
  30. package/dist/translations/index.js.map +1 -1
  31. package/dist/translations/it.js.map +1 -1
  32. package/dist/translations/nb.js.map +1 -1
  33. package/dist/translations/pl.js.map +1 -1
  34. package/dist/translations/ru.js.map +1 -1
  35. package/dist/translations/sv.js.map +1 -1
  36. package/dist/translations/tr.js.map +1 -1
  37. package/dist/translations/translation-schema.json +96 -96
  38. package/dist/translations/uk.js.map +1 -1
  39. package/dist/translations/vi.js.map +1 -1
  40. package/dist/types.js.map +1 -1
  41. package/dist/ui/LengthIndicator.js.map +1 -1
  42. package/dist/ui/Pill.js.map +1 -1
  43. package/package.json +1 -1
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
- # Alternative version of official @payloadcms/plugin-seo package with AI generating improvements
2
-
3
- [Official docs](https://payloadcms.com/docs/plugins/seo)
4
-
5
- ## List of the added options:
6
-
7
- `openaiApiKey`
8
- API key for OpenAI
9
-
10
- `generateTitleAi`:
11
- Should return prompt, example: `"Generate meta SEO title for <type of site> site in language=${data.locale}"`
12
-
13
- `generateDescriptionAi`:
14
- Should return prompt, example: "`Generate meta SEO description for <type of site> site in language=${data.locale}`"
15
-
16
- The args are the same as `generateTitle` and `generateDescription`
1
+ # Alternative version of official @payloadcms/plugin-seo package with AI generating improvements
2
+
3
+ [Official docs](https://payloadcms.com/docs/plugins/seo)
4
+
5
+ ## List of the added options:
6
+
7
+ `openaiApiKey`
8
+ API key for OpenAI
9
+
10
+ `generateTitleAi`:
11
+ Should return prompt, example: `"Generate meta SEO title for <type of site> site in language=${data.locale}"`
12
+
13
+ `generateDescriptionAi`:
14
+ Should return prompt, example: "`Generate meta SEO description for <type of site> site in language=${data.locale}`"
15
+
16
+ The args are the same as `generateTitle` and `generateDescription`
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const defaults = {\r\n description: {\r\n maxLength: 150,\r\n minLength: 100,\r\n },\r\n title: {\r\n maxLength: 60,\r\n minLength: 50,\r\n },\r\n}\r\n"],"names":["defaults","description","maxLength","minLength","title"],"mappings":"AAAA,OAAO,MAAMA,WAAW;IACtBC,aAAa;QACXC,WAAW;QACXC,WAAW;IACb;IACAC,OAAO;QACLF,WAAW;QACXC,WAAW;IACb;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const defaults = {\n description: {\n maxLength: 150,\n minLength: 100,\n },\n title: {\n maxLength: 60,\n minLength: 50,\n },\n}\n"],"names":["defaults","description","maxLength","minLength","title"],"mappings":"AAAA,OAAO,MAAMA,WAAW;IACtBC,aAAa;QACXC,WAAW;QACXC,WAAW;IACb;IACAC,OAAO;QACLF,WAAW;QACXC,WAAW;IACb;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { MetaDescriptionComponent } from '../fields/MetaDescription/MetaDescriptionComponent'\r\nexport { MetaImageComponent } from '../fields/MetaImage/MetaImageComponent'\r\nexport { MetaTitleComponent } from '../fields/MetaTitle/MetaTitleComponent'\r\nexport { OverviewComponent } from '../fields/Overview/OverviewComponent'\r\nexport { PreviewComponent } from '../fields/Preview/PreviewComponent'\r\n"],"names":["MetaDescriptionComponent","MetaImageComponent","MetaTitleComponent","OverviewComponent","PreviewComponent"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,qDAAoD;AAC7F,SAASC,kBAAkB,QAAQ,yCAAwC;AAC3E,SAASC,kBAAkB,QAAQ,yCAAwC;AAC3E,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,gBAAgB,QAAQ,qCAAoC"}
1
+ {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { MetaDescriptionComponent } from '../fields/MetaDescription/MetaDescriptionComponent'\nexport { MetaImageComponent } from '../fields/MetaImage/MetaImageComponent'\nexport { MetaTitleComponent } from '../fields/MetaTitle/MetaTitleComponent'\nexport { OverviewComponent } from '../fields/Overview/OverviewComponent'\nexport { PreviewComponent } from '../fields/Preview/PreviewComponent'\n"],"names":["MetaDescriptionComponent","MetaImageComponent","MetaTitleComponent","OverviewComponent","PreviewComponent"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,qDAAoD;AAC7F,SAASC,kBAAkB,QAAQ,yCAAwC;AAC3E,SAASC,kBAAkB,QAAQ,yCAAwC;AAC3E,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,gBAAgB,QAAQ,qCAAoC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/fields-components.ts"],"sourcesContent":["export { MetaDescriptionComponent } from '../fields/MetaDescription/MetaDescriptionComponent'\r\nexport { MetaImageComponent } from '../fields/MetaImage/MetaImageComponent'\r\nexport { MetaTitleComponent } from '../fields/MetaTitle/MetaTitleComponent'\r\nexport { OverviewComponent } from '../fields/Overview/OverviewComponent'\r\nexport { PreviewComponent } from '../fields/Preview/PreviewComponent'\r\n"],"names":["MetaDescriptionComponent","MetaImageComponent","MetaTitleComponent","OverviewComponent","PreviewComponent"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,qDAAoD;AAC7F,SAASC,kBAAkB,QAAQ,yCAAwC;AAC3E,SAASC,kBAAkB,QAAQ,yCAAwC;AAC3E,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,gBAAgB,QAAQ,qCAAoC"}
1
+ {"version":3,"sources":["../../src/exports/fields-components.ts"],"sourcesContent":["export { MetaDescriptionComponent } from '../fields/MetaDescription/MetaDescriptionComponent'\nexport { MetaImageComponent } from '../fields/MetaImage/MetaImageComponent'\nexport { MetaTitleComponent } from '../fields/MetaTitle/MetaTitleComponent'\nexport { OverviewComponent } from '../fields/Overview/OverviewComponent'\nexport { PreviewComponent } from '../fields/Preview/PreviewComponent'\n"],"names":["MetaDescriptionComponent","MetaImageComponent","MetaTitleComponent","OverviewComponent","PreviewComponent"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,qDAAoD;AAC7F,SAASC,kBAAkB,QAAQ,yCAAwC;AAC3E,SAASC,kBAAkB,QAAQ,yCAAwC;AAC3E,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,gBAAgB,QAAQ,qCAAoC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/fields.ts"],"sourcesContent":["export { MetaDescriptionField } from '../fields/MetaDescription'\r\nexport { MetaImageField } from '../fields/MetaImage'\r\nexport { MetaTitleField } from '../fields/MetaTitle'\r\nexport { OverviewField } from '../fields/Overview'\r\nexport { PreviewField } from '../fields/Preview'\r\n"],"names":["MetaDescriptionField","MetaImageField","MetaTitleField","OverviewField","PreviewField"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,YAAY,QAAQ,oBAAmB"}
1
+ {"version":3,"sources":["../../src/exports/fields.ts"],"sourcesContent":["export { MetaDescriptionField } from '../fields/MetaDescription'\nexport { MetaImageField } from '../fields/MetaImage'\nexport { MetaTitleField } from '../fields/MetaTitle'\nexport { OverviewField } from '../fields/Overview'\nexport { PreviewField } from '../fields/Preview'\n"],"names":["MetaDescriptionField","MetaImageField","MetaTitleField","OverviewField","PreviewField"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,YAAY,QAAQ,oBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/types.ts"],"sourcesContent":["export type {\r\n GenerateDescription,\r\n GenerateImage,\r\n GenerateTitle,\r\n GenerateURL,\r\n Meta,\r\n SEOPluginConfig,\r\n} from '../types'\r\n"],"names":[],"mappings":"AAAA,WAOiB"}
1
+ {"version":3,"sources":["../../src/exports/types.ts"],"sourcesContent":["export type {\n GenerateDescription,\n GenerateImage,\n GenerateTitle,\n GenerateURL,\n Meta,\n SEOPluginConfig,\n} from '../types'\n"],"names":[],"mappings":"AAAA,WAOiB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"sourcesContent":["'use client'\r\n\r\nimport type { FieldType, Options } from '@payloadcms/ui'\r\nimport {\r\n FieldLabel,\r\n TextareaInput,\r\n useConfig,\r\n useDocumentInfo,\r\n useField,\r\n useForm,\r\n useLocale,\r\n useTranslation,\r\n} from '@payloadcms/ui'\r\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\r\nimport type { TextareaFieldClientProps } from 'payload'\r\nimport React, { useCallback } from 'react'\r\n\r\nimport { defaults } from '../../defaults'\r\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations'\r\nimport type { GenerateDescription } from '../../types'\r\nimport { LengthIndicator } from '../../ui/LengthIndicator'\r\n\r\nconst { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.description\r\n\r\ntype MetaDescriptionProps = {\r\n readonly hasGenerateDescriptionAi: boolean\r\n readonly hasGenerateDescriptionFn: boolean\r\n} & TextareaFieldClientProps\r\n\r\nexport const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props) => {\r\n const {\r\n field: {\r\n label,\r\n localized,\r\n maxLength: maxLengthFromProps,\r\n minLength: minLengthFromProps,\r\n required,\r\n },\r\n hasGenerateDescriptionAi,\r\n hasGenerateDescriptionFn,\r\n path,\r\n readOnly,\r\n } = props\r\n\r\n const {\r\n config: {\r\n routes: { api },\r\n serverURL,\r\n },\r\n } = useConfig()\r\n\r\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\r\n\r\n const locale = useLocale()\r\n\r\n const { getData } = useForm()\r\n\r\n const docInfo = useDocumentInfo()\r\n\r\n const maxLength = maxLengthFromProps || maxLengthDefault\r\n\r\n const minLength = minLengthFromProps || minLengthDefault\r\n\r\n const { customComponents, errorMessage, setValue, showError, value }: FieldType<string> =\r\n useField({\r\n path,\r\n } as Options)\r\n\r\n const { AfterInput, BeforeInput, Label } = customComponents || {}\r\n\r\n const regenerateDescription = useCallback(async () => {\r\n if (!hasGenerateDescriptionFn) {\r\n return\r\n }\r\n\r\n const endpoint = `${serverURL}${api}/plugin-seo/generate-description`\r\n\r\n const genDescriptionResponse = await fetch(endpoint, {\r\n body: JSON.stringify({\r\n collectionSlug: docInfo.collectionSlug,\r\n doc: getData(),\r\n docPermissions: docInfo.docPermissions,\r\n globalSlug: docInfo.globalSlug,\r\n hasPublishPermission: docInfo.hasPublishPermission,\r\n hasSavePermission: docInfo.hasSavePermission,\r\n id: docInfo.id,\r\n initialData: docInfo.initialData,\r\n initialState: docInfo.initialState\r\n ? reduceToSerializableFields(docInfo.initialState)\r\n : undefined,\r\n locale: typeof locale === 'object' ? locale?.code : locale,\r\n title: docInfo.title,\r\n } satisfies Omit<\r\n Parameters<GenerateDescription>[0],\r\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\r\n >),\r\n credentials: 'include',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n },\r\n method: 'POST',\r\n })\r\n\r\n const { result: generatedDescription } = await genDescriptionResponse.json()\r\n\r\n setValue(generatedDescription || '')\r\n }, [\r\n hasGenerateDescriptionFn,\r\n serverURL,\r\n api,\r\n docInfo.id,\r\n docInfo.collectionSlug,\r\n docInfo.docPermissions,\r\n docInfo.globalSlug,\r\n docInfo.hasPublishPermission,\r\n docInfo.hasSavePermission,\r\n docInfo.initialData,\r\n docInfo.initialState,\r\n docInfo.title,\r\n getData,\r\n locale,\r\n setValue,\r\n ])\r\n\r\n const regenerateDescriptionAi = useCallback(async () => {\r\n if (!hasGenerateDescriptionAi) return\r\n\r\n const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description-ai', {\r\n body: JSON.stringify({\r\n collectionSlug: docInfo.collectionSlug,\r\n doc: getData(),\r\n docPermissions: docInfo.docPermissions,\r\n globalSlug: docInfo.globalSlug,\r\n hasPublishPermission: docInfo.hasPublishPermission,\r\n hasSavePermission: docInfo.hasSavePermission,\r\n id: docInfo.id,\r\n initialData: docInfo.initialData,\r\n initialState: docInfo.initialState\r\n ? reduceToSerializableFields(docInfo.initialState)\r\n : undefined,\r\n locale: typeof locale === 'object' ? locale?.code : locale,\r\n title: docInfo.title,\r\n }),\r\n credentials: 'include',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n },\r\n method: 'POST',\r\n })\r\n\r\n const { result: generatedDescription } = await genDescriptionResponse.json()\r\n\r\n setValue(generatedDescription || '')\r\n }, [\r\n setValue,\r\n hasGenerateDescriptionAi,\r\n locale,\r\n docInfo.id,\r\n docInfo.collectionSlug,\r\n docInfo.docPermissions,\r\n docInfo.globalSlug,\r\n docInfo.hasPublishPermission,\r\n docInfo.hasSavePermission,\r\n docInfo.initialData,\r\n docInfo.initialState,\r\n docInfo.title,\r\n getData,\r\n ])\r\n\r\n return (\r\n <div\r\n style={{\r\n marginBottom: '20px',\r\n }}\r\n >\r\n <div\r\n style={{\r\n marginBottom: '5px',\r\n position: 'relative',\r\n }}\r\n >\r\n <div className=\"plugin-seo__field\">\r\n {Label ?? (\r\n <FieldLabel label={label} localized={localized} path={path} required={required} />\r\n )}\r\n {hasGenerateDescriptionFn && (\r\n <React.Fragment>\r\n &nbsp; &mdash; &nbsp;\r\n <button\r\n disabled={readOnly}\r\n onClick={() => {\r\n void regenerateDescription()\r\n }}\r\n style={{\r\n background: 'none',\r\n backgroundColor: 'transparent',\r\n border: 'none',\r\n color: 'currentcolor',\r\n cursor: 'pointer',\r\n padding: 0,\r\n textDecoration: 'underline',\r\n }}\r\n type=\"button\"\r\n >\r\n {t('plugin-seo:autoGenerate')}\r\n </button>\r\n </React.Fragment>\r\n )}\r\n {hasGenerateDescriptionAi && (\r\n <React.Fragment>\r\n &nbsp; &mdash; &nbsp;\r\n <button\r\n disabled={readOnly}\r\n onClick={regenerateDescriptionAi}\r\n style={{\r\n background: 'none',\r\n backgroundColor: 'transparent',\r\n border: 'none',\r\n color: 'currentcolor',\r\n cursor: 'pointer',\r\n padding: 0,\r\n textDecoration: 'underline',\r\n }}\r\n type=\"button\"\r\n >\r\n {t('plugin-seo:generateAi')}\r\n </button>\r\n </React.Fragment>\r\n )}\r\n </div>\r\n <div\r\n style={{\r\n color: '#9A9A9A',\r\n }}\r\n >\r\n {t('plugin-seo:lengthTipDescription', { maxLength, minLength })}\r\n <a\r\n href=\"https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions\"\r\n rel=\"noopener noreferrer\"\r\n target=\"_blank\"\r\n >\r\n {t('plugin-seo:bestPractices')}\r\n </a>\r\n </div>\r\n </div>\r\n <div\r\n style={{\r\n marginBottom: '10px',\r\n position: 'relative',\r\n }}\r\n >\r\n <TextareaInput\r\n AfterInput={AfterInput}\r\n BeforeInput={BeforeInput}\r\n Error={errorMessage}\r\n onChange={setValue}\r\n path={path}\r\n readOnly={readOnly}\r\n required={required}\r\n showError={showError}\r\n style={{\r\n marginBottom: 0,\r\n }}\r\n value={value}\r\n />\r\n </div>\r\n <div\r\n style={{\r\n alignItems: 'center',\r\n display: 'flex',\r\n width: '100%',\r\n }}\r\n >\r\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\r\n </div>\r\n </div>\r\n )\r\n}\r\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","hasGenerateDescriptionAi","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","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","id","initialData","initialState","undefined","code","title","credentials","headers","method","result","generatedDescription","json","regenerateDescriptionAi","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;;AAGA,SACEA,UAAU,EACVC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,O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AC,MAAK;kDAEJtD,EAAE;;;;;;kCAKX,MAACsC;wBACCC,OAAO;4BACLW,OAAO;wBACT;;4BAEClD,EAAE,mCAAmC;gCAAErB;gCAAWE;4BAAU;0CAC7D,KAAC0E;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAEN1D,EAAE;;;;;;0BAIT,KAACsC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAAC1E;oBACC0C,YAAYA;oBACZC,aAAaA;oBACbiD,OAAOtD;oBACPuD,UAAUtD;oBACVZ,MAAMA;oBACNC,UAAUA;oBACVJ,UAAUA;oBACVgB,WAAWA;oBACXgC,OAAO;wBACLC,cAAc;oBAChB;oBACAhC,OAAOA;;;0BAGX,KAAC8B;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACrF;oBAAgBC,WAAWA;oBAAWE,WAAWA;oBAAWmF,MAAMxD;;;;;AAI3E,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\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 type { TextareaFieldClientProps } from 'payload'\nimport React, { useCallback } from 'react'\n\nimport { defaults } from '../../defaults'\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations'\nimport type { GenerateDescription } from '../../types'\nimport { LengthIndicator } from '../../ui/LengthIndicator'\n\nconst { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.description\n\ntype MetaDescriptionProps = {\n readonly hasGenerateDescriptionAi: boolean\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 hasGenerateDescriptionAi,\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\n const { getData } = useForm()\n\n const docInfo = useDocumentInfo()\n\n const maxLength = maxLengthFromProps || maxLengthDefault\n\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 collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n id: docInfo.id,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState\n ? reduceToSerializableFields(docInfo.initialState)\n : undefined,\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 const regenerateDescriptionAi = useCallback(async () => {\n if (!hasGenerateDescriptionAi) return\n\n const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description-ai', {\n body: JSON.stringify({\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n id: docInfo.id,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState\n ? reduceToSerializableFields(docInfo.initialState)\n : undefined,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\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 setValue,\n hasGenerateDescriptionAi,\n locale,\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 ])\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 &nbsp; &mdash; &nbsp;\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 {hasGenerateDescriptionAi && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n disabled={readOnly}\n onClick={regenerateDescriptionAi}\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:generateAi')}\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","hasGenerateDescriptionAi","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","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","id","initialData","initialState","undefined","code","title","credentials","headers","method","result","generatedDescription","json","regenerateDescriptionAi","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","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ZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJtD,EAAE;;;;;;kCAKX,MAACsC;wBACCC,OAAO;4BACLW,OAAO;wBACT;;4BAEClD,EAAE,mCAAmC;gCAAErB;gCAAWE;4BAAU;0CAC7D,KAAC0E;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAEN1D,EAAE;;;;;;0BAIT,KAACsC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAAC1E;oBACC0C,YAAYA;oBACZC,aAAaA;oBACbiD,OAAOtD;oBACPuD,UAAUtD;oBACVZ,MAAMA;oBACNC,UAAUA;oBACVJ,UAAUA;oBACVgB,WAAWA;oBACXgC,OAAO;wBACLC,cAAc;oBAChB;oBACAhC,OAAOA;;;0BAGX,KAAC8B;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACrF;oBAAgBC,WAAWA;oBAAWE,WAAWA;oBAAWmF,MAAMxD;;;;;AAI3E,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaDescription/index.ts"],"sourcesContent":["// @ts-nocheck\r\nimport type { TextareaField } from 'payload'\r\n\r\ntype FieldFunctionProps = {\r\n /**\r\n * Tell the component if the generate AI function is available as configured in the plugin config\r\n */\r\n hasGenerateAi?: boolean\r\n /**\r\n * Tell the component if the generate function is available as configured in the plugin config\r\n */\r\n hasGenerateFn?: boolean\r\n overrides?: Omit<Partial<TextareaField>, 'admin'>\r\n}\r\n\r\ntype FieldFunction = ({\r\n hasGenerateAi,\r\n hasGenerateFn,\r\n overrides,\r\n}: FieldFunctionProps) => TextareaField\r\n\r\nexport const MetaDescriptionField: FieldFunction = ({\r\n hasGenerateAi = false,\r\n hasGenerateFn = false,\r\n overrides,\r\n}) => {\r\n return {\r\n admin: {\r\n components: {\r\n Field: {\r\n clientProps: {\r\n hasGenerateDescriptionAi: hasGenerateAi,\r\n hasGenerateDescriptionFn: hasGenerateFn,\r\n },\r\n path: '@justanarthur/payload-plugin-seo/fields-components#MetaDescriptionComponent',\r\n },\r\n },\r\n },\r\n localized: true,\r\n name: 'description',\r\n type: 'textarea',\r\n ...((overrides as TextareaField) ?? {}),\r\n }\r\n}\r\n"],"names":["MetaDescriptionField","hasGenerateAi","hasGenerateFn","overrides","admin","components","Field","clientProps","hasGenerateDescriptionAi","hasGenerateDescriptionFn","path","localized","name","type"],"mappings":"AAAA,cAAc;AAqBd,OAAO,MAAMA,uBAAsC,CAAC,EAClDC,gBAAgB,KAAK,EACrBC,gBAAgB,KAAK,EACrBC,SAAS,EACV;IACC,OAAO;QACLC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXC,0BAA0BP;wBAC1BQ,0BAA0BP;oBAC5B;oBACAQ,MAAM;gBACR;YACF;QACF;QACAC,WAAW;QACXC,MAAM;QACNC,MAAM;QACN,GAAI,AAACV,aAA+B,CAAC,CAAC;IACxC;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/MetaDescription/index.ts"],"sourcesContent":["// @ts-nocheck\nimport type { TextareaField } from 'payload'\n\ntype FieldFunctionProps = {\n /**\n * Tell the component if the generate AI function is available as configured in the plugin config\n */\n hasGenerateAi?: boolean\n /**\n * Tell the component if the generate function is available as configured in the plugin config\n */\n hasGenerateFn?: boolean\n overrides?: Omit<Partial<TextareaField>, 'admin'>\n}\n\ntype FieldFunction = ({\n hasGenerateAi,\n hasGenerateFn,\n overrides,\n}: FieldFunctionProps) => TextareaField\n\nexport const MetaDescriptionField: FieldFunction = ({\n hasGenerateAi = false,\n hasGenerateFn = false,\n overrides,\n}) => {\n return {\n admin: {\n components: {\n Field: {\n clientProps: {\n hasGenerateDescriptionAi: hasGenerateAi,\n hasGenerateDescriptionFn: hasGenerateFn,\n },\n path: '@justanarthur/payload-plugin-seo/fields-components#MetaDescriptionComponent',\n },\n },\n },\n localized: true,\n name: 'description',\n type: 'textarea',\n ...((overrides as TextareaField) ?? {}),\n }\n}\n"],"names":["MetaDescriptionField","hasGenerateAi","hasGenerateFn","overrides","admin","components","Field","clientProps","hasGenerateDescriptionAi","hasGenerateDescriptionFn","path","localized","name","type"],"mappings":"AAAA,cAAc;AAqBd,OAAO,MAAMA,uBAAsC,CAAC,EAClDC,gBAAgB,KAAK,EACrBC,gBAAgB,KAAK,EACrBC,SAAS,EACV;IACC,OAAO;QACLC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXC,0BAA0BP;wBAC1BQ,0BAA0BP;oBAC5B;oBACAQ,MAAM;gBACR;YACF;QACF;QACAC,WAAW;QACXC,MAAM;QACNC,MAAM;QACN,GAAI,AAACV,aAA+B,CAAC,CAAC;IACxC;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"sourcesContent":["'use client'\r\n\r\nimport type { FieldType, Options } from '@payloadcms/ui'\r\nimport {\r\n FieldLabel,\r\n RenderCustomComponent,\r\n UploadInput,\r\n useConfig,\r\n useDocumentInfo,\r\n useField,\r\n useForm,\r\n useLocale,\r\n useTranslation,\r\n} from '@payloadcms/ui'\r\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\r\nimport type { UploadFieldClientProps } from 'payload'\r\nimport React, { useCallback } from 'react'\r\n\r\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations'\r\nimport type { GenerateImage } from '../../types'\r\nimport { Pill } from '../../ui/Pill'\r\n\r\ntype MetaImageProps = {\r\n readonly hasGenerateImageFn: boolean\r\n} & UploadFieldClientProps\r\n\r\nexport const MetaImageComponent: React.FC<MetaImageProps> = (props) => {\r\n const {\r\n field: { label, localized, relationTo, required },\r\n hasGenerateImageFn,\r\n path,\r\n readOnly,\r\n } = props || {}\r\n\r\n const {\r\n config: {\r\n collections,\r\n routes: { api },\r\n serverURL,\r\n },\r\n } = useConfig()\r\n\r\n const field: FieldType<string> = useField({ ...props, path } as Options)\r\n\r\n const { customComponents } = field\r\n\r\n const {\r\n // biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>\r\n Error,\r\n Label,\r\n } = customComponents || {}\r\n\r\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\r\n\r\n const locale = useLocale()\r\n\r\n const { getData } = useForm()\r\n\r\n const docInfo = useDocumentInfo()\r\n\r\n const { setValue, showError, value } = field\r\n\r\n const regenerateImage = useCallback(async () => {\r\n if (!hasGenerateImageFn) {\r\n return\r\n }\r\n\r\n const endpoint = `${serverURL}${api}/plugin-seo/generate-image`\r\n\r\n const genImageResponse = await fetch(endpoint, {\r\n body: JSON.stringify({\r\n collectionSlug: docInfo.collectionSlug,\r\n doc: getData(),\r\n docPermissions: docInfo.docPermissions,\r\n globalSlug: docInfo.globalSlug,\r\n hasPublishPermission: docInfo.hasPublishPermission,\r\n hasSavePermission: docInfo.hasSavePermission,\r\n id: docInfo.id,\r\n initialData: docInfo.initialData,\r\n initialState: docInfo.initialState\r\n ? reduceToSerializableFields(docInfo.initialState)\r\n : undefined,\r\n locale: typeof locale === 'object' ? locale?.code : locale,\r\n title: docInfo.title,\r\n } satisfies Omit<\r\n Parameters<GenerateImage>[0],\r\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\r\n >),\r\n credentials: 'include',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n },\r\n method: 'POST',\r\n })\r\n\r\n const generatedImage = await genImageResponse.text()\r\n\r\n setValue(generatedImage || '')\r\n }, [\r\n hasGenerateImageFn,\r\n serverURL,\r\n api,\r\n docInfo.id,\r\n docInfo.collectionSlug,\r\n docInfo.docPermissions,\r\n docInfo.globalSlug,\r\n docInfo.hasPublishPermission,\r\n docInfo.hasSavePermission,\r\n docInfo.initialData,\r\n docInfo.initialState,\r\n docInfo.title,\r\n getData,\r\n locale,\r\n setValue,\r\n ])\r\n\r\n const hasImage = Boolean(value)\r\n\r\n const collection = collections?.find((coll) => coll.slug === relationTo) || undefined\r\n\r\n return (\r\n <div\r\n style={{\r\n marginBottom: '20px',\r\n }}\r\n >\r\n <div\r\n style={{\r\n marginBottom: '5px',\r\n position: 'relative',\r\n }}\r\n >\r\n <div className=\"plugin-seo__field\">\r\n <RenderCustomComponent\r\n CustomComponent={Label}\r\n Fallback={\r\n <FieldLabel label={label} localized={localized} path={path} required={required} />\r\n }\r\n />\r\n {hasGenerateImageFn && (\r\n <React.Fragment>\r\n &nbsp; &mdash; &nbsp;\r\n <button\r\n disabled={readOnly}\r\n onClick={() => {\r\n void regenerateImage()\r\n }}\r\n style={{\r\n background: 'none',\r\n backgroundColor: 'transparent',\r\n border: 'none',\r\n color: 'currentcolor',\r\n cursor: 'pointer',\r\n padding: 0,\r\n textDecoration: 'underline',\r\n }}\r\n type=\"button\"\r\n >\r\n {t('plugin-seo:autoGenerate')}\r\n </button>\r\n </React.Fragment>\r\n )}\r\n </div>\r\n {hasGenerateImageFn && (\r\n <div\r\n style={{\r\n color: '#9A9A9A',\r\n }}\r\n >\r\n {t('plugin-seo:imageAutoGenerationTip')}\r\n </div>\r\n )}\r\n </div>\r\n <div\r\n style={{\r\n marginBottom: '10px',\r\n position: 'relative',\r\n }}\r\n >\r\n <UploadInput\r\n Error={Error}\r\n api={api}\r\n collection={collection}\r\n filterOptions={field.filterOptions}\r\n onChange={(incomingImage) => {\r\n if (incomingImage !== null) {\r\n if (typeof incomingImage === 'object') {\r\n const { id: incomingID } = incomingImage\r\n\r\n setValue(incomingID)\r\n } else {\r\n setValue(incomingImage)\r\n }\r\n } else {\r\n setValue(null)\r\n }\r\n }}\r\n path={path}\r\n readOnly={readOnly}\r\n relationTo={relationTo}\r\n required={required}\r\n serverURL={serverURL}\r\n showError={showError}\r\n style={{\r\n marginBottom: 0,\r\n }}\r\n value={value}\r\n />\r\n </div>\r\n <div\r\n style={{\r\n alignItems: 'center',\r\n display: 'flex',\r\n width: '100%',\r\n }}\r\n >\r\n <Pill\r\n backgroundColor={hasImage ? 'green' : 'red'}\r\n color=\"white\"\r\n label={hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')}\r\n />\r\n </div>\r\n </div>\r\n )\r\n}\r\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","collections","routes","api","serverURL","customComponents","Error","Label","t","locale","getData","docInfo","setValue","showError","value","regenerateImage","endpoint","genImageResponse","fetch","body","JSON","stringify","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","id","initialData","initialState","undefined","code","title","credentials","headers","method","generatedImage","text","hasImage","Boolean","collection","find","coll","slug","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;;AAGA,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;AAElE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,IAAI,QAAQ,gBAAe;AAMpC,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,WAAW,EACXC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAGxB;IAEJ,MAAMY,QAA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AAMA;oBACNC,UAAUA;oBACVJ,YAAYA;oBACZC,UAAUA;oBACVQ,WAAWA;oBACXS,WAAWA;oBACXiC,OAAO;wBACLC,cAAc;oBAChB;oBACAjC,OAAOA;;;0BAGX,KAAC+B;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACjF;oBACCoE,iBAAiBlB,WAAW,UAAU;oBACtCoB,OAAM;oBACNlE,OAAO8C,WAAW/B,EAAE,qBAAqBA,EAAE;;;;;AAKrD,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\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 type { UploadFieldClientProps } from 'payload'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations'\nimport type { GenerateImage } from '../../types'\nimport { Pill } from '../../ui/Pill'\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 collections,\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const field: FieldType<string> = useField({ ...props, path } as Options)\n\n const { customComponents } = field\n\n const {\n // biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>\n Error,\n Label,\n } = customComponents || {}\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n\n const { getData } = useForm()\n\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 collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n id: docInfo.id,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState\n ? reduceToSerializableFields(docInfo.initialState)\n : undefined,\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 = 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 <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n {hasGenerateImageFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\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 Error={Error}\n api={api}\n collection={collection}\n filterOptions={field.filterOptions}\n onChange={(incomingImage) => {\n if (incomingImage !== null) {\n if (typeof incomingImage === 'object') {\n const { id: incomingID } = incomingImage\n\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","collections","routes","api","serverURL","customComponents","Error","Label","t","locale","getData","docInfo","setValue","showError","value","regenerateImage","endpoint","genImageResponse","fetch","body","JSON","stringify","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","id","initialData","initialState","undefined","code","title","credentials","headers","method","generatedImage","text","hasImage","Boolean","collection","find","coll","slug","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;;AAGA,SACEA,UAAU,EACVC,qBAAqB,EACrBC,WAAW,EACXC,SAAS,EACTC,eAAe,EAC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AAE;;;;;;oBAKVX,oCACC,KAACgD;wBACCC,OAAO;4BACLa,OAAO;wBACT;kCAECnD,EAAE;;;;0BAIT,KAACqC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACrE;oBACC2B,OAAOA;oBACPH,KAAKA;oBACLsC,YAAYA;oBACZuB,eAAexE,MAAMwE,aAAa;oBAClCC,UAAU,CAACC;wBACT,IAAIA,kBAAkB,MAAM;4BAC1B,IAAI,OAAOA,kBAAkB,UAAU;gCACrC,MAAM,EAAEtC,IAAIuC,UAAU,EAAE,GAAGD;gCAE3BtD,SAASuD;4BACX,OAAO;gCACLvD,SAASsD;4BACX;wBACF,OAAO;4BACLtD,SAAS;wBACX;oBACF;oBACAd,MAAMA;oBACNC,UAAUA;oBACVJ,YAAYA;oBACZC,UAAUA;oBACVQ,WAAWA;oBACXS,WAAWA;oBACXiC,OAAO;wBACLC,cAAc;oBAChB;oBACAjC,OAAOA;;;0BAGX,KAAC+B;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACjF;oBACCoE,iBAAiBlB,WAAW,UAAU;oBACtCoB,OAAM;oBACNlE,OAAO8C,WAAW/B,EAAE,qBAAqBA,EAAE;;;;;AAKrD,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaImage/index.ts"],"sourcesContent":["// @ts-nocheck\r\nimport type { CollectionSlug, UploadField } from 'payload'\r\n\r\ntype FieldFunctionProps = {\r\n /**\r\n * Tell the component if the generate function is available as configured in the plugin config\r\n */\r\n hasGenerateFn?: boolean\r\n overrides?: Partial<UploadField>\r\n relationTo: string\r\n}\r\n\r\ntype FieldFunction = ({ hasGenerateFn, overrides }: FieldFunctionProps) => UploadField\r\n\r\nexport const MetaImageField: FieldFunction = ({ hasGenerateFn = false, overrides, relationTo }) => {\r\n return {\r\n admin: {\r\n components: {\r\n Field: {\r\n clientProps: {\r\n hasGenerateImageFn: hasGenerateFn,\r\n },\r\n path: '@justanarthur/payload-plugin-seo/fields-components#MetaImageComponent',\r\n },\r\n },\r\n description: 'Maximum upload file size: 12MB. Recommended file size for images is <500KB.',\r\n },\r\n label: 'Meta Image',\r\n localized: true,\r\n name: 'image',\r\n relationTo: relationTo as CollectionSlug,\r\n type: 'upload',\r\n ...((overrides as unknown as UploadField) ?? {}),\r\n }\r\n}\r\n"],"names":["MetaImageField","hasGenerateFn","overrides","relationTo","admin","components","Field","clientProps","hasGenerateImageFn","path","description","label","localized","name","type"],"mappings":"AAAA,cAAc;AAcd,OAAO,MAAMA,iBAAgC,CAAC,EAAEC,gBAAgB,KAAK,EAAEC,SAAS,EAAEC,UAAU,EAAE;IAC5F,OAAO;QACLC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXC,oBAAoBP;oBACtB;oBACAQ,MAAM;gBACR;YACF;YACAC,aAAa;QACf;QACAC,OAAO;QACPC,WAAW;QACXC,MAAM;QACNV,YAAYA;QACZW,MAAM;QACN,GAAI,AAACZ,aAAwC,CAAC,CAAC;IACjD;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/MetaImage/index.ts"],"sourcesContent":["// @ts-nocheck\nimport type { CollectionSlug, UploadField } from 'payload'\n\ntype 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 admin: {\n components: {\n Field: {\n clientProps: {\n hasGenerateImageFn: hasGenerateFn,\n },\n path: '@justanarthur/payload-plugin-seo/fields-components#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 name: 'image',\n relationTo: relationTo as CollectionSlug,\n type: 'upload',\n ...((overrides as unknown as UploadField) ?? {}),\n }\n}\n"],"names":["MetaImageField","hasGenerateFn","overrides","relationTo","admin","components","Field","clientProps","hasGenerateImageFn","path","description","label","localized","name","type"],"mappings":"AAAA,cAAc;AAcd,OAAO,MAAMA,iBAAgC,CAAC,EAAEC,gBAAgB,KAAK,EAAEC,SAAS,EAAEC,UAAU,EAAE;IAC5F,OAAO;QACLC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXC,oBAAoBP;oBACtB;oBACAQ,MAAM;gBACR;YACF;YACAC,aAAa;QACf;QACAC,OAAO;QACPC,WAAW;QACXC,MAAM;QACNV,YAAYA;QACZW,MAAM;QACN,GAAI,AAACZ,aAAwC,CAAC,CAAC;IACjD;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"sourcesContent":["'use client'\r\n\r\nimport '../index.scss'\r\n\r\nimport type { FieldType, Options } from '@payloadcms/ui'\r\nimport {\r\n FieldLabel,\r\n TextInput,\r\n useConfig,\r\n useDocumentInfo,\r\n useField,\r\n useForm,\r\n useLocale,\r\n useTranslation,\r\n} from '@payloadcms/ui'\r\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\r\nimport type { TextFieldClientProps } from 'payload'\r\nimport React, { useCallback } from 'react'\r\n\r\nimport { defaults } from '../../defaults'\r\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations'\r\nimport type { GenerateTitle } from '../../types'\r\nimport { LengthIndicator } from '../../ui/LengthIndicator'\r\n\r\nconst { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.title\r\n\r\ntype MetaTitleProps = {\r\n readonly hasGenerateTitleAi: boolean\r\n readonly hasGenerateTitleFn: boolean\r\n} & TextFieldClientProps\r\n\r\nexport const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {\r\n const {\r\n field: { label, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required },\r\n hasGenerateTitleAi,\r\n hasGenerateTitleFn,\r\n path,\r\n readOnly,\r\n } = props || {}\r\n\r\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\r\n\r\n const {\r\n config: {\r\n routes: { api },\r\n serverURL,\r\n },\r\n } = useConfig()\r\n\r\n const field: FieldType<string> = useField({ path } as Options)\r\n\r\n const { customComponents: { AfterInput, BeforeInput, Label } = {} } = field\r\n\r\n const locale = useLocale()\r\n\r\n const { getData } = useForm()\r\n\r\n const docInfo = useDocumentInfo()\r\n\r\n const minLength = minLengthFromProps || minLengthDefault\r\n\r\n const maxLength = maxLengthFromProps || maxLengthDefault\r\n\r\n const { errorMessage, setValue, showError, value } = field\r\n\r\n const regenerateTitle = useCallback(async () => {\r\n if (!hasGenerateTitleFn) {\r\n return\r\n }\r\n\r\n const endpoint = `${serverURL}${api}/plugin-seo/generate-title`\r\n\r\n const genTitleResponse = await fetch(endpoint, {\r\n body: JSON.stringify({\r\n collectionSlug: docInfo.collectionSlug,\r\n doc: getData(),\r\n docPermissions: docInfo.docPermissions,\r\n globalSlug: docInfo.globalSlug,\r\n hasPublishPermission: docInfo.hasPublishPermission,\r\n hasSavePermission: docInfo.hasSavePermission,\r\n id: docInfo.id,\r\n initialData: docInfo.initialData,\r\n initialState: docInfo.initialState\r\n ? reduceToSerializableFields(docInfo.initialState)\r\n : undefined,\r\n locale: typeof locale === 'object' ? locale?.code : locale,\r\n title: docInfo.title,\r\n } satisfies Omit<\r\n Parameters<GenerateTitle>[0],\r\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\r\n >),\r\n credentials: 'include',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n },\r\n method: 'POST',\r\n })\r\n\r\n const { result: generatedTitle } = await genTitleResponse.json()\r\n\r\n setValue(generatedTitle || '')\r\n }, [\r\n hasGenerateTitleFn,\r\n serverURL,\r\n api,\r\n docInfo.id,\r\n docInfo.collectionSlug,\r\n docInfo.docPermissions,\r\n docInfo.globalSlug,\r\n docInfo.hasPublishPermission,\r\n docInfo.hasSavePermission,\r\n docInfo.initialData,\r\n docInfo.initialState,\r\n docInfo.title,\r\n getData,\r\n locale,\r\n setValue,\r\n ])\r\n\r\n const regenerateTitleAi = useCallback(async () => {\r\n if (!hasGenerateTitleAi) return\r\n\r\n const genTitleResponse = await fetch('/api/plugin-seo/generate-title-ai', {\r\n body: JSON.stringify({\r\n collectionSlug: docInfo.collectionSlug,\r\n doc: getData(),\r\n docPermissions: docInfo.docPermissions,\r\n globalSlug: docInfo.globalSlug,\r\n hasPublishPermission: docInfo.hasPublishPermission,\r\n hasSavePermission: docInfo.hasSavePermission,\r\n id: docInfo.id,\r\n initialData: docInfo.initialData,\r\n initialState: docInfo.initialState\r\n ? reduceToSerializableFields(docInfo.initialState)\r\n : undefined,\r\n locale: typeof locale === 'object' ? locale?.code : locale,\r\n title: docInfo.title,\r\n }),\r\n credentials: 'include',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n },\r\n method: 'POST',\r\n })\r\n\r\n const { result: generatedTitle } = await genTitleResponse.json()\r\n\r\n setValue(generatedTitle || '')\r\n }, [\r\n setValue,\r\n hasGenerateTitleAi,\r\n locale,\r\n docInfo.id,\r\n docInfo.collectionSlug,\r\n docInfo.docPermissions,\r\n docInfo.globalSlug,\r\n docInfo.hasPublishPermission,\r\n docInfo.hasSavePermission,\r\n docInfo.initialData,\r\n docInfo.initialState,\r\n docInfo.title,\r\n getData,\r\n ])\r\n\r\n return (\r\n <div\r\n style={{\r\n marginBottom: '20px',\r\n }}\r\n >\r\n <div\r\n style={{\r\n marginBottom: '5px',\r\n position: 'relative',\r\n }}\r\n >\r\n <div className=\"plugin-seo__field\">\r\n {Label ?? <FieldLabel label={label} path={path} required={required} />}\r\n {hasGenerateTitleFn && (\r\n <React.Fragment>\r\n &nbsp; &mdash; &nbsp;\r\n <button\r\n disabled={readOnly}\r\n onClick={() => {\r\n void regenerateTitle()\r\n }}\r\n style={{\r\n background: 'none',\r\n backgroundColor: 'transparent',\r\n border: 'none',\r\n color: 'currentcolor',\r\n cursor: 'pointer',\r\n padding: 0,\r\n textDecoration: 'underline',\r\n }}\r\n type=\"button\"\r\n >\r\n {t('plugin-seo:autoGenerate')}\r\n </button>\r\n </React.Fragment>\r\n )}\r\n {hasGenerateTitleAi && (\r\n <React.Fragment>\r\n &nbsp; &mdash; &nbsp;\r\n <button\r\n onClick={regenerateTitleAi}\r\n style={{\r\n background: 'none',\r\n backgroundColor: 'transparent',\r\n border: 'none',\r\n color: 'currentcolor',\r\n cursor: 'pointer',\r\n padding: 0,\r\n textDecoration: 'underline',\r\n }}\r\n type=\"button\"\r\n >\r\n {t('plugin-seo:generateAi')}\r\n </button>\r\n </React.Fragment>\r\n )}\r\n </div>\r\n <div\r\n style={{\r\n color: '#9A9A9A',\r\n }}\r\n >\r\n {t('plugin-seo:lengthTipTitle', { maxLength, minLength })}\r\n <a\r\n href=\"https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles\"\r\n rel=\"noopener noreferrer\"\r\n target=\"_blank\"\r\n >\r\n {t('plugin-seo:bestPractices')}\r\n </a>\r\n .\r\n </div>\r\n </div>\r\n <div\r\n style={{\r\n marginBottom: '10px',\r\n position: 'relative',\r\n }}\r\n >\r\n <TextInput\r\n AfterInput={AfterInput}\r\n BeforeInput={BeforeInput}\r\n Error={errorMessage}\r\n onChange={setValue}\r\n path={path}\r\n readOnly={readOnly}\r\n required={required}\r\n showError={showError}\r\n style={{\r\n marginBottom: 0,\r\n }}\r\n value={value}\r\n />\r\n </div>\r\n <div\r\n style={{\r\n alignItems: 'center',\r\n display: 'flex',\r\n width: '100%',\r\n }}\r\n >\r\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\r\n </div>\r\n </div>\r\n )\r\n}\r\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","hasGenerateTitleAi","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","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","id","initialData","initialState","undefined","code","credentials","headers","method","result","generatedTitle","json","regenerateTitleAi","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;;AAEA,OAAO,gBAAe;AAGtB,SACEA,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAElE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAE1C,SAASC,QAAQ,QAAQ,iBAAgB;AAGzC,SAASC,eAAe,QAAQ,2BAA0B;AAE1D,MAAM,EAAEC,WAAWC,gBAAgB,EAAEC,WAAWC,gBAAgB,EAAE,GAAGL,SAASM,KAAK;AAOnF,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EAAEC,KAAK,EAAER,WAAWS,kBAAkB,EAAEP,WAAWQ,kBAAkB,EAAEC,QAAQ,EAAE,EACxFC,kBAAkB,EAClBC,kBAAkB,EAClBC,IAAI,EACJC,QAAQ,EACT,GAAGT,SAAS,CAAC;IAEd,MAAM,EAAEU,CAAC,EAAE,GAAGtB;IAEd,MAAM,EACJuB,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAG/B;IAEJ,MAAMkB,QAA2BhB,SAAS;QAAEuB;IAAK;IAEjD,MAAM,EAAEO,kBAAkB,EAAEC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;gCAAOM,MAAMA;gCAAMH,UAAUA;;4BACzDE,oCACC,MAACjB,MAAMkE,QAAQ;;oCAAC;kDAEd,KAACC;wCACCC,UAAUjD;wCACVkD,SAAS;4CACP,KAAKjC;wCACP;wCACA0B,OAAO;4CACLQ,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJzD,EAAE;;;;4BAIRJ,oCACC,MAAChB,MAAMkE,QAAQ;;oCAAC;kDAEd,KAACC;wCACCE,SAAST;wCACTE,OAAO;4CACLQ,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJzD,EAAE;;;;;;kCAKX,MAACyC;wBACCC,OAAO;4BACLW,OAAO;wBACT;;4BAECrD,EAAE,6BAA6B;gCAAEhB;gCAAWE;4BAAU;0CACvD,KAACwE;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAEN7D,EAAE;;4BACD;;;;;0BAIR,KAACyC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACxE;oBACCkC,YAAYA;oBACZC,aAAaA;oBACbuD,OAAOlD;oBACPmD,UAAUlD;oBACVf,MAAMA;oBACNC,UAAUA;oBACVJ,UAAUA;oBACVmB,WAAWA;oBACX4B,OAAO;wBACLC,cAAc;oBAChB;oBACA5B,OAAOA;;;0BAGX,KAAC0B;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACnF;oBAAgBC,WAAWA;oBAAWE,WAAWA;oBAAWiF,MAAMpD;;;;;AAI3E,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"sourcesContent":["'use client'\n\nimport '../index.scss'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\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 type { TextFieldClientProps } from 'payload'\nimport React, { useCallback } from 'react'\n\nimport { defaults } from '../../defaults'\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations'\nimport type { GenerateTitle } from '../../types'\nimport { LengthIndicator } from '../../ui/LengthIndicator'\n\nconst { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.title\n\ntype MetaTitleProps = {\n readonly hasGenerateTitleAi: boolean\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 hasGenerateTitleAi,\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\n const { customComponents: { AfterInput, BeforeInput, Label } = {} } = field\n\n const locale = useLocale()\n\n const { getData } = useForm()\n\n const docInfo = useDocumentInfo()\n\n const minLength = minLengthFromProps || minLengthDefault\n\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 collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n id: docInfo.id,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState\n ? reduceToSerializableFields(docInfo.initialState)\n : undefined,\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 const regenerateTitleAi = useCallback(async () => {\n if (!hasGenerateTitleAi) return\n\n const genTitleResponse = await fetch('/api/plugin-seo/generate-title-ai', {\n body: JSON.stringify({\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n id: docInfo.id,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState\n ? reduceToSerializableFields(docInfo.initialState)\n : undefined,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\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 setValue,\n hasGenerateTitleAi,\n locale,\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 ])\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 &nbsp; &mdash; &nbsp;\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 {hasGenerateTitleAi && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={regenerateTitleAi}\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:generateAi')}\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","hasGenerateTitleAi","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","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","id","initialData","initialState","undefined","code","credentials","headers","method","result","generatedTitle","json","regenerateTitleAi","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;;AAEA,OAAO,gBAAe;AAGtB,SACEA,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAElE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAE1C,SAASC,QAAQ,QAAQ,iBAAgB;AAGzC,SAASC,eAAe,QAAQ,2BAA0B;AAE1D,MAAM,EAAEC,WAAWC,gBAAgB,EAAEC,WAAWC,gBAAgB,EAAE,GAAGL,SAASM,KAAK;AAOnF,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EAAEC,KAAK,EAAER,WAAWS,kBAAkB,EAAEP,WAAWQ,kBAAkB,EAAEC,QAAQ,EAAE,EACxFC,kBAAkB,EAClBC,kBAAkB,EAClBC,IAAI,EACJC,QAAQ,EACT,GAAGT,SAAS,CAAC;IAEd,MAAM,EAAEU,CAAC,EAAE,GAAGtB;IAEd,MAAM,EACJuB,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAG/B;IAEJ,MAAMkB,QAA2BhB,SAAS;QAAEuB;IAAK;IAEjD,MAAM,EAAEO,kBAAkB,EAAEC,UAAU,EAAEC,WA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gCAAMH,UAAUA;;4BACzDE,oCACC,MAACjB,MAAMkE,QAAQ;;oCAAC;kDAEd,KAACC;wCACCC,UAAUjD;wCACVkD,SAAS;4CACP,KAAKjC;wCACP;wCACA0B,OAAO;4CACLQ,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJzD,EAAE;;;;4BAIRJ,oCACC,MAAChB,MAAMkE,QAAQ;;oCAAC;kDAEd,KAACC;wCACCE,SAAST;wCACTE,OAAO;4CACLQ,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJzD,EAAE;;;;;;kCAKX,MAACyC;wBACCC,OAAO;4BACLW,OAAO;wBACT;;4BAECrD,EAAE,6BAA6B;gCAAEhB;gCAAWE;4BAAU;0CACvD,KAACwE;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAEN7D,EAAE;;4BACD;;;;;0BAIR,KAACyC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACxE;oBACCkC,YAAYA;oBACZC,aAAaA;oBACbuD,OAAOlD;oBACPmD,UAAUlD;oBACVf,MAAMA;oBACNC,UAAUA;oBACVJ,UAAUA;oBACVmB,WAAWA;oBACX4B,OAAO;wBACLC,cAAc;oBAChB;oBACA5B,OAAOA;;;0BAGX,KAAC0B;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACnF;oBAAgBC,WAAWA;oBAAWE,WAAWA;oBAAWiF,MAAMpD;;;;;AAI3E,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaTitle/index.ts"],"sourcesContent":["// @ts-nocheck\r\nimport type { TextField } from 'payload'\r\n\r\ntype FieldFunctionProps = {\r\n /**\r\n * Tell the component if the generate AI function is available as configured in the plugin config\r\n */\r\n hasGenerateAi?: boolean\r\n /**\r\n * Tell the component if the generate function is available as configured in the plugin config\r\n */\r\n hasGenerateFn?: boolean\r\n overrides?: Partial<TextField>\r\n}\r\n\r\ntype FieldFunction = ({ hasGenerateAi, hasGenerateFn, overrides }: FieldFunctionProps) => TextField\r\n\r\nexport const MetaTitleField: FieldFunction = ({\r\n hasGenerateAi = false,\r\n hasGenerateFn = false,\r\n overrides,\r\n}) => {\r\n return {\r\n admin: {\r\n components: {\r\n Field: {\r\n clientProps: {\r\n hasGenerateTitleAi: hasGenerateAi,\r\n hasGenerateTitleFn: hasGenerateFn,\r\n },\r\n path: '@justanarthur/payload-plugin-seo/fields-components#MetaTitleComponent',\r\n },\r\n },\r\n },\r\n localized: true,\r\n name: 'title',\r\n type: 'text',\r\n ...((overrides as unknown as TextField) ?? {}),\r\n }\r\n}\r\n"],"names":["MetaTitleField","hasGenerateAi","hasGenerateFn","overrides","admin","components","Field","clientProps","hasGenerateTitleAi","hasGenerateTitleFn","path","localized","name","type"],"mappings":"AAAA,cAAc;AAiBd,OAAO,MAAMA,iBAAgC,CAAC,EAC5CC,gBAAgB,KAAK,EACrBC,gBAAgB,KAAK,EACrBC,SAAS,EACV;IACC,OAAO;QACLC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXC,oBAAoBP;wBACpBQ,oBAAoBP;oBACtB;oBACAQ,MAAM;gBACR;YACF;QACF;QACAC,WAAW;QACXC,MAAM;QACNC,MAAM;QACN,GAAI,AAACV,aAAsC,CAAC,CAAC;IAC/C;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/MetaTitle/index.ts"],"sourcesContent":["// @ts-nocheck\nimport type { TextField } from 'payload'\n\ntype FieldFunctionProps = {\n /**\n * Tell the component if the generate AI function is available as configured in the plugin config\n */\n hasGenerateAi?: boolean\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 = ({ hasGenerateAi, hasGenerateFn, overrides }: FieldFunctionProps) => TextField\n\nexport const MetaTitleField: FieldFunction = ({\n hasGenerateAi = false,\n hasGenerateFn = false,\n overrides,\n}) => {\n return {\n admin: {\n components: {\n Field: {\n clientProps: {\n hasGenerateTitleAi: hasGenerateAi,\n hasGenerateTitleFn: hasGenerateFn,\n },\n path: '@justanarthur/payload-plugin-seo/fields-components#MetaTitleComponent',\n },\n },\n },\n localized: true,\n name: 'title',\n type: 'text',\n ...((overrides as unknown as TextField) ?? {}),\n }\n}\n"],"names":["MetaTitleField","hasGenerateAi","hasGenerateFn","overrides","admin","components","Field","clientProps","hasGenerateTitleAi","hasGenerateTitleFn","path","localized","name","type"],"mappings":"AAAA,cAAc;AAiBd,OAAO,MAAMA,iBAAgC,CAAC,EAC5CC,gBAAgB,KAAK,EACrBC,gBAAgB,KAAK,EACrBC,SAAS,EACV;IACC,OAAO;QACLC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXC,oBAAoBP;wBACpBQ,oBAAoBP;oBACtB;oBACAQ,MAAM;gBACR;YACF;QACF;QACAC,WAAW;QACXC,MAAM;QACNC,MAAM;QACN,GAAI,AAACV,aAAsC,CAAC,CAAC;IAC/C;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Overview/OverviewComponent.tsx"],"sourcesContent":["'use client'\r\n\r\nimport { useAllFormFields, useForm, useTranslation } from '@payloadcms/ui'\r\nimport type { FormField, UIField } from 'payload'\r\nimport React, { useCallback, useEffect, useState } from 'react'\r\n\r\nimport { defaults } from '../../defaults'\r\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations'\r\n\r\nconst {\r\n description: { maxLength: maxDescDefault, minLength: minDescDefault },\r\n title: { maxLength: maxTitleDefault, minLength: minTitleDefault },\r\n} = defaults\r\n\r\ntype OverviewProps = {\r\n descriptionOverrides?: {\r\n maxLength?: number\r\n minLength?: number\r\n }\r\n descriptionPath?: string\r\n imagePath?: string\r\n titleOverrides?: {\r\n maxLength?: number\r\n minLength?: number\r\n }\r\n titlePath?: string\r\n} & UIField\r\n\r\nexport const OverviewComponent: React.FC<OverviewProps> = ({\r\n descriptionOverrides,\r\n descriptionPath: descriptionPathFromContext,\r\n imagePath: imagePathFromContext,\r\n titleOverrides,\r\n titlePath: titlePathFromContext,\r\n}) => {\r\n const { getFields } = useForm()\r\n\r\n const descriptionPath = descriptionPathFromContext || 'meta.description'\r\n\r\n const titlePath = titlePathFromContext || 'meta.title'\r\n\r\n const imagePath = imagePathFromContext || 'meta.image'\r\n\r\n const [\r\n {\r\n [descriptionPath]: { value: metaDesc } = {} as FormField,\r\n [imagePath]: { value: metaImage } = {} as FormField,\r\n [titlePath]: { value: metaTitle } = {} as FormField,\r\n },\r\n ] = useAllFormFields()\r\n\r\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\r\n\r\n const [titleIsValid, setTitleIsValid] = useState<boolean | undefined>()\r\n\r\n const [descIsValid, setDescIsValid] = useState<boolean | undefined>()\r\n\r\n const [imageIsValid, setImageIsValid] = useState<boolean | undefined>()\r\n\r\n const minDesc = descriptionOverrides?.minLength || minDescDefault\r\n\r\n const maxDesc = descriptionOverrides?.maxLength || maxDescDefault\r\n\r\n const minTitle = titleOverrides?.minLength || minTitleDefault\r\n\r\n const maxTitle = titleOverrides?.maxLength || maxTitleDefault\r\n\r\n const resetAll = useCallback(() => {\r\n const fields = getFields()\r\n\r\n const fieldsWithoutMeta = fields\r\n\r\n fieldsWithoutMeta['meta.title'].value = ''\r\n fieldsWithoutMeta['meta.description'].value = ''\r\n fieldsWithoutMeta['meta.image'].value = ''\r\n // dispatchFields(fieldsWithoutMeta);\r\n }, [getFields])\r\n\r\n useEffect(() => {\r\n if (typeof metaTitle === 'string') {\r\n setTitleIsValid(metaTitle.length >= minTitle && metaTitle.length <= maxTitle)\r\n }\r\n if (typeof metaDesc === 'string') {\r\n setDescIsValid(metaDesc.length >= minDesc && metaDesc.length <= maxDesc)\r\n }\r\n setImageIsValid(Boolean(metaImage))\r\n }, [metaTitle, metaDesc, metaImage, maxDesc, maxTitle, minDesc, minTitle])\r\n\r\n const testResults = [titleIsValid, descIsValid, imageIsValid]\r\n\r\n const numberOfPasses = testResults.filter(Boolean).length\r\n\r\n return (\r\n <div\r\n style={{\r\n marginBottom: '20px',\r\n }}\r\n >\r\n <div>\r\n {t('plugin-seo:checksPassing', {\r\n current: numberOfPasses,\r\n max: testResults.length,\r\n })}\r\n </div>\r\n </div>\r\n )\r\n}\r\n"],"names":["useAllFormFields","useForm","useTranslation","React","useCallback","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","resetAll","fields","fieldsWithoutMeta","length","Boolean","testResults","numberOfPasses","filter","div","style","marginBottom","current","max"],"mappings":"AAAA;;AAEA,SAASA,gBAAgB,EAAEC,OAAO,EAAEC,cAAc,QAAQ,iBAAgB;AAE1E,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,QAAQ,QAAQ,iBAAgB;AAGzC,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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C1B,GAAG;QAACC;QAAWF;QAAUC;QAAWU;QAASE;QAAUH;QAASE;KAAS;IAEzE,MAAMO,cAAc;QAACf;QAAcE;QAAaE;KAAa;IAE7D,MAAMY,iBAAiBD,YAAYE,MAAM,CAACH,SAASD,MAAM;IAEzD,qBACE,KAACK;QACCC,OAAO;YACLC,cAAc;QAChB;kBAEA,cAAA,KAACF;sBACEnB,EAAE,4BAA4B;gBAC7BsB,SAASL;gBACTM,KAAKP,YAAYF,MAAM;YACzB;;;AAIR,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/Overview/OverviewComponent.tsx"],"sourcesContent":["'use client'\n\nimport { useAllFormFields, useForm, useTranslation } from '@payloadcms/ui'\nimport type { FormField, UIField } from 'payload'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { defaults } from '../../defaults'\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations'\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\n const titlePath = titlePathFromContext || 'meta.title'\n\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\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const [titleIsValid, setTitleIsValid] = useState<boolean | undefined>()\n\n const [descIsValid, setDescIsValid] = useState<boolean | undefined>()\n\n const [imageIsValid, setImageIsValid] = useState<boolean | undefined>()\n\n const minDesc = descriptionOverrides?.minLength || minDescDefault\n\n const maxDesc = descriptionOverrides?.maxLength || maxDescDefault\n\n const minTitle = titleOverrides?.minLength || minTitleDefault\n\n const maxTitle = titleOverrides?.maxLength || maxTitleDefault\n\n const resetAll = useCallback(() => {\n const fields = getFields()\n\n const fieldsWithoutMeta = fields\n\n fieldsWithoutMeta['meta.title'].value = ''\n fieldsWithoutMeta['meta.description'].value = ''\n fieldsWithoutMeta['meta.image'].value = ''\n // dispatchFields(fieldsWithoutMeta);\n }, [getFields])\n\n useEffect(() => {\n if (typeof metaTitle === 'string') {\n setTitleIsValid(metaTitle.length >= minTitle && metaTitle.length <= maxTitle)\n }\n if (typeof metaDesc === 'string') {\n setDescIsValid(metaDesc.length >= minDesc && metaDesc.length <= maxDesc)\n }\n setImageIsValid(Boolean(metaImage))\n }, [metaTitle, metaDesc, metaImage, maxDesc, maxTitle, minDesc, minTitle])\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', {\n current: numberOfPasses,\n max: testResults.length,\n })}\n </div>\n </div>\n )\n}\n"],"names":["useAllFormFields","useForm","useTranslation","React","useCallback","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","resetAll","fields","fieldsWithoutMeta","length","Boolean","testResults","numberOfPasses","filter","div","style","marginBottom","current","max"],"mappings":"AAAA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Ef,MAAMkB,oBAAoBD;QAE1BC,iBAAiB,CAAC,aAAa,CAACjB,KAAK,GAAG;QACxCiB,iBAAiB,CAAC,mBAAmB,CAACjB,KAAK,GAAG;QAC9CiB,iBAAiB,CAAC,aAAa,CAACjB,KAAK,GAAG;IACxC,qCAAqC;IACvC,GAAG;QAACD;KAAU;IAEdpB,UAAU;QACR,IAAI,OAAOwB,cAAc,UAAU;YACjCG,gBAAgBH,UAAUe,MAAM,IAAIL,YAAYV,UAAUe,MAAM,IAAIJ;QACtE;QACA,IAAI,OAAOb,aAAa,UAAU;YAChCO,eAAeP,SAASiB,MAAM,IAAIP,WAAWV,SAASiB,MAAM,IAAIN;QAClE;QACAF,gBAAgBS,QAAQjB;IAC1B,GAAG;QAACC;QAAWF;QAAUC;QAAWU;QAASE;QAAUH;QAASE;KAAS;IAEzE,MAAMO,cAAc;QAACf;QAAcE;QAAaE;KAAa;IAE7D,MAAMY,iBAAiBD,YAAYE,MAAM,CAACH,SAASD,MAAM;IAEzD,qBACE,KAACK;QACCC,OAAO;YACLC,cAAc;QAChB;kBAEA,cAAA,KAACF;sBACEnB,EAAE,4BAA4B;gBAC7BsB,SAASL;gBACTM,KAAKP,YAAYF,MAAM;YACzB;;;AAIR,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Overview/index.tsx"],"sourcesContent":["// @ts-nocheck\r\nimport type { UIField } from 'payload'\r\n\r\ntype FieldFunctionProps = {\r\n descriptionOverrides?: {\r\n maxLength?: number\r\n minLength?: number\r\n }\r\n /**\r\n * Path to the description field to use for the preview\r\n *\r\n * @default 'meta.description'\r\n */\r\n descriptionPath?: string\r\n /**\r\n * Path to the image field to use for the preview\r\n *\r\n * @default 'meta.image'\r\n */\r\n imagePath?: string\r\n overrides?: Partial<UIField>\r\n titleOverrides?: {\r\n maxLength?: number\r\n minLength?: number\r\n }\r\n /**\r\n * Path to the title field to use for the preview\r\n *\r\n * @default 'meta.title'\r\n */\r\n titlePath?: string\r\n}\r\n\r\ntype FieldFunction = ({ overrides }: FieldFunctionProps) => UIField\r\n\r\nexport const OverviewField: FieldFunction = ({\r\n descriptionOverrides,\r\n descriptionPath,\r\n imagePath,\r\n overrides,\r\n titleOverrides,\r\n titlePath,\r\n}) => {\r\n return {\r\n admin: {\r\n components: {\r\n Field: {\r\n clientProps: {\r\n descriptionOverrides,\r\n descriptionPath,\r\n imagePath,\r\n titleOverrides,\r\n titlePath,\r\n },\r\n path: '@justanarthur/payload-plugin-seo/fields-components#OverviewComponent',\r\n },\r\n },\r\n },\r\n label: 'Overview',\r\n name: 'overview',\r\n type: 'ui',\r\n ...((overrides as unknown as UIField) ?? {}),\r\n }\r\n}\r\n"],"names":["OverviewField","descriptionOverrides","descriptionPath","imagePath","overrides","titleOverrides","titlePath","admin","components","Field","clientProps","path","label","name","type"],"mappings":"AAAA,cAAc;AAmCd,OAAO,MAAMA,gBAA+B,CAAC,EAC3CC,oBAAoB,EACpBC,eAAe,EACfC,SAAS,EACTC,SAAS,EACTC,cAAc,EACdC,SAAS,EACV;IACC,OAAO;QACLC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXT;wBACAC;wBACAC;wBACAE;wBACAC;oBACF;oBACAK,MAAM;gBACR;YACF;QACF;QACAC,OAAO;QACPC,MAAM;QACNC,MAAM;QACN,GAAI,AAACV,aAAoC,CAAC,CAAC;IAC7C;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/Overview/index.tsx"],"sourcesContent":["// @ts-nocheck\nimport type { UIField } from 'payload'\n\ntype 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 admin: {\n components: {\n Field: {\n clientProps: {\n descriptionOverrides,\n descriptionPath,\n imagePath,\n titleOverrides,\n titlePath,\n },\n path: '@justanarthur/payload-plugin-seo/fields-components#OverviewComponent',\n },\n },\n },\n label: 'Overview',\n name: 'overview',\n type: 'ui',\n ...((overrides as unknown as UIField) ?? {}),\n }\n}\n"],"names":["OverviewField","descriptionOverrides","descriptionPath","imagePath","overrides","titleOverrides","titlePath","admin","components","Field","clientProps","path","label","name","type"],"mappings":"AAAA,cAAc;AAmCd,OAAO,MAAMA,gBAA+B,CAAC,EAC3CC,oBAAoB,EACpBC,eAAe,EACfC,SAAS,EACTC,SAAS,EACTC,cAAc,EACdC,SAAS,EACV;IACC,OAAO;QACLC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXT;wBACAC;wBACAC;wBACAE;wBACAC;oBACF;oBACAK,MAAM;gBACR;YACF;QACF;QACAC,OAAO;QACPC,MAAM;QACNC,MAAM;QACN,GAAI,AAACV,aAAoC,CAAC,CAAC;IAC7C;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AAMjD,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,CAqJnD,CAAA"}
1
+ {"version":3,"file":"PreviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AAMjD,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,CAwInD,CAAA"}
@@ -18,18 +18,6 @@ export const PreviewComponent = (props)=>{
18
18
  // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
19
19
  useEffect(()=>{
20
20
  const endpoint = `${serverURL}${api}/plugin-seo/generate-url`;
21
- const circularReplacer = ()=>{
22
- const seen = new WeakSet();
23
- return (_key, value)=>{
24
- if (typeof value === 'object' && value !== null) {
25
- if (seen.has(value)) {
26
- return undefined;
27
- }
28
- seen.add(value);
29
- }
30
- return value;
31
- };
32
- };
33
21
  const getHref = async ()=>{
34
22
  const genURLResponse = await fetch(endpoint, {
35
23
  body: JSON.stringify({
@@ -44,7 +32,7 @@ export const PreviewComponent = (props)=>{
44
32
  initialState: docInfo.initialState ? reduceToSerializableFields(docInfo.initialState) : undefined,
45
33
  locale: typeof locale === 'object' ? locale?.code : locale,
46
34
  title: docInfo.title
47
- }, circularReplacer()),
35
+ }),
48
36
  credentials: 'include',
49
37
  headers: {
50
38
  'Content-Type': 'application/json'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"sourcesContent":["'use client'\r\n\r\nimport {\r\n useAllFormFields,\r\n useConfig,\r\n useDocumentInfo,\r\n useForm,\r\n useLocale,\r\n useTranslation,\r\n} from '@payloadcms/ui'\r\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\r\nimport type { FormField, UIField } from 'payload'\r\nimport { useEffect, useState } from 'react'\r\n\r\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations'\r\nimport type { GenerateURL } from '../../types'\r\n\r\ntype PreviewProps = {\r\n readonly descriptionPath?: string\r\n readonly hasGenerateURLFn: boolean\r\n readonly titlePath?: string\r\n} & UIField\r\n\r\nexport const PreviewComponent: React.FC<PreviewProps> = (props) => {\r\n const {\r\n descriptionPath: descriptionPathFromContext,\r\n hasGenerateURLFn,\r\n titlePath: titlePathFromContext,\r\n } = props\r\n\r\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\r\n\r\n const {\r\n config: {\r\n routes: { api },\r\n serverURL,\r\n },\r\n } = useConfig()\r\n\r\n const locale = useLocale()\r\n\r\n const [fields] = useAllFormFields()\r\n\r\n const { getData } = useForm()\r\n\r\n const docInfo = useDocumentInfo()\r\n\r\n const descriptionPath = descriptionPathFromContext || 'meta.description'\r\n\r\n const titlePath = titlePathFromContext || 'meta.title'\r\n\r\n const {\r\n [descriptionPath]: { value: metaDescription } = {} as FormField,\r\n [titlePath]: { value: metaTitle } = {} as FormField,\r\n } = fields\r\n\r\n const [href, setHref] = useState<string>()\r\n\r\n // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>\r\n useEffect(() => {\r\n const endpoint = `${serverURL}${api}/plugin-seo/generate-url`\r\n\r\n const circularReplacer = () => {\r\n const seen = new WeakSet()\r\n return (_key: string, value: unknown) => {\r\n if (typeof value === 'object' && value !== null) {\r\n if (seen.has(value as object)) {\r\n return undefined\r\n }\r\n seen.add(value as object)\r\n }\r\n return value\r\n }\r\n }\r\n\r\n const getHref = async () => {\r\n const genURLResponse = await fetch(endpoint, {\r\n body: JSON.stringify({\r\n collectionSlug: docInfo.collectionSlug,\r\n doc: getData(),\r\n docPermissions: docInfo.docPermissions,\r\n globalSlug: docInfo.globalSlug,\r\n hasPublishPermission: docInfo.hasPublishPermission,\r\n hasSavePermission: docInfo.hasSavePermission,\r\n id: docInfo.id,\r\n initialData: docInfo.initialData,\r\n initialState: docInfo.initialState\r\n ? reduceToSerializableFields(docInfo.initialState)\r\n : undefined,\r\n locale: typeof locale === 'object' ? locale?.code : locale,\r\n title: docInfo.title,\r\n } satisfies Omit<\r\n Parameters<GenerateURL>[0],\r\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\r\n >, circularReplacer()),\r\n credentials: 'include',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n },\r\n method: 'POST',\r\n })\r\n\r\n const { result: newHref } = await genURLResponse.json()\r\n\r\n setHref(newHref)\r\n }\r\n\r\n if (hasGenerateURLFn && !href) {\r\n void getHref()\r\n }\r\n }, [fields, href, locale, docInfo, hasGenerateURLFn, getData, serverURL, api])\r\n\r\n return (\r\n <div\r\n style={{\r\n marginBottom: '20px',\r\n }}\r\n >\r\n <div>{t('plugin-seo:preview')}</div>\r\n <div\r\n style={{\r\n color: '#9A9A9A',\r\n marginBottom: '5px',\r\n }}\r\n >\r\n {t('plugin-seo:previewDescription')}\r\n </div>\r\n <div\r\n style={{\r\n background: 'var(--theme-elevation-50)',\r\n borderRadius: '5px',\r\n boxShadow: '0px 0px 10px rgba(0, 0, 0, 0.1)',\r\n maxWidth: '600px',\r\n padding: '20px',\r\n pointerEvents: 'none',\r\n width: '100%',\r\n }}\r\n >\r\n <div>\r\n <a\r\n href={href}\r\n style={{\r\n textDecoration: 'none',\r\n }}\r\n >\r\n {href || 'https://...'}\r\n </a>\r\n </div>\r\n <h4\r\n style={{\r\n margin: 0,\r\n }}\r\n >\r\n <a\r\n href=\"/\"\r\n style={{\r\n textDecoration: 'none',\r\n }}\r\n >\r\n {metaTitle as string}\r\n </a>\r\n </h4>\r\n <p\r\n style={{\r\n margin: 0,\r\n }}\r\n >\r\n {metaDescription as string}\r\n </p>\r\n </div>\r\n </div>\r\n )\r\n}\r\n"],"names":["useAllFormFields","useConfig","useDocumentInfo","useForm","useLocale","useTranslation","reduceToSerializableFields","useEffect","useState","PreviewComponent","props","descriptionPath","descriptionPathFromContext","hasGenerateURLFn","titlePath","titlePathFromContext","t","config","routes","api","serverURL","locale","fields","getData","docInfo","value","metaDescription","metaTitle","href","setHref","endpoint","circularReplacer","seen","WeakSet","_key","has","undefined","add","getHref","genURLResponse","fetch","body","JSON","stringify","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","id","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;;AAEA,SACEA,gBAAgB,EAChBC,SAAS,EACTC,eAAe,EACfC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAElE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAW3C,OAAO,MAAMC,mBAA2C,CAACC;IACvD,MAAM,EACJC,iBAAiBC,0BAA0B,EAC3CC,gBAAgB,EAChBC,WAAWC,oBAAoB,EAChC,GAAGL;IAEJ,MAAM,EAAEM,CAAC,EAAE,GAAGX;IAEd,MAAM,EACJY,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAGnB;IAEJ,MAAMoB,SAASjB;IAEf,MAAM,CAACkB,OAAO,GAAGtB;IAEjB,MAAM,EAAEuB,OAAO,EAAE,GAAGpB;IAEpB,MAAMqB,UAAUtB;IAEhB,MAAMS,kBAAkBC,8BAA8B;IAEtD,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,GAAG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AAC6C;gBACCC,OAAO;oBACLE,OAAO;oBACPD,cAAc;gBAChB;0BAEC/C,EAAE;;0BAEL,MAAC6C;gBACCC,OAAO;oBACLG,YAAY;oBACZC,cAAc;oBACdC,WAAW;oBACXC,UAAU;oBACVC,SAAS;oBACTC,eAAe;oBACfC,OAAO;gBACT;;kCAEA,KAACV;kCACC,cAAA,KAACW;4BACC5C,MAAMA;4BACNkC,OAAO;gCACLW,gBAAgB;4BAClB;sCAEC7C,QAAQ;;;kCAGb,KAAC8C;wBACCZ,OAAO;4BACLa,QAAQ;wBACV;kCAEA,cAAA,KAACH;4BACC5C,MAAK;4BACLkC,OAAO;gCACLW,gBAAgB;4BAClB;sCAEC9C;;;kCAGL,KAACiD;wBACCd,OAAO;4BACLa,QAAQ;wBACV;kCAECjD;;;;;;AAKX,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"sourcesContent":["'use client'\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 type { FormField, UIField } from 'payload'\nimport { useEffect, useState } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations'\nimport type { GenerateURL } from '../../types'\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\n const [fields] = useAllFormFields()\n\n const { getData } = useForm()\n\n const docInfo = useDocumentInfo()\n\n const descriptionPath = descriptionPathFromContext || 'meta.description'\n\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 // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>\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 collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n id: docInfo.id,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState\n ? reduceToSerializableFields(docInfo.initialState)\n : undefined,\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","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","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","id","initialData","initialState","undefined","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;;AAEA,SACEA,gBAAgB,EAChBC,SAAS,EACTC,eAAe,EACfC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAElE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAW3C,OAAO,MAAMC,mBAA2C,CAACC;IACvD,MAAM,EACJC,iBAAiBC,0BAA0B,EAC3CC,gBAAgB,EAChBC,WAAWC,oBAAoB,EAChC,GAAGL;IAEJ,MAAM,EAAEM,CAAC,EAAE,GAAGX;IAEd,MAAM,EACJY,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAGnB;IAEJ,MAAMoB,SAASjB;IAEf,MAAM,CAACkB,OAAO,GAAGtB;IAEjB,MAAM,EAAEuB,OAAO,EAAE,GAAGpB;IAEpB,MAAMqB,UAAUtB;IAEhB,MAAMS,kBAAkBC,8BAA8B;IAEtD,MAAME,YAAYC,wBAAwB;IAE1C,MAAM,EACJ,CAACJ,gBAAgB,EAAE,EAAEc,OAAOC,eAAe,EAAE,GAAG,CAAC,CAAc,EAC/D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BACVC,SAAS;oBACTC,eAAe;oBACfC,OAAO;gBACT;;kCAEA,KAACV;kCACC,cAAA,KAACW;4BACCtC,MAAMA;4BACN4B,OAAO;gCACLW,gBAAgB;4BAClB;sCAECvC,QAAQ;;;kCAGb,KAACwC;wBACCZ,OAAO;4BACLa,QAAQ;wBACV;kCAEA,cAAA,KAACH;4BACCtC,MAAK;4BACL4B,OAAO;gCACLW,gBAAgB;4BAClB;sCAECxC;;;kCAGL,KAAC2C;wBACCd,OAAO;4BACLa,QAAQ;wBACV;kCAEC3C;;;;;;AAKX,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Preview/index.tsx"],"sourcesContent":["// @ts-nocheck\r\nimport type { UIField } from 'payload'\r\n\r\ntype FieldFunctionProps = {\r\n /**\r\n * Path to the description field to use for the preview\r\n *\r\n * @default 'meta.description'\r\n */\r\n descriptionPath?: string\r\n /**\r\n * Tell the component if the generate function is available as configured in the plugin config\r\n */\r\n hasGenerateFn?: boolean\r\n overrides?: Partial<UIField>\r\n /**\r\n * Path to the title field to use for the preview\r\n *\r\n * @default 'meta.title'\r\n */\r\n titlePath?: string\r\n}\r\n\r\ntype FieldFunction = ({ hasGenerateFn, overrides }: FieldFunctionProps) => UIField\r\n\r\nexport const PreviewField: FieldFunction = ({\r\n descriptionPath,\r\n hasGenerateFn = false,\r\n overrides,\r\n titlePath,\r\n}) => {\r\n return {\r\n admin: {\r\n components: {\r\n Field: {\r\n clientProps: {\r\n descriptionPath,\r\n hasGenerateURLFn: hasGenerateFn,\r\n titlePath,\r\n },\r\n path: '@justanarthur/payload-plugin-seo/fields-components#PreviewComponent',\r\n },\r\n },\r\n },\r\n label: 'Preview',\r\n name: 'preview',\r\n type: 'ui',\r\n ...((overrides as unknown as UIField) ?? {}),\r\n }\r\n}\r\n"],"names":["PreviewField","descriptionPath","hasGenerateFn","overrides","titlePath","admin","components","Field","clientProps","hasGenerateURLFn","path","label","name","type"],"mappings":"AAAA,cAAc;AAyBd,OAAO,MAAMA,eAA8B,CAAC,EAC1CC,eAAe,EACfC,gBAAgB,KAAK,EACrBC,SAAS,EACTC,SAAS,EACV;IACC,OAAO;QACLC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXP;wBACAQ,kBAAkBP;wBAClBE;oBACF;oBACAM,MAAM;gBACR;YACF;QACF;QACAC,OAAO;QACPC,MAAM;QACNC,MAAM;QACN,GAAI,AAACV,aAAoC,CAAC,CAAC;IAC7C;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/Preview/index.tsx"],"sourcesContent":["// @ts-nocheck\nimport type { UIField } from 'payload'\n\ntype 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 admin: {\n components: {\n Field: {\n clientProps: {\n descriptionPath,\n hasGenerateURLFn: hasGenerateFn,\n titlePath,\n },\n path: '@justanarthur/payload-plugin-seo/fields-components#PreviewComponent',\n },\n },\n },\n label: 'Preview',\n name: 'preview',\n type: 'ui',\n ...((overrides as unknown as UIField) ?? {}),\n }\n}\n"],"names":["PreviewField","descriptionPath","hasGenerateFn","overrides","titlePath","admin","components","Field","clientProps","hasGenerateURLFn","path","label","name","type"],"mappings":"AAAA,cAAc;AAyBd,OAAO,MAAMA,eAA8B,CAAC,EAC1CC,eAAe,EACfC,gBAAgB,KAAK,EACrBC,SAAS,EACTC,SAAS,EACV;IACC,OAAO;QACLC,OAAO;YACLC,YAAY;gBACVC,OAAO;oBACLC,aAAa;wBACXP;wBACAQ,kBAAkBP;wBAClBE;oBACF;oBACAM,MAAM;gBACR;YACF;QACF;QACAC,OAAO;QACPC,MAAM;QACNC,MAAM;QACN,GAAI,AAACV,aAAoC,CAAC,CAAC;IAC7C;AACF,EAAC"}
@@ -1,7 +1,7 @@
1
- @layer payload-default {
2
- .plugin-seo__field {
3
- .field-label {
4
- display: inline !important;
5
- }
6
- }
7
- }
1
+ @layer payload-default {
2
+ .plugin-seo__field {
3
+ .field-label {
4
+ display: inline !important;
5
+ }
6
+ }
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,MAAM,EAA4C,MAAM,SAAS,CAAA;AAU/F,OAAO,KAAK,EAKV,eAAe,EAChB,MAAM,SAAS,CAAA;AAEhB,eAAO,MAAM,SAAS,GACnB,cAAc,eAAe,MAC7B,QAAQ,MAAM,KAAG,MAsXjB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,MAAM,EAA4C,MAAM,SAAS,CAAA;AAU/F,OAAO,KAAK,EAKV,eAAe,EAChB,MAAM,SAAS,CAAA;AAEhB,eAAO,MAAM,SAAS,GACnB,cAAc,eAAe,MAC7B,QAAQ,MAAM,KAAG,MAsYjB,CAAA"}