@payloadcms/plugin-seo 3.0.0-alpha.48 → 3.0.0-alpha.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { FormFieldBase } from '@payloadcms/ui';
1
+ import type { FormFieldBase } from '@payloadcms/ui/fields/shared';
2
2
  import React from 'react';
3
3
  type MetaDescriptionProps = FormFieldBase & {
4
4
  hasGenerateDescriptionFn: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"MetaDescription.d.ts","sourceRoot":"","sources":["../../src/fields/MetaDescription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,aAAa,EAAW,MAAM,gBAAgB,CAAA;AAMvE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAU1C,KAAK,oBAAoB,GAAG,aAAa,GAAG;IAC1C,wBAAwB,EAAE,OAAO,CAAA;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAgI1D,CAAA"}
1
+ {"version":3,"file":"MetaDescription.d.ts","sourceRoot":"","sources":["../../src/fields/MetaDescription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAWjE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAU1C,KAAK,oBAAoB,GAAG,aAAa,GAAG;IAC1C,wBAAwB,EAAE,OAAO,CAAA;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA+H1D,CAAA"}
@@ -1,15 +1,19 @@
1
1
  'use client';
2
- import { useFieldPath } from '@payloadcms/ui';
3
- import { useTranslation } from '@payloadcms/ui';
4
- import { TextareaInput } from '@payloadcms/ui';
5
- import { useAllFormFields, useDocumentInfo, useField, useLocale } from '@payloadcms/ui';
2
+ import { TextareaInput } from '@payloadcms/ui/fields/Textarea';
3
+ import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
4
+ import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
5
+ import { useAllFormFields } from '@payloadcms/ui/forms/Form';
6
+ import { useField } from '@payloadcms/ui/forms/useField';
7
+ import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
8
+ import { useLocale } from '@payloadcms/ui/providers/Locale';
9
+ import { useTranslation } from '@payloadcms/ui/providers/Translation';
6
10
  import React, { useCallback } from 'react';
7
11
  import { defaults } from '../defaults.js';
8
12
  import { LengthIndicator } from '../ui/LengthIndicator.js';
9
13
  const { maxLength, minLength } = defaults.description;
10
14
  export const MetaDescription = (props)=>{
11
- const { Label, hasGenerateDescriptionFn, path, required } = props;
12
- const { path: pathFromContext, schemaPath } = useFieldPath();
15
+ const { CustomLabel, hasGenerateDescriptionFn, labelProps, path, required } = props;
16
+ const { path: pathFromContext } = useFieldProps();
13
17
  const { t } = useTranslation();
14
18
  const locale = useLocale();
15
19
  const [fields] = useAllFormFields();
@@ -54,7 +58,7 @@ export const MetaDescription = (props)=>{
54
58
  }
55
59
  }, /*#__PURE__*/ React.createElement("div", {
56
60
  className: "plugin-seo__field"
57
- }, Label, required && /*#__PURE__*/ React.createElement("span", {
61
+ }, CustomLabel !== undefined ? CustomLabel : /*#__PURE__*/ React.createElement(FieldLabel, labelProps || {}), required && /*#__PURE__*/ React.createElement("span", {
58
62
  style: {
59
63
  color: 'var(--theme-error-500)',
60
64
  marginLeft: '5px'
@@ -88,7 +92,7 @@ export const MetaDescription = (props)=>{
88
92
  position: 'relative'
89
93
  }
90
94
  }, /*#__PURE__*/ React.createElement(TextareaInput, {
91
- Error: errorMessage,
95
+ CustomError: errorMessage,
92
96
  onChange: setValue,
93
97
  path: pathFromContext,
94
98
  required: required,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fields/MetaDescription.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, FormFieldBase, Options } from '@payloadcms/ui'\n\nimport { useFieldPath } from '@payloadcms/ui'\nimport { useTranslation } from '@payloadcms/ui'\nimport { TextareaInput } from '@payloadcms/ui'\nimport { useAllFormFields, useDocumentInfo, useField, useLocale } from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { GenerateDescription } from '../types.js'\n\nimport { defaults } from '../defaults.js'\nimport { LengthIndicator } from '../ui/LengthIndicator.js'\n\nconst { maxLength, minLength } = defaults.description\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaDescriptionProps = FormFieldBase & {\n hasGenerateDescriptionFn: boolean\n path: string\n}\n\nexport const MetaDescription: React.FC<MetaDescriptionProps> = (props) => {\n const { Label, hasGenerateDescriptionFn, path, required } = props\n const { path: pathFromContext, schemaPath } = useFieldPath()\n\n const { t } = useTranslation()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const docInfo = useDocumentInfo()\n\n const field: FieldType<string> = useField({\n path,\n } as Options)\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateDescription = useCallback(async () => {\n if (!hasGenerateDescriptionFn) return\n\n const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateDescription>[0]),\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 }, [fields, setValue, hasGenerateDescriptionFn, locale, docInfo])\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\n {required && (\n <span\n style={{\n color: 'var(--theme-error-500)',\n marginLeft: '5px',\n }}\n >\n *\n </span>\n )}\n\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={regenerateDescription}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipDescription', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextareaInput\n Error={errorMessage} // TODO: Fix\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["useFieldPath","useTranslation","TextareaInput","useAllFormFields","useDocumentInfo","useField","useLocale","React","useCallback","defaults","LengthIndicator","maxLength","minLength","description","MetaDescription","props","Label","hasGenerateDescriptionFn","path","required","pathFromContext","schemaPath","t","locale","fields","docInfo","field","errorMessage","setValue","showError","value","regenerateDescription","genDescriptionResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedDescription","json","div","style","marginBottom","position","className","span","color","marginLeft","Fragment","button","onClick","background","backgroundColor","border","cursor","padding","textDecoration","type","a","href","rel","target","Error","onChange","alignItems","display","width","text"],"mappings":"AAAA;AAIA,SAASA,YAAY,QAAQ,iBAAgB;AAC7C,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,gBAAgB,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,SAAS,QA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AAC+B;QACCJ,OAAO;YACLK,OAAO;YACPC,YAAY;QACd;OACD,MAKFnC,0CACC,oBAACV,MAAM8C,QAAQ,QAAC,uBAEd,oBAACC;QACCC,SAASxB;QACTe,OAAO;YACLU,YAAY;YACZC,iBAAiB;YACjBC,QAAQ;YACRP,OAAO;YACPQ,QAAQ;YACRC,SAAS;YACTC,gBAAgB;QAClB;QACAC,MAAK;OAEJxC,EAAE,6CAKX,oBAACuB;QACCC,OAAO;YACLK,OAAO;QACT;OAEC7B,EAAE,mCAAmC;QAAEX;QAAWC;IAAU,kBAC7D,oBAACmD;QACCC,MAAK;QACLC,KAAI;QACJC,QAAO;OAEN5C,EAAE,8CAIT,oBAACuB;QACCC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAAC9C;QACCiE,OAAOxC;QACPyC,UAAUxC;QACVV,MAAME;QACND,UAAUA;QACVU,WAAWA;QACXiB,OAAO;YACLC,cAAc;QAChB;QACAjB,OAAOA;uBAGX,oBAACe;QACCC,OAAO;YACLuB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAAC7D;QAAgBC,WAAWA;QAAWC,WAAWA;QAAW4D,MAAM1C;;AAI3E,EAAC"}
1
+ {"version":3,"sources":["../../src/fields/MetaDescription.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { FieldType, Options } from '@payloadcms/ui/forms/useField'\n\nimport { TextareaInput } from '@payloadcms/ui/fields/Textarea'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useAllFormFields } from '@payloadcms/ui/forms/Form'\nimport { useField } from '@payloadcms/ui/forms/useField'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useLocale } from '@payloadcms/ui/providers/Locale'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback } from 'react'\n\nimport type { GenerateDescription } from '../types.js'\n\nimport { defaults } from '../defaults.js'\nimport { LengthIndicator } from '../ui/LengthIndicator.js'\n\nconst { maxLength, minLength } = defaults.description\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaDescriptionProps = FormFieldBase & {\n hasGenerateDescriptionFn: boolean\n path: string\n}\n\nexport const MetaDescription: React.FC<MetaDescriptionProps> = (props) => {\n const { CustomLabel, hasGenerateDescriptionFn, labelProps, path, required } = props\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const docInfo = useDocumentInfo()\n\n const field: FieldType<string> = useField({\n path,\n } as Options)\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateDescription = useCallback(async () => {\n if (!hasGenerateDescriptionFn) return\n\n const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateDescription>[0]),\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 }, [fields, setValue, hasGenerateDescriptionFn, locale, docInfo])\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 {CustomLabel !== undefined ? CustomLabel : <FieldLabel {...(labelProps || {})} />}\n {required && (\n <span\n style={{\n color: 'var(--theme-error-500)',\n marginLeft: '5px',\n }}\n >\n *\n </span>\n )}\n\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={regenerateDescription}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipDescription', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextareaInput\n CustomError={errorMessage}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["TextareaInput","FieldLabel","useFieldProps","useAllFormFields","useField","useDocumentInfo","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","description","MetaDescription","props","CustomLabel","hasGenerateDescriptionFn","labelProps","path","required","pathFromContext","t","locale","fields","docInfo","field","errorMessage","setValue","showError","value","regenerateDescription","genDescriptionResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedDescription","json","div","style","marginBottom","position","className","undefined","span","color","marginLeft","Fragment","button","onClick","background","backgroundColor","border","cursor","padding","textDecoration","type","a","href","rel","target","CustomError","onChange","alignItems","display","width","text"],"mappings":"AAAA;AAKA,SAASA,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,QAAQ,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1EE,0BACC,oBAAC+B;QACCL,OAAO;YACLM,OAAO;YACPC,YAAY;QACd;OACD,MAKFpC,0CACC,oBAACV,MAAM+C,QAAQ,QAAC,uBAEd,oBAACC;QACCC,SAASzB;QACTe,OAAO;YACLW,YAAY;YACZC,iBAAiB;YACjBC,QAAQ;YACRP,OAAO;YACPQ,QAAQ;YACRC,SAAS;YACTC,gBAAgB;QAClB;QACAC,MAAK;OAEJzC,EAAE,6CAKX,oBAACuB;QACCC,OAAO;YACLM,OAAO;QACT;OAEC9B,EAAE,mCAAmC;QAAEX;QAAWC;IAAU,kBAC7D,oBAACoD;QACCC,MAAK;QACLC,KAAI;QACJC,QAAO;OAEN7C,EAAE,8CAIT,oBAACuB;QACCC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAACjD;QACCqE,aAAazC;QACb0C,UAAUzC;QACVT,MAAME;QACND,UAAUA;QACVS,WAAWA;QACXiB,OAAO;YACLC,cAAc;QAChB;QACAjB,OAAOA;uBAGX,oBAACe;QACCC,OAAO;YACLwB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAAC9D;QAAgBC,WAAWA;QAAWC,WAAWA;QAAW6D,MAAM3C;;AAI3E,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { UploadInputProps } from '@payloadcms/ui';
1
+ import type { UploadInputProps } from '@payloadcms/ui/fields/Upload';
2
2
  import React from 'react';
3
3
  type MetaImageProps = UploadInputProps & {
4
4
  hasGenerateImageFn: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"MetaImage.d.ts","sourceRoot":"","sources":["../../src/fields/MetaImage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAW1E,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,KAAK,cAAc,GAAG,gBAAgB,GAAG;IACvC,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAgJ9C,CAAA"}
1
+ {"version":3,"file":"MetaImage.d.ts","sourceRoot":"","sources":["../../src/fields/MetaImage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAWpE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,KAAK,cAAc,GAAG,gBAAgB,GAAG;IACvC,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA8I9C,CAAA"}
@@ -1,9 +1,16 @@
1
1
  'use client';
2
- import { UploadInput, useAllFormFields, useConfig, useDocumentInfo, useField, useLocale, useTranslation } from '@payloadcms/ui';
2
+ import { UploadInput } from '@payloadcms/ui/fields/Upload';
3
+ import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
4
+ import { useAllFormFields } from '@payloadcms/ui/forms/Form';
5
+ import { useField } from '@payloadcms/ui/forms/useField';
6
+ import { useConfig } from '@payloadcms/ui/providers/Config';
7
+ import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
8
+ import { useLocale } from '@payloadcms/ui/providers/Locale';
9
+ import { useTranslation } from '@payloadcms/ui/providers/Translation';
3
10
  import React, { useCallback } from 'react';
4
11
  import { Pill } from '../ui/Pill.js';
5
12
  export const MetaImage = (props)=>{
6
- const { Label, hasGenerateImageFn, path, relationTo, required } = props || {};
13
+ const { CustomLabel, hasGenerateImageFn, labelProps, relationTo, required } = props || {};
7
14
  const field = useField(props);
8
15
  const { t } = useTranslation();
9
16
  const locale = useLocale();
@@ -50,7 +57,7 @@ export const MetaImage = (props)=>{
50
57
  }
51
58
  }, /*#__PURE__*/ React.createElement("div", {
52
59
  className: "plugin-seo__field"
53
- }, Label, required && /*#__PURE__*/ React.createElement("span", {
60
+ }, CustomLabel !== undefined ? CustomLabel : /*#__PURE__*/ React.createElement(FieldLabel, labelProps || {}), required && /*#__PURE__*/ React.createElement("span", {
54
61
  style: {
55
62
  color: 'var(--theme-error-500)',
56
63
  marginLeft: '5px'
@@ -77,7 +84,7 @@ export const MetaImage = (props)=>{
77
84
  position: 'relative'
78
85
  }
79
86
  }, /*#__PURE__*/ React.createElement(UploadInput, {
80
- Error: errorMessage,
87
+ CustomError: errorMessage,
81
88
  api: api,
82
89
  collection: collection,
83
90
  filterOptions: {},
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fields/MetaImage.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options, UploadInputProps } from '@payloadcms/ui'\n\nimport {\n UploadInput,\n useAllFormFields,\n useConfig,\n useDocumentInfo,\n useField,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { GenerateImage } from '../types.js'\n\nimport { Pill } from '../ui/Pill.js'\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaImageProps = UploadInputProps & {\n hasGenerateImageFn: boolean\n}\n\nexport const MetaImage: React.FC<MetaImageProps> = (props) => {\n const { Label, hasGenerateImageFn, path, relationTo, required } = props || {}\n\n const field: FieldType<string> = useField(props as Options)\n\n const { t } = useTranslation()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateImage = useCallback(async () => {\n if (!hasGenerateImageFn) return\n\n const genImageResponse = await fetch('/api/plugin-seo/generate-image', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateImage>[0]),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedImage } = await genImageResponse.json()\n\n setValue(generatedImage || '')\n }, [fields, setValue, hasGenerateImageFn, locale, docInfo])\n\n const hasImage = Boolean(value)\n\n const config = useConfig()\n\n const { collections, routes: { api } = {}, serverURL } = config\n\n const collection = collections?.find((coll) => coll.slug === relationTo) || undefined\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n {Label}\n\n {required && (\n <span\n style={{\n color: 'var(--theme-error-500)',\n marginLeft: '5px',\n }}\n >\n *\n </span>\n )}\n\n {hasGenerateImageFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={regenerateImage}\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={errorMessage} // TODO: Fix\n api={api}\n collection={collection}\n filterOptions={{}}\n label={undefined}\n onChange={(incomingImage) => {\n if (incomingImage !== null) {\n const { id: incomingID } = incomingImage\n setValue(incomingID)\n } else {\n setValue(null)\n }\n }}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <Pill\n backgroundColor={hasImage ? 'green' : 'red'}\n color=\"white\"\n label={hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')}\n />\n </div>\n </div>\n )\n}\n"],"names":["UploadInput","useAllFormFields","useConfig","useDocumentInfo","useField","useLocale","useTranslation","React","useCallback","Pill","MetaImage","props","Label","hasGenerateImageFn","path","relationTo","required","field","t","locale","fields","docInfo","errorMessage","setValue","showError","value","regenerateImage","genImageResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedImage","json","hasImage","Boolean","config","collections","routes","api","serverURL","collection","find","coll","slug","undefined","div","style","marginBottom","position","className","span","color","marginLeft","Fragment","button","onClick","background","backgroundColor","border","cursor","padding","textDecoration","type","Error","filterOptions","label","onChange","incomingImage","id","incomingID","alignItems","display","width"],"mappings":"AAAA;AAIA,SACEA,WAAW,EACXC,gBAAgB,EAChBC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,IAAI,QAAQ,gBAAe;AAOpC,OAAO,MAAMC,YAAsC,CAACC;IAClD,MAAM,EAAEC,KAAK,EAAEC,kBAAkB,EAAEC,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGL,SAAS,CAAC;IAE5E,MAAMM,QAA2Bb,SAASO;IAE1C,MAAM,EAAEO,CAAC,EAAE,GAAGZ;IAEd,MAAMa,SAASd;IACf,MAAM,CAACe,OAAO,GAAGnB;IACjB,MAAMoB,UAAUlB;IAEhB,MAAM,EAAEmB,YAAY,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGR;IAErD,MAAMS,kBAAkBlB,YAAY;QAClC,IAAI,CAACK,oBAAoB;QAEzB,MAAMc,mBAAmB,MAAMC,MAAM,kCAAkC;YACrEC,MAAMC,KAAKC,SAAS,CAAC;gBACnB,GAAGV,OAAO;gBACVW,KAAK;oBAAE,GAAGZ,MAAM;gBAAC;gBACjBD,QAAQ,OAAOA,WAAW,WAAWA,QAAQc,OAAOd;YACtD;YACAe,aAAa;YACbC,SAAS;gBACP,gBAAgB;YAClB;YACAC,QAAQ;QACV;QAEA,MAAM,EAAEC,QAAQC,cAAc,EAAE,GAAG,MAAMX,iBAAiBY,IAAI;QAE9DhB,SAASe,kBAAkB;IAC7B,GAAG;QAAClB;QAAQG;QAAUV;QAAoBM;QAAQE;KAAQ;IAE1D,MAAMm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kB,OAAM;QACNc,OAAOhC,WAAWtB,EAAE,qBAAqBA,EAAE;;AAKrD,EAAC"}
1
+ {"version":3,"sources":["../../src/fields/MetaImage.tsx"],"sourcesContent":["'use client'\n\nimport type { UploadInputProps } from '@payloadcms/ui/fields/Upload'\nimport type { FieldType, Options } from '@payloadcms/ui/forms/useField'\n\nimport { UploadInput } from '@payloadcms/ui/fields/Upload'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport { useAllFormFields } from '@payloadcms/ui/forms/Form'\nimport { useField } from '@payloadcms/ui/forms/useField'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useLocale } from '@payloadcms/ui/providers/Locale'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback } from 'react'\n\nimport type { GenerateImage } from '../types.js'\n\nimport { Pill } from '../ui/Pill.js'\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaImageProps = UploadInputProps & {\n hasGenerateImageFn: boolean\n}\n\nexport const MetaImage: React.FC<MetaImageProps> = (props) => {\n const { CustomLabel, hasGenerateImageFn, labelProps, relationTo, required } = props || {}\n\n const field: FieldType<string> = useField(props as Options)\n\n const { t } = useTranslation()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateImage = useCallback(async () => {\n if (!hasGenerateImageFn) return\n\n const genImageResponse = await fetch('/api/plugin-seo/generate-image', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateImage>[0]),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedImage } = await genImageResponse.json()\n\n setValue(generatedImage || '')\n }, [fields, setValue, hasGenerateImageFn, locale, docInfo])\n\n const hasImage = Boolean(value)\n\n const config = useConfig()\n\n const { collections, routes: { api } = {}, serverURL } = config\n\n const collection = collections?.find((coll) => coll.slug === relationTo) || undefined\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n {CustomLabel !== undefined ? CustomLabel : <FieldLabel {...(labelProps || {})} />}\n {required && (\n <span\n style={{\n color: 'var(--theme-error-500)',\n marginLeft: '5px',\n }}\n >\n *\n </span>\n )}\n {hasGenerateImageFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={regenerateImage}\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 CustomError={errorMessage}\n api={api}\n collection={collection}\n filterOptions={{}}\n label={undefined}\n onChange={(incomingImage) => {\n if (incomingImage !== null) {\n const { id: incomingID } = incomingImage\n setValue(incomingID)\n } else {\n setValue(null)\n }\n }}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <Pill\n backgroundColor={hasImage ? 'green' : 'red'}\n color=\"white\"\n label={hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')}\n />\n </div>\n </div>\n )\n}\n"],"names":["UploadInput","FieldLabel","useAllFormFields","useField","useConfig","useDocumentInfo","useLocale","useTranslation","React","useCallback","Pill","MetaImage","props","CustomLabel","hasGenerateImageFn","labelProps","relationTo","required","field","t","locale","fields","docInfo","errorMessage","setValue","showError","value","regenerateImage","genImageResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedImage","json","hasImage","Boolean","config","collections","routes","api","serverURL","collection","find","coll","slug","undefined","div","style","marginBottom","position","className","span","color","marginLeft","Fragment","button","onClick","background","backgroundColor","border","cursor","padding","textDecoration","type","CustomError","filterOptions","label","onChange","incomingImage","id","incomingID","alignItems","display","width"],"mappings":"AAAA;AAKA,SAASA,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,IAAI,QAAQ,gBAAe;AAOpC,OAAO,MAAMC,YAAsC,CAACC;IAClD,MAAM,EAAEC,WAAW,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGL,SAAS,CAAC;IAExF,MAAMM,QAA2Bf,SAASS;IAE1C,MAAM,EAAEO,CAAC,EAAE,GAAGZ;IAEd,MAAMa,SAASd;IACf,MAAM,CAACe,OAAO,GAAGnB;IACjB,MAAMoB,UAAUjB;IAEhB,MAAM,EAAEkB,YAAY,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGR;IAErD,MAAMS,kBAAkBlB,YAAY;QAClC,IAAI,CAACK,oBAAoB;QAEzB,MAAMc,mBAAmB,MAAMC,MAAM,kCAAkC;YACrEC,MAAMC,KAAKC,SAAS,CAAC;gBACnB,GAAGV,OAAO;gBACVW,KAAK;oBAAE,GAAGZ,MAAM;gBAAC;gBACjBD,QAAQ,OAAOA,W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AM,EAAEC,IAAIC,UAAU,EAAE,GAAGF;gBAC3BnD,SAASqD;YACX,OAAO;gBACLrD,SAAS;YACX;QACF;QACAR,YAAYA;QACZC,UAAUA;QACV8B,WAAWA;QACXtB,WAAWA;QACX6B,OAAO;YACLC,cAAc;QAChB;QACA7B,OAAOA;uBAGX,oBAAC2B;QACCC,OAAO;YACLwB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAACtE;QACCuD,iBAAiBxB,WAAW,UAAU;QACtCkB,OAAM;QACNc,OAAOhC,WAAWtB,EAAE,qBAAqBA,EAAE;;AAKrD,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { FormFieldBase } from '@payloadcms/ui';
1
+ import type { FormFieldBase } from '@payloadcms/ui/fields/shared';
2
2
  import React from 'react';
3
3
  import './index.scss';
4
4
  type MetaTitleProps = FormFieldBase & {
@@ -1 +1 @@
1
- {"version":3,"file":"MetaTitle.d.ts","sourceRoot":"","sources":["../../src/fields/MetaTitle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,aAAa,EAAW,MAAM,gBAAgB,CAAA;AAWvE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAM1C,OAAO,cAAc,CAAA;AAKrB,KAAK,cAAc,GAAG,aAAa,GAAG;IACpC,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAiI9C,CAAA"}
1
+ {"version":3,"file":"MetaTitle.d.ts","sourceRoot":"","sources":["../../src/fields/MetaTitle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAYjE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAM1C,OAAO,cAAc,CAAA;AAKrB,KAAK,cAAc,GAAG,aAAa,GAAG;IACpC,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA+H9C,CAAA"}
@@ -1,14 +1,20 @@
1
1
  'use client';
2
- import { useFieldPath } from '@payloadcms/ui';
3
- import { TextInput, useAllFormFields, useDocumentInfo, useField, useLocale, useTranslation } from '@payloadcms/ui';
2
+ import { TextInput } from '@payloadcms/ui/fields/Text';
3
+ import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
4
+ import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
5
+ import { useAllFormFields } from '@payloadcms/ui/forms/Form';
6
+ import { useField } from '@payloadcms/ui/forms/useField';
7
+ import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
8
+ import { useLocale } from '@payloadcms/ui/providers/Locale';
9
+ import { useTranslation } from '@payloadcms/ui/providers/Translation';
4
10
  import React, { useCallback } from 'react';
5
11
  import { defaults } from '../defaults.js';
6
12
  import { LengthIndicator } from '../ui/LengthIndicator.js';
7
13
  import './index.scss';
8
14
  const { maxLength, minLength } = defaults.title;
9
15
  export const MetaTitle = (props)=>{
10
- const { Label, hasGenerateTitleFn, path, required } = props || {};
11
- const { path: pathFromContext, schemaPath } = useFieldPath();
16
+ const { CustomLabel, hasGenerateTitleFn, labelProps, path, required } = props || {};
17
+ const { path: pathFromContext } = useFieldProps();
12
18
  const { t } = useTranslation();
13
19
  const field = useField({
14
20
  path
@@ -53,7 +59,7 @@ export const MetaTitle = (props)=>{
53
59
  }
54
60
  }, /*#__PURE__*/ React.createElement("div", {
55
61
  className: "plugin-seo__field"
56
- }, Label, required && /*#__PURE__*/ React.createElement("span", {
62
+ }, CustomLabel !== undefined ? CustomLabel : /*#__PURE__*/ React.createElement(FieldLabel, labelProps || {}), required && /*#__PURE__*/ React.createElement("span", {
57
63
  style: {
58
64
  color: 'var(--theme-error-500)',
59
65
  marginLeft: '5px'
@@ -87,7 +93,7 @@ export const MetaTitle = (props)=>{
87
93
  position: 'relative'
88
94
  }
89
95
  }, /*#__PURE__*/ React.createElement(TextInput, {
90
- Error: errorMessage,
96
+ CustomError: errorMessage,
91
97
  onChange: setValue,
92
98
  path: pathFromContext,
93
99
  required: required,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fields/MetaTitle.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, FormFieldBase, Options } from '@payloadcms/ui'\n\nimport { useFieldPath } from '@payloadcms/ui'\nimport {\n TextInput,\n useAllFormFields,\n useDocumentInfo,\n useField,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { GenerateTitle } from '../types.js'\n\nimport { defaults } from '../defaults.js'\nimport { LengthIndicator } from '../ui/LengthIndicator.js'\nimport './index.scss'\n\nconst { maxLength, minLength } = defaults.title\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaTitleProps = FormFieldBase & {\n hasGenerateTitleFn: boolean\n}\n\nexport const MetaTitle: React.FC<MetaTitleProps> = (props) => {\n const { Label, hasGenerateTitleFn, path, required } = props || {}\n const { path: pathFromContext, schemaPath } = useFieldPath()\n\n const { t } = useTranslation()\n\n const field: FieldType<string> = useField({\n path,\n } as Options)\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) return\n\n const genTitleResponse = await fetch('/api/plugin-seo/generate-title', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateTitle>[0]),\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 }, [fields, setValue, hasGenerateTitleFn, locale, docInfo])\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\n {required && (\n <span\n style={{\n color: 'var(--theme-error-500)',\n marginLeft: '5px',\n }}\n >\n *\n </span>\n )}\n\n {hasGenerateTitleFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={regenerateTitle}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipTitle', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n .\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextInput\n Error={errorMessage} // TODO: fix errormessage\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["useFieldPath","TextInput","useAllFormFields","useDocumentInfo","useField","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","title","MetaTitle","props","Label","hasGenerateTitleFn","path","required","pathFromContext","schemaPath","t","field","locale","fields","docInfo","errorMessage","setValue","showError","value","regenerateTitle","genTitleResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedTitle","json","div","style","marginBottom","position","className","span","color","marginLeft","Fragment","button","onClick","background","backgroundColor","border","cursor","padding","textDecoration","type","a","href","rel","target","Error","onChange","alignItems","display","width","text"],"mappings":"AAAA;AAIA,SAASA,YAAY,QAAQ,iBAAgB;AAC7C,SACEC,S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AACF;QACCC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAACH;QAAII,WAAU;OACZjC,OAEAG,0BACC,oBAAC+B;QACCJ,OAAO;YACLK,OAAO;YACPC,YAAY;QACd;OACD,MAKFnC,oCACC,oBAACV,MAAM8C,QAAQ,QAAC,uBAEd,oBAACC;QACCC,SAASxB;QACTe,OAAO;YACLU,YAAY;YACZC,iBAAiB;YACjBC,QAAQ;YACRP,OAAO;YACPQ,QAAQ;YACRC,SAAS;YACTC,gBAAgB;QAClB;QACAC,MAAK;OAEJxC,EAAE,6CAKX,oBAACuB;QACCC,OAAO;YACLK,OAAO;QACT;OAEC7B,EAAE,6BAA6B;QAAEX;QAAWC;IAAU,kBACvD,oBAACmD;QACCC,MAAK;QACLC,KAAI;QACJC,QAAO;OAEN5C,EAAE,8BACD,qBAIR,oBAACuB;QACCC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAAC/C;QACCkE,OAAOxC;QACPyC,UAAUxC;QACVV,MAAME;QACND,UAAUA;QACVU,WAAWA;QACXiB,OAAO;YACLC,cAAc;QAChB;QACAjB,OAAOA;uBAGX,oBAACe;QACCC,OAAO;YACLuB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAAC7D;QAAgBC,WAAWA;QAAWC,WAAWA;QAAW4D,MAAM1C;;AAI3E,EAAC"}
1
+ {"version":3,"sources":["../../src/fields/MetaTitle.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { Options } from '@payloadcms/ui/forms/useField'\nimport type { FieldType } from '@payloadcms/ui/forms/useField'\n\nimport { TextInput } from '@payloadcms/ui/fields/Text'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useAllFormFields } from '@payloadcms/ui/forms/Form'\nimport { useField } from '@payloadcms/ui/forms/useField'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useLocale } from '@payloadcms/ui/providers/Locale'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback } from 'react'\n\nimport type { GenerateTitle } from '../types.js'\n\nimport { defaults } from '../defaults.js'\nimport { LengthIndicator } from '../ui/LengthIndicator.js'\nimport './index.scss'\n\nconst { maxLength, minLength } = defaults.title\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaTitleProps = FormFieldBase & {\n hasGenerateTitleFn: boolean\n}\n\nexport const MetaTitle: React.FC<MetaTitleProps> = (props) => {\n const { CustomLabel, hasGenerateTitleFn, labelProps, path, required } = props || {}\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation()\n\n const field: FieldType<string> = useField({\n path,\n } as Options)\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) return\n\n const genTitleResponse = await fetch('/api/plugin-seo/generate-title', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateTitle>[0]),\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 }, [fields, setValue, hasGenerateTitleFn, locale, docInfo])\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 {CustomLabel !== undefined ? CustomLabel : <FieldLabel {...(labelProps || {})} />}\n {required && (\n <span\n style={{\n color: 'var(--theme-error-500)',\n marginLeft: '5px',\n }}\n >\n *\n </span>\n )}\n {hasGenerateTitleFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={regenerateTitle}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipTitle', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n .\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextInput\n CustomError={errorMessage}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["TextInput","FieldLabel","useFieldProps","useAllFormFields","useField","useDocumentInfo","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","title","MetaTitle","props","CustomLabel","hasGenerateTitleFn","labelProps","path","required","pathFromContext","t","field","locale","fields","docInfo","errorMessage","setValue","showError","value","regenerateTitle","genTitleResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedTitle","json","div","style","marginBottom","position","className","undefined","span","color","marginLeft","Fragment","button","onClick","background","backgroundColor","border","cursor","padding","textDecoration","type","a","href","rel","target","CustomError","onChange","alignItems","display","width","text"],"mappings":"AAAA;AAMA,SAASA,SAAS,QAAQ,6BAA4B;AACtD,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,eAAe,QAAQ,wCAAuC;A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YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAACH;QAAII,WAAU;OACZjC,gBAAgBkC,YAAYlC,4BAAc,oBAAChB,YAAgBkB,cAAc,CAAC,IAC1EE,0BACC,oBAAC+B;QACCL,OAAO;YACLM,OAAO;YACPC,YAAY;QACd;OACD,MAIFpC,oCACC,oBAACV,MAAM+C,QAAQ,QAAC,uBAEd,oBAACC;QACCC,SAASzB;QACTe,OAAO;YACLW,YAAY;YACZC,iBAAiB;YACjBC,QAAQ;YACRP,OAAO;YACPQ,QAAQ;YACRC,SAAS;YACTC,gBAAgB;QAClB;QACAC,MAAK;OAEJzC,EAAE,6CAKX,oBAACuB;QACCC,OAAO;YACLM,OAAO;QACT;OAEC9B,EAAE,6BAA6B;QAAEX;QAAWC;IAAU,kBACvD,oBAACoD;QACCC,MAAK;QACLC,KAAI;QACJC,QAAO;OAEN7C,EAAE,8BACD,qBAIR,oBAACuB;QACCC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAACjD;QACCqE,aAAazC;QACb0C,UAAUzC;QACVT,MAAME;QACND,UAAUA;QACVS,WAAWA;QACXiB,OAAO;YACLC,cAAc;QAChB;QACAjB,OAAOA;uBAGX,oBAACe;QACCC,OAAO;YACLwB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAAC9D;QAAgBC,WAAWA;QAAWC,WAAWA;QAAW6D,MAAM3C;;AAI3E,EAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Config } from 'payload/config';
2
2
  import type { PluginConfig } from './types.js';
3
3
  declare const seo: (pluginConfig: PluginConfig) => (config: Config) => Config;
4
- export default seo;
4
+ export { seo };
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAM5C,OAAO,KAAK,EAKV,YAAY,EACb,MAAM,YAAY,CAAA;AASnB,QAAA,MAAM,GAAG,iBACQ,YAAY,cAClB,MAAM,KAAG,MA6PjB,CAAA;AAEH,eAAe,GAAG,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAM5C,OAAO,KAAK,EAKV,YAAY,EACb,MAAM,YAAY,CAAA;AASnB,QAAA,MAAM,GAAG,iBACQ,YAAY,cAClB,MAAM,KAAG,MA2QjB,CAAA;AAEH,OAAO,EAAE,GAAG,EAAE,CAAA"}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import { MetaDescription } from './fields/MetaDescription.js';
4
4
  import { MetaImage } from './fields/MetaImage.js';
5
5
  import { MetaTitle } from './fields/MetaTitle.js';
6
- import translations from './translations/index.js';
6
+ import { translations } from './translations/index.js';
7
7
  import { Overview } from './ui/Overview.js';
8
8
  import { Preview } from './ui/Preview.js';
9
9
  const seo = (pluginConfig)=>(config)=>{
@@ -98,16 +98,27 @@ const seo = (pluginConfig)=>(config)=>{
98
98
  if (pluginConfig?.tabbedUI) {
99
99
  // prevent issues with auth enabled collections having an email field that shouldn't be moved to the SEO tab
100
100
  const emailField = (collection.auth || !(typeof collection.auth === 'object' && collection.auth.disableLocalStrategy)) && collection.fields?.find((field)=>'name' in field && field.name === 'email');
101
- const seoTabs = [
101
+ const hasOnlyEmailField = collection.fields?.length === 1 && emailField;
102
+ const seoTabs = hasOnlyEmailField ? [
103
+ {
104
+ type: 'tabs',
105
+ tabs: [
106
+ {
107
+ fields: seoFields,
108
+ label: 'SEO'
109
+ }
110
+ ]
111
+ }
112
+ ] : [
102
113
  {
103
114
  type: 'tabs',
104
115
  tabs: [
105
116
  // append a new tab onto the end of the tabs array, if there is one at the first index
106
117
  // if needed, create a new `Content` tab in the first index for this collection's base fields
107
- ...collection?.fields?.[0]?.type === 'tabs' ? collection.fields[0]?.tabs : [
118
+ ...collection?.fields?.[0]?.type === 'tabs' && collection?.fields?.[0]?.tabs ? collection.fields[0].tabs : [
108
119
  {
109
120
  fields: [
110
- ...(emailField ? collection.fields.filter((field)=>'name' in field && field.name !== 'email') : collection.fields) || []
121
+ ...emailField ? collection.fields.filter((field)=>'name' in field && field.name !== 'email') : collection.fields
111
122
  ],
112
123
  label: collection?.labels?.singular || 'Content'
113
124
  }
@@ -203,7 +214,7 @@ const seo = (pluginConfig)=>(config)=>{
203
214
  tabs: [
204
215
  // append a new tab onto the end of the tabs array, if there is one at the first index
205
216
  // if needed, create a new `Content` tab in the first index for this global's base fields
206
- ...global?.fields?.[0].type === 'tabs' ? global.fields[0]?.tabs : [
217
+ ...global?.fields?.[0].type === 'tabs' && global?.fields?.[0].tabs ? global.fields[0].tabs : [
207
218
  {
208
219
  fields: [
209
220
  ...global?.fields || []
@@ -222,7 +233,7 @@ const seo = (pluginConfig)=>(config)=>{
222
233
  ...global,
223
234
  fields: [
224
235
  ...seoTabs,
225
- ...global?.fields?.[0].type === 'tabs' ? global?.fields?.slice(1) : []
236
+ ...global?.fields?.[0].type === 'tabs' ? global.fields.slice(1) : []
226
237
  ]
227
238
  };
228
239
  }
@@ -244,6 +255,6 @@ const seo = (pluginConfig)=>(config)=>{
244
255
  }
245
256
  };
246
257
  };
247
- export default seo;
258
+ export { seo };
248
259
 
249
260
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import type { Config } from 'payload/config'\nimport type { Field, GroupField, TabsField, TextField } from 'payload/types'\n\nimport { deepMerge } from 'payload/utilities'\nimport React from 'react'\n\nimport type {\n GenerateDescription,\n GenerateImage,\n GenerateTitle,\n GenerateURL,\n PluginConfig,\n} from './types.js'\n\nimport { MetaDescription } from './fields/MetaDescription.js'\nimport { MetaImage } from './fields/MetaImage.js'\nimport { MetaTitle } from './fields/MetaTitle.js'\nimport translations from './translations/index.js'\nimport { Overview } from './ui/Overview.js'\nimport { Preview } from './ui/Preview.js'\n\nconst seo =\n (pluginConfig: PluginConfig) =>\n (config: Config): Config => {\n const seoFields: GroupField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n {\n name: 'overview',\n type: 'ui',\n admin: {\n components: {\n Field: Overview,\n },\n },\n label: 'Overview',\n },\n {\n name: 'title',\n type: 'text',\n admin: {\n components: {\n Field: (props) => (\n <MetaTitle\n {...props}\n hasGenerateTitleFn={typeof pluginConfig.generateTitle === 'function'}\n />\n ),\n },\n },\n localized: true,\n ...((pluginConfig?.fieldOverrides?.title as unknown as TextField) ?? {}),\n },\n {\n name: 'description',\n type: 'textarea',\n admin: {\n components: {\n Field: (props) => (\n <MetaDescription\n {...props}\n hasGenerateDescriptionFn={\n typeof pluginConfig.generateDescription === 'function'\n }\n />\n ),\n },\n },\n localized: true,\n ...(pluginConfig?.fieldOverrides?.description ?? {}),\n },\n ...(pluginConfig?.uploadsCollection\n ? [\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n {\n name: 'image',\n type: 'upload',\n admin: {\n components: {\n Field: (props) => (\n <MetaImage\n {...props}\n hasGenerateImageFn={typeof pluginConfig.generateImage === 'function'}\n />\n ),\n },\n description:\n 'Maximum upload file size: 12MB. Recommended file size for images is <500KB.',\n },\n label: 'Meta Image',\n localized: true,\n relationTo: pluginConfig?.uploadsCollection,\n ...(pluginConfig?.fieldOverrides?.image ?? {}),\n } as Field,\n ]\n : []),\n ...(pluginConfig?.fields || []),\n {\n name: 'preview',\n type: 'ui',\n admin: {\n components: {\n Field: (props) => (\n <Preview\n {...props}\n hasGenerateURLFn={typeof pluginConfig.generateURL === 'function'}\n />\n ),\n },\n },\n label: 'Preview',\n },\n ],\n interfaceName: pluginConfig.interfaceName,\n label: 'SEO',\n },\n ]\n\n return {\n ...config,\n collections:\n config.collections?.map((collection) => {\n const { slug } = collection\n const isEnabled = pluginConfig?.collections?.includes(slug)\n\n if (isEnabled) {\n if (pluginConfig?.tabbedUI) {\n // prevent issues with auth enabled collections having an email field that shouldn't be moved to the SEO tab\n const emailField =\n (collection.auth ||\n !(typeof collection.auth === 'object' && collection.auth.disableLocalStrategy)) &&\n collection.fields?.find((field) => 'name' in field && field.name === 'email')\n\n const seoTabs: TabsField[] = [\n {\n type: 'tabs',\n tabs: [\n // append a new tab onto the end of the tabs array, if there is one at the first index\n // if needed, create a new `Content` tab in the first index for this collection's base fields\n ...(collection?.fields?.[0]?.type === 'tabs'\n ? collection.fields[0]?.tabs\n : [\n {\n fields: [\n ...((emailField\n ? collection.fields.filter(\n (field) => 'name' in field && field.name !== 'email',\n )\n : collection.fields) || []),\n ],\n label: collection?.labels?.singular || 'Content',\n },\n ]),\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n\n return {\n ...collection,\n fields: [\n ...(emailField ? [emailField] : []),\n ...seoTabs,\n ...(collection?.fields?.[0]?.type === 'tabs' ? collection.fields.slice(1) : []),\n ],\n }\n }\n\n return {\n ...collection,\n fields: [...(collection?.fields || []), ...seoFields],\n }\n }\n\n return collection\n }) || [],\n endpoints: [\n {\n handler: async (req) => {\n const args: Parameters<GenerateTitle>[0] =\n req.data as unknown as Parameters<GenerateTitle>[0]\n const result = await pluginConfig.generateTitle(args)\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-title',\n },\n {\n handler: async (req) => {\n const args: Parameters<GenerateDescription>[0] =\n req.data as unknown as Parameters<GenerateDescription>[0]\n const result = await pluginConfig.generateDescription(args)\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-description',\n },\n {\n handler: async (req) => {\n const args: Parameters<GenerateURL>[0] =\n req.data as unknown as Parameters<GenerateURL>[0]\n const result = await pluginConfig.generateURL(args)\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-url',\n },\n {\n handler: async (req) => {\n const args: Parameters<GenerateImage>[0] =\n req.data as unknown as Parameters<GenerateImage>[0]\n const result = await pluginConfig.generateImage(args)\n return new Response(result, { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-image',\n },\n ],\n globals:\n config.globals?.map((global) => {\n const { slug } = global\n const isEnabled = pluginConfig?.globals?.includes(slug)\n\n if (isEnabled) {\n if (pluginConfig?.tabbedUI) {\n const seoTabs: TabsField[] = [\n {\n type: 'tabs',\n tabs: [\n // append a new tab onto the end of the tabs array, if there is one at the first index\n // if needed, create a new `Content` tab in the first index for this global's base fields\n ...(global?.fields?.[0].type === 'tabs'\n ? global.fields[0]?.tabs\n : [\n {\n fields: [...(global?.fields || [])],\n label: global?.label || 'Content',\n },\n ]),\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n\n return {\n ...global,\n fields: [\n ...seoTabs,\n ...(global?.fields?.[0].type === 'tabs' ? global?.fields?.slice(1) : []),\n ],\n }\n }\n\n return {\n ...global,\n fields: [...(global?.fields || []), ...seoFields],\n }\n }\n\n return global\n }) || [],\n i18n: {\n ...config.i18n,\n translations: {\n ...deepMerge(translations, config.i18n?.translations),\n },\n },\n }\n }\n\nexport default seo\n"],"names":["deepMerge","React","MetaDescription","MetaImage","MetaTitle","translations","Overview","Preview","seo","pluginConfig","config","seoFields","name","type","fields","admin","components","Field","label","props","hasGenerateTitleFn","generateTitle","localized","fieldOverrides","title","hasGenerateDescriptionFn","generateDescription","description","uploadsCollection","hasGenerateImageFn","generateImage","relationTo","image","hasGenerateURLFn","generateURL","interfaceName","collections","map","collection","slug","isEnabled","includes","tabbedUI","emailField","auth","disableLocalStrategy","find","field","seoTabs","tabs","filter","labels","singular","slice","endpoints","handler","req","args","data","result","Response","JSON","stringify","status","method","path","globals","global","i18n"],"mappings":"AAGA,SAASA,SAAS,QAAQ,oBAAmB;AAC7C,OAAOC,WAAW,QAAO;AAUzB,SAASC,eAAe,QAAQ,8BAA6B;AA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,QAAQ;oBACRC,MAAM;gBACR;aACD;YACDC,SACExD,OAAOwD,OAAO,EAAE7B,IAAI,CAAC8B;gBACnB,MAAM,EAAE5B,IAAI,EAAE,GAAG4B;gBACjB,MAAM3B,YAAY/B,cAAcyD,SAASzB,SAASF;gBAElD,IAAIC,WAAW;oBACb,IAAI/B,cAAciC,UAAU;wBAC1B,MAAMM,UAAuB;4BAC3B;gCACEnC,MAAM;gCACNoC,MAAM;oCACJ,sFAAsF;oCACtF,yFAAyF;uCACrFkB,QAAQrD,QAAQ,CAAC,EAAE,CAACD,SAAS,SAC7BsD,OAAOrD,MAAM,CAAC,EAAE,EAAEmC,OAClB;wCACE;4CACEnC,QAAQ;mDAAKqD,QAAQrD,UAAU,EAAE;6CAAE;4CACnCI,OAAOiD,QAAQjD,SAAS;wCAC1B;qCACD;oCACL;wCACEJ,QAAQH;wCACRO,OAAO;oCACT;iCACD;4BACH;yBACD;wBAED,OAAO;4BACL,GAAGiD,MAAM;4BACTrD,QAAQ;mCACHkC;mCACCmB,QAAQrD,QAAQ,CAAC,EAAE,CAACD,SAAS,SAASsD,QAAQrD,QAAQuC,MAAM,KAAK,EAAE;6BACxE;wBACH;oBACF;oBAEA,OAAO;wBACL,GAAGc,MAAM;wBACTrD,QAAQ;+BAAKqD,QAAQrD,UAAU,EAAE;+BAAMH;yBAAU;oBACnD;gBACF;gBAEA,OAAOwD;YACT,MAAM,EAAE;YACVC,MAAM;gBACJ,GAAG1D,OAAO0D,IAAI;gBACd/D,cAAc;oBACZ,GAAGL,UAAUK,cAAcK,OAAO0D,IAAI,EAAE/D,aAAa;gBACvD;YACF;QACF;IACF;AAEF,eAAeG,IAAG"}
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import type { Config } from 'payload/config'\nimport type { Field, GroupField, TabsField, TextField } from 'payload/types'\n\nimport { deepMerge } from 'payload/utilities'\nimport React from 'react'\n\nimport type {\n GenerateDescription,\n GenerateImage,\n GenerateTitle,\n GenerateURL,\n PluginConfig,\n} from './types.js'\n\nimport { MetaDescription } from './fields/MetaDescription.js'\nimport { MetaImage } from './fields/MetaImage.js'\nimport { MetaTitle } from './fields/MetaTitle.js'\nimport { translations } from './translations/index.js'\nimport { Overview } from './ui/Overview.js'\nimport { Preview } from './ui/Preview.js'\n\nconst seo =\n (pluginConfig: PluginConfig) =>\n (config: Config): Config => {\n const seoFields: GroupField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n {\n name: 'overview',\n type: 'ui',\n admin: {\n components: {\n Field: Overview,\n },\n },\n label: 'Overview',\n },\n {\n name: 'title',\n type: 'text',\n admin: {\n components: {\n Field: (props) => (\n <MetaTitle\n {...props}\n hasGenerateTitleFn={typeof pluginConfig.generateTitle === 'function'}\n />\n ),\n },\n },\n localized: true,\n ...((pluginConfig?.fieldOverrides?.title as unknown as TextField) ?? {}),\n },\n {\n name: 'description',\n type: 'textarea',\n admin: {\n components: {\n Field: (props) => (\n <MetaDescription\n {...props}\n hasGenerateDescriptionFn={\n typeof pluginConfig.generateDescription === 'function'\n }\n />\n ),\n },\n },\n localized: true,\n ...(pluginConfig?.fieldOverrides?.description ?? {}),\n },\n ...(pluginConfig?.uploadsCollection\n ? [\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n {\n name: 'image',\n type: 'upload',\n admin: {\n components: {\n Field: (props) => (\n <MetaImage\n {...props}\n hasGenerateImageFn={typeof pluginConfig.generateImage === 'function'}\n />\n ),\n },\n description:\n 'Maximum upload file size: 12MB. Recommended file size for images is <500KB.',\n },\n label: 'Meta Image',\n localized: true,\n relationTo: pluginConfig?.uploadsCollection,\n ...(pluginConfig?.fieldOverrides?.image ?? {}),\n } as Field,\n ]\n : []),\n ...(pluginConfig?.fields || []),\n {\n name: 'preview',\n type: 'ui',\n admin: {\n components: {\n Field: (props) => (\n <Preview\n {...props}\n hasGenerateURLFn={typeof pluginConfig.generateURL === 'function'}\n />\n ),\n },\n },\n label: 'Preview',\n },\n ],\n interfaceName: pluginConfig.interfaceName,\n label: 'SEO',\n },\n ]\n\n return {\n ...config,\n collections:\n config.collections?.map((collection) => {\n const { slug } = collection\n const isEnabled = pluginConfig?.collections?.includes(slug)\n\n if (isEnabled) {\n if (pluginConfig?.tabbedUI) {\n // prevent issues with auth enabled collections having an email field that shouldn't be moved to the SEO tab\n const emailField =\n (collection.auth ||\n !(typeof collection.auth === 'object' && collection.auth.disableLocalStrategy)) &&\n collection.fields?.find((field) => 'name' in field && field.name === 'email')\n const hasOnlyEmailField = collection.fields?.length === 1 && emailField\n\n const seoTabs: TabsField[] = hasOnlyEmailField\n ? [\n {\n type: 'tabs',\n tabs: [\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n : [\n {\n type: 'tabs',\n tabs: [\n // append a new tab onto the end of the tabs array, if there is one at the first index\n // if needed, create a new `Content` tab in the first index for this collection's base fields\n ...(collection?.fields?.[0]?.type === 'tabs' &&\n collection?.fields?.[0]?.tabs\n ? collection.fields[0].tabs\n : [\n {\n fields: [\n ...(emailField\n ? collection.fields.filter(\n (field) => 'name' in field && field.name !== 'email',\n )\n : collection.fields),\n ],\n label: collection?.labels?.singular || 'Content',\n },\n ]),\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n\n return {\n ...collection,\n fields: [\n ...(emailField ? [emailField] : []),\n ...seoTabs,\n ...(collection?.fields?.[0]?.type === 'tabs' ? collection.fields.slice(1) : []),\n ],\n }\n }\n\n return {\n ...collection,\n fields: [...(collection?.fields || []), ...seoFields],\n }\n }\n\n return collection\n }) || [],\n endpoints: [\n {\n handler: async (req) => {\n const args: Parameters<GenerateTitle>[0] =\n req.data as unknown as Parameters<GenerateTitle>[0]\n const result = await pluginConfig.generateTitle(args)\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-title',\n },\n {\n handler: async (req) => {\n const args: Parameters<GenerateDescription>[0] =\n req.data as unknown as Parameters<GenerateDescription>[0]\n const result = await pluginConfig.generateDescription(args)\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-description',\n },\n {\n handler: async (req) => {\n const args: Parameters<GenerateURL>[0] =\n req.data as unknown as Parameters<GenerateURL>[0]\n const result = await pluginConfig.generateURL(args)\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-url',\n },\n {\n handler: async (req) => {\n const args: Parameters<GenerateImage>[0] =\n req.data as unknown as Parameters<GenerateImage>[0]\n const result = await pluginConfig.generateImage(args)\n return new Response(result, { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-image',\n },\n ],\n globals:\n config.globals?.map((global) => {\n const { slug } = global\n const isEnabled = pluginConfig?.globals?.includes(slug)\n\n if (isEnabled) {\n if (pluginConfig?.tabbedUI) {\n const seoTabs: TabsField[] = [\n {\n type: 'tabs',\n tabs: [\n // append a new tab onto the end of the tabs array, if there is one at the first index\n // if needed, create a new `Content` tab in the first index for this global's base fields\n ...(global?.fields?.[0].type === 'tabs' && global?.fields?.[0].tabs\n ? global.fields[0].tabs\n : [\n {\n fields: [...(global?.fields || [])],\n label: global?.label || 'Content',\n },\n ]),\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n\n return {\n ...global,\n fields: [\n ...seoTabs,\n ...(global?.fields?.[0].type === 'tabs' ? global.fields.slice(1) : []),\n ],\n }\n }\n\n return {\n ...global,\n fields: [...(global?.fields || []), ...seoFields],\n }\n }\n\n return global\n }) || [],\n i18n: {\n ...config.i18n,\n translations: {\n ...deepMerge(translations, config.i18n?.translations),\n },\n },\n }\n }\n\nexport { seo }\n"],"names":["deepMerge","React","MetaDescription","MetaImage","MetaTitle","translations","Overview","Preview","seo","pluginConfig","config","seoFields","name","type","fields","admin","components","Field","label","props","hasGenerateTitleFn","generateTitle","localized","fieldOverrides","title","hasGenerateDescriptionFn","generateDescription","description","uploadsCollection","hasGenerateImageFn","generateImage","relationTo","image","hasGenerateURLFn","generateURL","interfaceName","collections","map","collection","slug","isEnabled","includes","tabbedUI","emailField","auth","disableLocalStrategy","find","field","hasOnlyEmailField","length","seoTabs","tabs","filter","labels","singular","slice","endpoints","handler","req","args","data","result","Response","JSON","stringify","status","method","path","globals","global","i18n"],"mappings":"AAGA,SAASA,SAAS,QAAQ,oBAAmB;AAC7C,OAAOC,WAAW,QAAO;AAUzB,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,QAAQ,QAAQ,mBAAkB;AAC3C,SAASC,OAAO,QAAQ,kBAAiB;AAEzC,MAAMC,MACJ,CAACC,eACD,CAACC;QACC,MAAMC,YAA0B;YAC9B;gBACEC,MAAM;gBACNC,MAAM;gBACNC,QAAQ;oBACN;wBACEF,MAAM;wBACNC,MAAM;wBACNE,OAAO;4BACLC,YAAY;gCACVC,OAAOX;4BACT;wBACF;wBACAY,OAAO;oBACT;oBACA;wBACEN,MAAM;wBACNC,MAAM;wBACNE,OAAO;4BACLC,YAAY;gCACVC,OAAO,CAACE,sBACN,oBAACf;wCACE,GAAGe,KAAK;wCACTC,oBAAoB,OAAOX,aAAaY,aAAa,KAAK;;4BAGhE;wBACF;wBACAC,WAAW;wBACX,GAAI,AAACb,cAAcc,gBAAgBC,SAAkC,CAAC,CAAC;oBACzE;oBACA;wBACEZ,MAAM;wBACNC,MAAM;wBACNE,OAAO;4BACLC,YAAY;gCACVC,OAAO,CAACE,sBACN,oBAACjB;wCACE,GAAGiB,KAAK;wCACTM,0BACE,OAAOhB,aAAaiB,mBAAmB,KAAK;;4BAIpD;wBACF;wBACAJ,WAAW;wBACX,GAAIb,cAAcc,gBAAgBI,eAAe,CAAC,CAAC;oBACrD;uBACIlB,cAAcmB,oBACd;wBACE,yEAAyE;wBACzE;4BACEhB,MAAM;4BACNC,MAAM;4BACNE,OAAO;gCACLC,YAAY;oC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;wBACH;oBACF;oBAEA,OAAO;wBACL,GAAGc,MAAM;wBACTvD,QAAQ;+BAAKuD,QAAQvD,UAAU,EAAE;+BAAMH;yBAAU;oBACnD;gBACF;gBAEA,OAAO0D;YACT,MAAM,EAAE;YACVC,MAAM;gBACJ,GAAG5D,OAAO4D,IAAI;gBACdjE,cAAc;oBACZ,GAAGL,UAAUK,cAAcK,OAAO4D,IAAI,EAAEjE,aAAa;gBACvD;YACF;QACF;IACF;AAEF,SAASG,GAAG,GAAE"}
@@ -1,7 +1,7 @@
1
- declare const _default: {
1
+ export declare const translations: {
2
2
  en: {
3
3
  $schema: string;
4
- "plugin-seo": {
4
+ 'plugin-seo': {
5
5
  almostThere: string;
6
6
  autoGenerate: string;
7
7
  bestPractices: string;
@@ -23,7 +23,7 @@ declare const _default: {
23
23
  };
24
24
  es: {
25
25
  $schema: string;
26
- "plugin-seo": {
26
+ 'plugin-seo': {
27
27
  almostThere: string;
28
28
  autoGenerate: string;
29
29
  bestPractices: string;
@@ -45,7 +45,7 @@ declare const _default: {
45
45
  };
46
46
  fa: {
47
47
  $schema: string;
48
- "plugin-seo": {
48
+ 'plugin-seo': {
49
49
  almostThere: string;
50
50
  autoGenerate: string;
51
51
  bestPractices: string;
@@ -67,7 +67,29 @@ declare const _default: {
67
67
  };
68
68
  fr: {
69
69
  $schema: string;
70
- "plugin-seo": {
70
+ 'plugin-seo': {
71
+ almostThere: string;
72
+ autoGenerate: string;
73
+ bestPractices: string;
74
+ characterCount: string;
75
+ charactersLeftOver: string;
76
+ charactersToGo: string;
77
+ charactersTooMany: string;
78
+ checksPassing: string;
79
+ good: string;
80
+ imageAutoGenerationTip: string;
81
+ lengthTipDescription: string;
82
+ lengthTipTitle: string;
83
+ noImage: string;
84
+ preview: string;
85
+ previewDescription: string;
86
+ tooLong: string;
87
+ tooShort: string;
88
+ };
89
+ };
90
+ nb: {
91
+ $schema: string;
92
+ 'plugin-seo': {
71
93
  almostThere: string;
72
94
  autoGenerate: string;
73
95
  bestPractices: string;
@@ -89,7 +111,7 @@ declare const _default: {
89
111
  };
90
112
  pl: {
91
113
  $schema: string;
92
- "plugin-seo": {
114
+ 'plugin-seo': {
93
115
  almostThere: string;
94
116
  autoGenerate: string;
95
117
  bestPractices: string;
@@ -110,5 +132,4 @@ declare const _default: {
110
132
  };
111
133
  };
112
134
  };
113
- export default _default;
114
135
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/translations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,wBAMC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/translations/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuJxB,CAAA"}