@payloadcms/plugin-seo 4.0.0-canary.7 → 4.0.0-canary.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fields/MetaTitle/MetaTitleComponent.d.ts +1 -1
- package/dist/fields/MetaTitle/MetaTitleComponent.d.ts.map +1 -1
- package/dist/fields/MetaTitle/MetaTitleComponent.js +1 -1
- package/dist/fields/MetaTitle/MetaTitleComponent.js.map +1 -1
- package/dist/fields/{index.scss → index.css} +2 -0
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaTitleComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAenD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,
|
|
1
|
+
{"version":3,"file":"MetaTitleComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAenD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,cAAc,CAAA;AAIrB,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,oBAAoB,CAAA;AAExB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAoLvD,CAAA"}
|
|
@@ -6,7 +6,7 @@ import { formatAdminURL } from 'payload/shared';
|
|
|
6
6
|
import React, { useCallback } from 'react';
|
|
7
7
|
import { defaults } from '../../defaults.js';
|
|
8
8
|
import { LengthIndicator } from '../../ui/LengthIndicator.js';
|
|
9
|
-
import '../index.
|
|
9
|
+
import '../index.css';
|
|
10
10
|
const { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.title;
|
|
11
11
|
export const MetaTitleComponent = (props)=>{
|
|
12
12
|
const { field: { label, localized, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required }, hasGenerateTitleFn, readOnly } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType } from '@payloadcms/ui'\nimport type { TextFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n TextInput,\n useConfig,\n useDocumentInfo,\n useDocumentTitle,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateTitle } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\nimport '../index.
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType } from '@payloadcms/ui'\nimport type { TextFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n TextInput,\n useConfig,\n useDocumentInfo,\n useDocumentTitle,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateTitle } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\nimport '../index.css'\n\nconst { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.title\n\ntype MetaTitleProps = {\n readonly hasGenerateTitleFn: boolean\n} & TextFieldClientProps\n\nexport const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {\n const {\n field: {\n label,\n localized,\n maxLength: maxLengthFromProps,\n minLength: minLengthFromProps,\n required,\n },\n hasGenerateTitleFn,\n readOnly,\n } = props\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const {\n config: {\n routes: { api },\n },\n } = useConfig()\n\n const {\n customComponents: { AfterInput, BeforeInput, Label } = {},\n errorMessage,\n path,\n setValue,\n showError,\n value,\n }: FieldType<string> = useField()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n const { title } = useDocumentTitle()\n\n const minLength = minLengthFromProps || minLengthDefault\n const maxLength = maxLengthFromProps || maxLengthDefault\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) {\n return\n }\n\n const endpoint = formatAdminURL({\n apiRoute: api,\n path: '/plugin-seo/generate-title',\n })\n\n const genTitleResponse = await fetch(endpoint, {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: reduceToSerializableFields(docInfo.initialState ?? {}),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title,\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 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 getData,\n locale,\n setValue,\n title,\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 {hasGenerateTitleFn && (\n <React.Fragment>\n — \n <button\n disabled={readOnly}\n onClick={() => {\n void regenerateTitle()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipTitle', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n .\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n Error={errorMessage}\n onChange={setValue}\n path={path}\n readOnly={readOnly}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextInput","useConfig","useDocumentInfo","useDocumentTitle","useField","useForm","useLocale","useTranslation","reduceToSerializableFields","formatAdminURL","React","useCallback","defaults","LengthIndicator","maxLength","maxLengthDefault","minLength","minLengthDefault","title","MetaTitleComponent","props","field","label","localized","maxLengthFromProps","minLengthFromProps","required","hasGenerateTitleFn","readOnly","t","config","routes","api","customComponents","AfterInput","BeforeInput","Label","errorMessage","path","setValue","showError","value","locale","getData","docInfo","regenerateTitle","endpoint","apiRoute","genTitleResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","credentials","headers","method","result","generatedTitle","json","div","style","marginBottom","position","className","Fragment","button","disabled","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,eAAe,EACfC,gBAAgB,EAChBC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,OAAO,eAAc;AAErB,MAAM,EAAEC,WAAWC,gBAAgB,EAAEC,WAAWC,gBAAgB,EAAE,GAAGL,SAASM,KAAK;AAMnF,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EACLC,KAAK,EACLC,SAAS,EACTT,WAAWU,kBAAkB,EAC7BR,WAAWS,kBAAkB,EAC7BC,QAAQ,EACT,EACDC,kBAAkB,EAClBC,QAAQ,EACT,GAAGR;IAEJ,MAAM,EAAES,CAAC,EAAE,GAAGtB;IAEd,MAAM,EACJuB,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EAChB,EACF,GAAG/B;IAEJ,MAAM,EACJgC,kBAAkB,EAAEC,UAAU,EAAEC,WAAW,EAAEC,KAAK,EAAE,GAAG,CAAC,CAAC,EACzDC,YAAY,EACZC,IAAI,EACJC,QAAQ,EACRC,SAAS,EACTC,KAAK,EACN,GAAsBrC;IAEvB,MAAMsC,SAASpC;IACf,MAAM,EAAEqC,OAAO,EAAE,GAAGtC;IACpB,MAAMuC,UAAU1C;IAChB,MAAM,EAAEgB,KAAK,EAAE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AMA;gCAAMZ,UAAUA;;4BAEvEC,oCACC,MAACjB,MAAMgE,QAAQ;;oCAAC;kDAEd,KAACC;wCACCC,UAAUhD;wCACViD,SAAS;4CACP,KAAKhC;wCACP;wCACAyB,OAAO;4CACLQ,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJxD,EAAE;;;;;;kCAKX,MAACwC;wBACCC,OAAO;4BACLW,OAAO;wBACT;;4BAECpD,EAAE,6BAA6B;gCAAEf;gCAAWE;4BAAU;0CACvD,KAACsE;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAEN5D,EAAE;;4BACD;;;;;0BAIR,KAACwC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACxE;oBACCkC,YAAYA;oBACZC,aAAaA;oBACbuD,OAAOrD;oBACPsD,UAAUpD;oBACVD,MAAMA;oBACNV,UAAUA;oBACVF,UAAUA;oBACVc,WAAWA;oBACX8B,OAAO;wBACLC,cAAc;oBAChB;oBACA9B,OAAOA;;;0BAGX,KAAC4B;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACjF;oBAAgBC,WAAWA;oBAAWE,WAAWA;oBAAW+E,MAAMtD;;;;;AAI3E,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-seo",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.8",
|
|
4
4
|
"description": "SEO plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -58,20 +58,20 @@
|
|
|
58
58
|
"dist"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@payloadcms/translations": "4.0.0-canary.
|
|
62
|
-
"@payloadcms/ui": "4.0.0-canary.
|
|
61
|
+
"@payloadcms/translations": "4.0.0-canary.8",
|
|
62
|
+
"@payloadcms/ui": "4.0.0-canary.8"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/react": "19.2.14",
|
|
66
66
|
"@types/react-dom": "19.2.3",
|
|
67
67
|
"@payloadcms/eslint-config": "3.28.0",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
68
|
+
"@payloadcms/next": "4.0.0-canary.8",
|
|
69
|
+
"payload": "4.0.0-canary.8"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
73
73
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
74
|
-
"payload": "4.0.0-canary.
|
|
74
|
+
"payload": "4.0.0-canary.8"
|
|
75
75
|
},
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"registry": "https://registry.npmjs.org/"
|