@payloadcms/plugin-seo 3.0.0-canary.51be7be → 3.0.0-canary.5624723
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fields/MetaDescription/MetaDescriptionComponent.d.ts.map +1 -1
- package/dist/fields/MetaDescription/MetaDescriptionComponent.js +14 -18
- package/dist/fields/MetaDescription/MetaDescriptionComponent.js.map +1 -1
- package/dist/fields/MetaImage/MetaImageComponent.d.ts.map +1 -1
- package/dist/fields/MetaImage/MetaImageComponent.js +17 -18
- package/dist/fields/MetaImage/MetaImageComponent.js.map +1 -1
- package/dist/fields/MetaTitle/MetaTitleComponent.d.ts.map +1 -1
- package/dist/fields/MetaTitle/MetaTitleComponent.js +13 -16
- package/dist/fields/MetaTitle/MetaTitleComponent.js.map +1 -1
- package/dist/fields/Preview/PreviewComponent.d.ts.map +1 -1
- package/dist/fields/Preview/PreviewComponent.js +2 -1
- package/dist/fields/Preview/PreviewComponent.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -20
- package/dist/index.js.map +1 -1
- package/dist/translations/cs.d.ts +3 -0
- package/dist/translations/cs.d.ts.map +1 -0
- package/dist/translations/cs.js +25 -0
- package/dist/translations/cs.js.map +1 -0
- package/dist/translations/index.d.ts +3 -0
- package/dist/translations/index.d.ts.map +1 -1
- package/dist/translations/index.js +6 -0
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/sv.d.ts +3 -0
- package/dist/translations/sv.d.ts.map +1 -0
- package/dist/translations/sv.js +25 -0
- package/dist/translations/sv.js.map +1 -0
- package/dist/translations/tr.d.ts +3 -0
- package/dist/translations/tr.d.ts.map +1 -0
- package/dist/translations/tr.js +25 -0
- package/dist/translations/tr.js.map +1 -0
- package/dist/types.d.ts +28 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/license.md +22 -0
- package/package.json +16 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaDescriptionComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAavD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAU1C,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,wBAAwB,EAAE,OAAO,CAAA;CAC3C,GAAG,wBAAwB,CAAA;AAE5B,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"MetaDescriptionComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAavD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAU1C,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,wBAAwB,EAAE,OAAO,CAAA;CAC3C,GAAG,wBAAwB,CAAA;AAE5B,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAgLnE,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { FieldLabel, TextareaInput, useConfig, useDocumentInfo, useField,
|
|
3
|
+
import { FieldLabel, TextareaInput, useConfig, useDocumentInfo, useField, useForm, useLocale, useTranslation } from '@payloadcms/ui';
|
|
4
|
+
import { reduceToSerializableFields } from '@payloadcms/ui/shared';
|
|
4
5
|
import React, { useCallback } from 'react';
|
|
5
6
|
import { defaults } from '../../defaults.js';
|
|
6
7
|
import { LengthIndicator } from '../../ui/LengthIndicator.js';
|
|
7
8
|
const { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.description;
|
|
8
9
|
export const MetaDescriptionComponent = (props)=>{
|
|
9
|
-
const { field: {
|
|
10
|
-
const { path: pathFromContext } = useFieldProps();
|
|
10
|
+
const { field: { label, localized, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required }, hasGenerateDescriptionFn, path } = props;
|
|
11
11
|
const { config: { routes: { api }, serverURL } } = useConfig();
|
|
12
12
|
const { t } = useTranslation();
|
|
13
13
|
const locale = useLocale();
|
|
@@ -15,10 +15,9 @@ export const MetaDescriptionComponent = (props)=>{
|
|
|
15
15
|
const docInfo = useDocumentInfo();
|
|
16
16
|
const maxLength = maxLengthFromProps || maxLengthDefault;
|
|
17
17
|
const minLength = minLengthFromProps || minLengthDefault;
|
|
18
|
-
const
|
|
19
|
-
path
|
|
18
|
+
const { customComponents: { AfterInput, BeforeInput, Label }, errorMessage, setValue, showError, value } = useField({
|
|
19
|
+
path
|
|
20
20
|
});
|
|
21
|
-
const { errorMessage, setValue, showError, value } = field;
|
|
22
21
|
const regenerateDescription = useCallback(async ()=>{
|
|
23
22
|
if (!hasGenerateDescriptionFn) {
|
|
24
23
|
return;
|
|
@@ -34,7 +33,7 @@ export const MetaDescriptionComponent = (props)=>{
|
|
|
34
33
|
hasPublishPermission: docInfo.hasPublishPermission,
|
|
35
34
|
hasSavePermission: docInfo.hasSavePermission,
|
|
36
35
|
initialData: docInfo.initialData,
|
|
37
|
-
initialState: docInfo.initialState,
|
|
36
|
+
initialState: reduceToSerializableFields(docInfo.initialState),
|
|
38
37
|
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
39
38
|
title: docInfo.title
|
|
40
39
|
}),
|
|
@@ -77,12 +76,11 @@ export const MetaDescriptionComponent = (props)=>{
|
|
|
77
76
|
/*#__PURE__*/ _jsxs("div", {
|
|
78
77
|
className: "plugin-seo__field",
|
|
79
78
|
children: [
|
|
80
|
-
/*#__PURE__*/ _jsx(FieldLabel, {
|
|
81
|
-
field: null,
|
|
82
|
-
Label: Label,
|
|
79
|
+
Label ?? /*#__PURE__*/ _jsx(FieldLabel, {
|
|
83
80
|
label: label,
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
localized: localized,
|
|
82
|
+
path: path,
|
|
83
|
+
required: required
|
|
86
84
|
}),
|
|
87
85
|
hasGenerateDescriptionFn && /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
88
86
|
children: [
|
|
@@ -132,13 +130,11 @@ export const MetaDescriptionComponent = (props)=>{
|
|
|
132
130
|
position: 'relative'
|
|
133
131
|
},
|
|
134
132
|
children: /*#__PURE__*/ _jsx(TextareaInput, {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
RenderedComponent: errorMessage
|
|
139
|
-
},
|
|
133
|
+
AfterInput: AfterInput,
|
|
134
|
+
BeforeInput: BeforeInput,
|
|
135
|
+
Error: errorMessage,
|
|
140
136
|
onChange: setValue,
|
|
141
|
-
path:
|
|
137
|
+
path: path,
|
|
142
138
|
required: required,
|
|
143
139
|
showError: showError,
|
|
144
140
|
style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextareaFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n TextareaInput,\n useConfig,\n useDocumentInfo,\n useField,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextareaFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n TextareaInput,\n useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateDescription } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\n\nconst { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.description\n\ntype MetaDescriptionProps = {\n readonly hasGenerateDescriptionFn: boolean\n} & TextareaFieldClientProps\n\nexport const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props) => {\n const {\n field: {\n label,\n localized,\n maxLength: maxLengthFromProps,\n minLength: minLengthFromProps,\n required,\n },\n hasGenerateDescriptionFn,\n path,\n } = props\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const maxLength = maxLengthFromProps || maxLengthDefault\n const minLength = minLengthFromProps || minLengthDefault\n\n const {\n customComponents: { AfterInput, BeforeInput, Label },\n errorMessage,\n setValue,\n showError,\n value,\n }: FieldType<string> = useField({\n path,\n } as Options)\n\n const regenerateDescription = useCallback(async () => {\n if (!hasGenerateDescriptionFn) {\n return\n }\n\n const endpoint = `${serverURL}${api}/plugin-seo/generate-description`\n\n const genDescriptionResponse = await fetch(endpoint, {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: reduceToSerializableFields(docInfo.initialState),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateDescription>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedDescription } = await genDescriptionResponse.json()\n\n setValue(generatedDescription || '')\n }, [\n hasGenerateDescriptionFn,\n serverURL,\n api,\n docInfo.id,\n docInfo.collectionSlug,\n docInfo.docPermissions,\n docInfo.globalSlug,\n docInfo.hasPublishPermission,\n docInfo.hasSavePermission,\n docInfo.initialData,\n docInfo.initialState,\n docInfo.title,\n getData,\n locale,\n setValue,\n ])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n {Label ?? (\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n )}\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n — \n <button\n onClick={() => {\n void regenerateDescription()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipDescription', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextareaInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n Error={errorMessage}\n onChange={setValue}\n path={path}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextareaInput","useConfig","useDocumentInfo","useField","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useCallback","defaults","LengthIndicator","maxLength","maxLengthDefault","minLength","minLengthDefault","description","MetaDescriptionComponent","props","field","label","localized","maxLengthFromProps","minLengthFromProps","required","hasGenerateDescriptionFn","path","config","routes","api","serverURL","t","locale","getData","docInfo","customComponents","AfterInput","BeforeInput","Label","errorMessage","setValue","showError","value","regenerateDescription","endpoint","genDescriptionResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","result","generatedDescription","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAE7D,MAAM,EAAEC,WAAWC,gBAAgB,EAAEC,WAAWC,gBAAgB,EAAE,GAAGL,SAASM,WAAW;AAMzF,OAAO,MAAMC,2BAA2D,CAACC;IACvE,MAAM,EACJC,OAAO,EACLC,KAAK,EACLC,SAAS,EACTT,WAAWU,kBAAkB,EAC7BR,WAAWS,kBAAkB,EAC7BC,QAAQ,EACT,EACDC,wBAAwB,EACxBC,IAAI,EACL,GAAGR;IAEJ,MAAM,EACJS,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAG7B;IAEJ,MAAM,EAAE8B,CAAC,EAAE,GAAGzB;IAEd,MAAM0B,SAAS3B;IACf,MAAM,EAAE4B,OAAO,EAAE,GAAG7B;IACpB,MAAM8B,UAAUhC;IAEhB,MAAMU,YAAYU,sBAAsBT;IACxC,MAAMC,YAAYS,sBAAsBR;IAExC,MAAM,EACJoB,kBAAkB,EAAEC,UAAU,EAAEC,WAAW,EAAEC,KAAK,EAAE,EACpDC,YAAY,EAC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WAAU;;4BACZjC,uBACC,KAACvC;gCAAWqB,OAAOA;gCAAOC,WAAWA;gCAAWK,MAAMA;gCAAMF,UAAUA;;4BAEvEC,0CACC,MAACjB,MAAMgE,QAAQ;;oCAAC;kDAEd,KAACC;wCACCC,SAAS;4CACP,KAAK/B;wCACP;wCACAyB,OAAO;4CACLO,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJnD,EAAE;;;;;;kCAKX,MAACoC;wBACCC,OAAO;4BACLU,OAAO;wBACT;;4BAEC/C,EAAE,mCAAmC;gCAAEnB;gCAAWE;4BAAU;0CAC7D,KAACqE;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAENvD,EAAE;;;;;;0BAIT,KAACoC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACtE;oBACCoC,YAAYA;oBACZC,aAAaA;oBACbkD,OAAOhD;oBACPiD,UAAUhD;oBACVd,MAAMA;oBACNF,UAAUA;oBACViB,WAAWA;oBACX2B,OAAO;wBACLC,cAAc;oBAChB;oBACA3B,OAAOA;;;0BAGX,KAACyB;gBACCC,OAAO;oBACLqB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAAChF;oBAAgBC,WAAWA;oBAAWE,WAAWA;oBAAW8E,MAAMlD;;;;;AAI3E,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaImageComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"MetaImageComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAcrD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,sBAAsB,CAAA;AAE1B,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAyLvD,CAAA"}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { FieldLabel, UploadInput, useConfig, useDocumentInfo, useField,
|
|
3
|
+
import { FieldLabel, RenderCustomComponent, UploadInput, useConfig, useDocumentInfo, useField, useForm, useLocale, useTranslation } from '@payloadcms/ui';
|
|
4
|
+
import { reduceToSerializableFields } from '@payloadcms/ui/shared';
|
|
4
5
|
import React, { useCallback } from 'react';
|
|
5
6
|
import { Pill } from '../../ui/Pill.js';
|
|
6
7
|
export const MetaImageComponent = (props)=>{
|
|
7
|
-
const { field: {
|
|
8
|
-
const { path: pathFromContext } = useFieldProps();
|
|
8
|
+
const { field: { label, localized, relationTo, required }, hasGenerateImageFn, path } = props || {};
|
|
9
9
|
const { config: { collections, routes: { api }, serverURL } } = useConfig();
|
|
10
10
|
const field = useField({
|
|
11
11
|
...props,
|
|
12
|
-
path
|
|
12
|
+
path
|
|
13
13
|
});
|
|
14
|
+
const { customComponents: { Error, Label } } = field;
|
|
14
15
|
const { t } = useTranslation();
|
|
15
16
|
const locale = useLocale();
|
|
16
17
|
const { getData } = useForm();
|
|
17
18
|
const docInfo = useDocumentInfo();
|
|
18
|
-
const {
|
|
19
|
+
const { setValue, showError, value } = field;
|
|
19
20
|
const regenerateImage = useCallback(async ()=>{
|
|
20
21
|
if (!hasGenerateImageFn) {
|
|
21
22
|
return;
|
|
@@ -31,7 +32,7 @@ export const MetaImageComponent = (props)=>{
|
|
|
31
32
|
hasPublishPermission: docInfo.hasPublishPermission,
|
|
32
33
|
hasSavePermission: docInfo.hasSavePermission,
|
|
33
34
|
initialData: docInfo.initialData,
|
|
34
|
-
initialState: docInfo.initialState,
|
|
35
|
+
initialState: reduceToSerializableFields(docInfo.initialState),
|
|
35
36
|
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
36
37
|
title: docInfo.title
|
|
37
38
|
}),
|
|
@@ -76,12 +77,14 @@ export const MetaImageComponent = (props)=>{
|
|
|
76
77
|
/*#__PURE__*/ _jsxs("div", {
|
|
77
78
|
className: "plugin-seo__field",
|
|
78
79
|
children: [
|
|
79
|
-
/*#__PURE__*/ _jsx(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
/*#__PURE__*/ _jsx(RenderCustomComponent, {
|
|
81
|
+
CustomComponent: Label,
|
|
82
|
+
Fallback: /*#__PURE__*/ _jsx(FieldLabel, {
|
|
83
|
+
label: label,
|
|
84
|
+
localized: localized,
|
|
85
|
+
path: path,
|
|
86
|
+
required: required
|
|
87
|
+
})
|
|
85
88
|
}),
|
|
86
89
|
hasGenerateImageFn && /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
87
90
|
children: [
|
|
@@ -122,11 +125,7 @@ export const MetaImageComponent = (props)=>{
|
|
|
122
125
|
children: /*#__PURE__*/ _jsx(UploadInput, {
|
|
123
126
|
api: api,
|
|
124
127
|
collection: collection,
|
|
125
|
-
Error:
|
|
126
|
-
type: 'client',
|
|
127
|
-
Component: null,
|
|
128
|
-
RenderedComponent: errorMessage
|
|
129
|
-
},
|
|
128
|
+
Error: Error,
|
|
130
129
|
filterOptions: field.filterOptions,
|
|
131
130
|
onChange: (incomingImage)=>{
|
|
132
131
|
if (incomingImage !== null) {
|
|
@@ -140,7 +139,7 @@ export const MetaImageComponent = (props)=>{
|
|
|
140
139
|
setValue(null);
|
|
141
140
|
}
|
|
142
141
|
},
|
|
143
|
-
path:
|
|
142
|
+
path: path,
|
|
144
143
|
relationTo: relationTo,
|
|
145
144
|
required: required,
|
|
146
145
|
serverURL: serverURL,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { UploadFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n UploadInput,\n useConfig,\n useDocumentInfo,\n useField,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { UploadFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n RenderCustomComponent,\n UploadInput,\n useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateImage } from '../../types.js'\n\nimport { Pill } from '../../ui/Pill.js'\n\ntype MetaImageProps = {\n readonly hasGenerateImageFn: boolean\n} & UploadFieldClientProps\n\nexport const MetaImageComponent: React.FC<MetaImageProps> = (props) => {\n const {\n field: { label, localized, relationTo, required },\n hasGenerateImageFn,\n path,\n } = 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 const {\n customComponents: { Error, Label },\n } = field\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const { setValue, showError, value } = field\n\n const regenerateImage = useCallback(async () => {\n if (!hasGenerateImageFn) {\n return\n }\n\n const endpoint = `${serverURL}${api}/plugin-seo/generate-image`\n\n const genImageResponse = await fetch(endpoint, {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: reduceToSerializableFields(docInfo.initialState),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateImage>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const generatedImage = await genImageResponse.text()\n\n setValue(generatedImage || '')\n }, [\n hasGenerateImageFn,\n serverURL,\n api,\n docInfo.id,\n docInfo.collectionSlug,\n docInfo.docPermissions,\n docInfo.globalSlug,\n docInfo.hasPublishPermission,\n docInfo.hasSavePermission,\n docInfo.initialData,\n docInfo.initialState,\n docInfo.title,\n getData,\n locale,\n setValue,\n ])\n\n const hasImage = Boolean(value)\n\n const collection = 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 — \n <button\n onClick={() => {\n void regenerateImage()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n {hasGenerateImageFn && (\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:imageAutoGenerationTip')}\n </div>\n )}\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <UploadInput\n api={api}\n collection={collection}\n Error={Error}\n filterOptions={field.filterOptions}\n onChange={(incomingImage) => {\n if (incomingImage !== null) {\n if (typeof incomingImage === 'object') {\n const { id: incomingID } = incomingImage\n setValue(incomingID)\n } else {\n setValue(incomingImage)\n }\n } else {\n setValue(null)\n }\n }}\n path={path}\n 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","config","collections","routes","api","serverURL","customComponents","Error","Label","t","locale","getData","docInfo","setValue","showError","value","regenerateImage","endpoint","genImageResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","generatedImage","text","hasImage","Boolean","collection","find","coll","slug","undefined","div","style","marginBottom","position","className","CustomComponent","Fallback","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","filterOptions","onChange","incomingImage","incomingID","alignItems","display","width"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,qBAAqB,EACrBC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,IAAI,QAAQ,mBAAkB;AAMvC,OAAO,MAAMC,qBAA+C,CAACC;I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AAOA,kBAAkB,UAAU;gCACrC,MAAM,EAAE3C,IAAI4C,UAAU,EAAE,GAAGD;gCAC3BrD,SAASsD;4BACX,OAAO;gCACLtD,SAASqD;4BACX;wBACF,OAAO;4BACLrD,SAAS;wBACX;oBACF;oBACAb,MAAMA;oBACNH,YAAYA;oBACZC,UAAUA;oBACVO,WAAWA;oBACXS,WAAWA;oBACXiC,OAAO;wBACLC,cAAc;oBAChB;oBACAjC,OAAOA;;;0BAGX,KAAC+B;gBACCC,OAAO;oBACLqB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAAC/E;oBACCkE,iBAAiBlB,WAAW,UAAU;oBACtCoB,OAAM;oBACNhE,OAAO4C,WAAW9B,EAAE,qBAAqBA,EAAE;;;;;AAKrD,EAAC"}
|
|
@@ -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;AAanD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,eAAe,CAAA;AAItB,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,oBAAoB,CAAA;AAExB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,
|
|
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;AAanD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,eAAe,CAAA;AAItB,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,oBAAoB,CAAA;AAExB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAoKvD,CAAA"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { FieldLabel, TextInput, useConfig, useDocumentInfo, useField,
|
|
3
|
+
import { FieldLabel, TextInput, useConfig, useDocumentInfo, useField, useForm, useLocale, useTranslation } from '@payloadcms/ui';
|
|
4
|
+
import { reduceToSerializableFields } from '@payloadcms/ui/shared';
|
|
4
5
|
import React, { useCallback } from 'react';
|
|
5
6
|
import { defaults } from '../../defaults.js';
|
|
6
7
|
import { LengthIndicator } from '../../ui/LengthIndicator.js';
|
|
7
8
|
import '../index.scss';
|
|
8
9
|
const { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.title;
|
|
9
10
|
export const MetaTitleComponent = (props)=>{
|
|
10
|
-
const { field: {
|
|
11
|
-
const { path: pathFromContext } = useFieldProps();
|
|
11
|
+
const { field: { label, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required }, hasGenerateTitleFn, path } = props || {};
|
|
12
12
|
const { t } = useTranslation();
|
|
13
13
|
const { config: { routes: { api }, serverURL } } = useConfig();
|
|
14
14
|
const field = useField({
|
|
15
|
-
path
|
|
15
|
+
path
|
|
16
16
|
});
|
|
17
|
+
const { customComponents: { AfterInput, BeforeInput, Label } = {} } = field;
|
|
17
18
|
const locale = useLocale();
|
|
18
19
|
const { getData } = useForm();
|
|
19
20
|
const docInfo = useDocumentInfo();
|
|
@@ -35,7 +36,7 @@ export const MetaTitleComponent = (props)=>{
|
|
|
35
36
|
hasPublishPermission: docInfo.hasPublishPermission,
|
|
36
37
|
hasSavePermission: docInfo.hasSavePermission,
|
|
37
38
|
initialData: docInfo.initialData,
|
|
38
|
-
initialState: docInfo.initialState,
|
|
39
|
+
initialState: reduceToSerializableFields(docInfo.initialState),
|
|
39
40
|
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
40
41
|
title: docInfo.title
|
|
41
42
|
}),
|
|
@@ -78,12 +79,10 @@ export const MetaTitleComponent = (props)=>{
|
|
|
78
79
|
/*#__PURE__*/ _jsxs("div", {
|
|
79
80
|
className: "plugin-seo__field",
|
|
80
81
|
children: [
|
|
81
|
-
/*#__PURE__*/ _jsx(FieldLabel, {
|
|
82
|
-
field: fieldFromProps,
|
|
83
|
-
Label: Label,
|
|
82
|
+
Label ?? /*#__PURE__*/ _jsx(FieldLabel, {
|
|
84
83
|
label: label,
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
path: path,
|
|
85
|
+
required: required
|
|
87
86
|
}),
|
|
88
87
|
hasGenerateTitleFn && /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
89
88
|
children: [
|
|
@@ -134,13 +133,11 @@ export const MetaTitleComponent = (props)=>{
|
|
|
134
133
|
position: 'relative'
|
|
135
134
|
},
|
|
136
135
|
children: /*#__PURE__*/ _jsx(TextInput, {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
RenderedComponent: errorMessage
|
|
141
|
-
},
|
|
136
|
+
AfterInput: AfterInput,
|
|
137
|
+
BeforeInput: BeforeInput,
|
|
138
|
+
Error: errorMessage,
|
|
142
139
|
onChange: setValue,
|
|
143
|
-
path:
|
|
140
|
+
path: path,
|
|
144
141
|
required: required,
|
|
145
142
|
showError: showError,
|
|
146
143
|
style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n TextInput,\n useConfig,\n useDocumentInfo,\n useField,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n TextInput,\n useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateTitle } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\nimport '../index.scss'\n\nconst { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.title\n\ntype MetaTitleProps = {\n readonly hasGenerateTitleFn: boolean\n} & TextFieldClientProps\n\nexport const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {\n const {\n field: { label, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required },\n hasGenerateTitleFn,\n path,\n } = props || {}\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const field: FieldType<string> = useField({ path } as Options)\n const { customComponents: { AfterInput, BeforeInput, Label } = {} } = field\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const minLength = minLengthFromProps || minLengthDefault\n const maxLength = maxLengthFromProps || maxLengthDefault\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) {\n return\n }\n\n const endpoint = `${serverURL}${api}/plugin-seo/generate-title`\n\n const genTitleResponse = await fetch(endpoint, {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: reduceToSerializableFields(docInfo.initialState),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedTitle } = await genTitleResponse.json()\n\n setValue(generatedTitle || '')\n }, [\n hasGenerateTitleFn,\n serverURL,\n api,\n docInfo.id,\n docInfo.collectionSlug,\n docInfo.docPermissions,\n docInfo.globalSlug,\n docInfo.hasPublishPermission,\n docInfo.hasSavePermission,\n docInfo.initialData,\n docInfo.initialState,\n docInfo.title,\n getData,\n locale,\n setValue,\n ])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n {Label ?? <FieldLabel label={label} path={path} required={required} />}\n {hasGenerateTitleFn && (\n <React.Fragment>\n — \n <button\n 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 required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextInput","useConfig","useDocumentInfo","useField","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useCallback","defaults","LengthIndicator","maxLength","maxLengthDefault","minLength","minLengthDefault","title","MetaTitleComponent","props","field","label","maxLengthFromProps","minLengthFromProps","required","hasGenerateTitleFn","path","t","config","routes","api","serverURL","customComponents","AfterInput","BeforeInput","Label","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateTitle","endpoint","genTitleResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","credentials","headers","method","result","generatedTitle","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,OAAO,gBAAe;AAEtB,MAAM,EAAEC,WAAWC,gBAAgB,EAAEC,WAAWC,gBAAgB,EAAE,GAAGL,SAASM,KAAK;AAMnF,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EAAEC,KAAK,EAAER,WAAWS,kBAAkB,EAAEP,WAAWQ,kBAAkB,EAAEC,QAAQ,EAAE,EACxFC,kBAAkB,EAClBC,IAAI,EACL,GAAGP,SAAS,CAAC;IAEd,MAAM,EAAEQ,CAAC,EAAE,GAAGpB;IAEd,MAAM,EACJqB,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EAC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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"PreviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AAWjD,OAAO,KAA8B,MAAM,OAAO,CAAA;AAKlD,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B,GAAG,OAAO,CAAA;AAEX,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAiInD,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useAllFormFields, useConfig, useDocumentInfo, useForm, useLocale, useTranslation } from '@payloadcms/ui';
|
|
4
|
+
import { reduceToSerializableFields } from '@payloadcms/ui/shared';
|
|
4
5
|
import React, { useEffect, useState } from 'react';
|
|
5
6
|
export const PreviewComponent = (props)=>{
|
|
6
7
|
const { descriptionPath: descriptionPathFromContext, hasGenerateURLFn, titlePath: titlePathFromContext } = props;
|
|
@@ -27,7 +28,7 @@ export const PreviewComponent = (props)=>{
|
|
|
27
28
|
hasPublishPermission: docInfo.hasPublishPermission,
|
|
28
29
|
hasSavePermission: docInfo.hasSavePermission,
|
|
29
30
|
initialData: docInfo.initialData,
|
|
30
|
-
initialState: docInfo.initialState,
|
|
31
|
+
initialState: reduceToSerializableFields(docInfo.initialState),
|
|
31
32
|
locale: typeof locale === 'object' ? locale?.code : locale,
|
|
32
33
|
title: docInfo.title
|
|
33
34
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FormField, UIField } from 'payload'\n\nimport {\n useAllFormFields,\n useConfig,\n useDocumentInfo,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateURL } from '../../types.js'\n\ntype PreviewProps = {\n readonly descriptionPath?: string\n readonly hasGenerateURLFn: boolean\n readonly titlePath?: string\n} & UIField\n\nexport const PreviewComponent: React.FC<PreviewProps> = (props) => {\n const {\n descriptionPath: descriptionPathFromContext,\n hasGenerateURLFn,\n titlePath: titlePathFromContext,\n } = props\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const descriptionPath = descriptionPathFromContext || 'meta.description'\n const titlePath = titlePathFromContext || 'meta.title'\n\n const {\n [descriptionPath]: { value: metaDescription } = {} as FormField,\n [titlePath]: { value: metaTitle } = {} as FormField,\n } = fields\n\n const [href, setHref] = useState<string>()\n\n useEffect(() => {\n const endpoint = `${serverURL}${api}/plugin-seo/generate-url`\n\n const getHref = async () => {\n const genURLResponse = await fetch(endpoint, {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Preview/PreviewComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FormField, UIField } from 'payload'\n\nimport {\n useAllFormFields,\n useConfig,\n useDocumentInfo,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\nimport React, { useEffect, useState } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateURL } from '../../types.js'\n\ntype PreviewProps = {\n readonly descriptionPath?: string\n readonly hasGenerateURLFn: boolean\n readonly titlePath?: string\n} & UIField\n\nexport const PreviewComponent: React.FC<PreviewProps> = (props) => {\n const {\n descriptionPath: descriptionPathFromContext,\n hasGenerateURLFn,\n titlePath: titlePathFromContext,\n } = props\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const descriptionPath = descriptionPathFromContext || 'meta.description'\n const titlePath = titlePathFromContext || 'meta.title'\n\n const {\n [descriptionPath]: { value: metaDescription } = {} as FormField,\n [titlePath]: { value: metaTitle } = {} as FormField,\n } = fields\n\n const [href, setHref] = useState<string>()\n\n useEffect(() => {\n const endpoint = `${serverURL}${api}/plugin-seo/generate-url`\n\n const getHref = async () => {\n const genURLResponse = await fetch(endpoint, {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: reduceToSerializableFields(docInfo.initialState),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateURL>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: newHref } = await genURLResponse.json()\n\n setHref(newHref)\n }\n\n if (hasGenerateURLFn && !href) {\n void getHref()\n }\n }, [fields, href, locale, docInfo, hasGenerateURLFn, getData, serverURL, api])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div>{t('plugin-seo:preview')}</div>\n <div\n style={{\n color: '#9A9A9A',\n marginBottom: '5px',\n }}\n >\n {t('plugin-seo:previewDescription')}\n </div>\n <div\n style={{\n background: 'var(--theme-elevation-50)',\n borderRadius: '5px',\n boxShadow: '0px 0px 10px rgba(0, 0, 0, 0.1)',\n maxWidth: '600px',\n padding: '20px',\n pointerEvents: 'none',\n width: '100%',\n }}\n >\n <div>\n <a\n href={href}\n style={{\n textDecoration: 'none',\n }}\n >\n {href || 'https://...'}\n </a>\n </div>\n <h4\n style={{\n margin: 0,\n }}\n >\n <a\n href=\"/\"\n style={{\n textDecoration: 'none',\n }}\n >\n {metaTitle as string}\n </a>\n </h4>\n <p\n style={{\n margin: 0,\n }}\n >\n {metaDescription as string}\n </p>\n </div>\n </div>\n )\n}\n"],"names":["useAllFormFields","useConfig","useDocumentInfo","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useEffect","useState","PreviewComponent","props","descriptionPath","descriptionPathFromContext","hasGenerateURLFn","titlePath","titlePathFromContext","t","config","routes","api","serverURL","locale","fields","getData","docInfo","value","metaDescription","metaTitle","href","setHref","endpoint","getHref","genURLResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","result","newHref","json","div","style","marginBottom","color","background","borderRadius","boxShadow","maxWidth","padding","pointerEvents","width","a","textDecoration","h4","margin","p"],"mappings":"AAAA;;AAIA,SACEA,gBAAgB,EAChBC,SA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xC,2BAA2BmB,QAAQqB,YAAY;oBAC7DxB,QAAQ,OAAOA,WAAW,WAAWA,QAAQyB,OAAOzB;oBACpD0B,OAAOvB,QAAQuB,KAAK;gBACtB;gBAIAC,aAAa;gBACbC,SAAS;oBACP,gBAAgB;gBAClB;gBACAC,QAAQ;YACV;YAEA,MAAM,EAAEC,QAAQC,OAAO,EAAE,GAAG,MAAMpB,eAAeqB,IAAI;YAErDxB,QAAQuB;QACV;QAEA,IAAIvC,oBAAoB,CAACe,MAAM;YAC7B,KAAKG;QACP;IACF,GAAG;QAACT;QAAQM;QAAMP;QAAQG;QAASX;QAAkBU;QAASH;QAAWD;KAAI;IAE7E,qBACE,MAACmC;QACCC,OAAO;YACLC,cAAc;QAChB;;0BAEA,KAACF;0BAAKtC,EAAE;;0BACR,KAACsC;gBACCC,OAAO;oBACLE,OAAO;oBACPD,cAAc;gBAChB;0BAECxC,EAAE;;0BAEL,MAACsC;gBACCC,OAAO;oBACLG,YAAY;oBACZC,cAAc;oBACdC,WAAW;oBACXC,UAAU;oBACVC,SAAS;oBACTC,eAAe;oBACfC,OAAO;gBACT;;kCAEA,KAACV;kCACC,cAAA,KAACW;4BACCrC,MAAMA;4BACN2B,OAAO;gCACLW,gBAAgB;4BAClB;sCAECtC,QAAQ;;;kCAGb,KAACuC;wBACCZ,OAAO;4BACLa,QAAQ;wBACV;kCAEA,cAAA,KAACH;4BACCrC,MAAK;4BACL2B,OAAO;gCACLW,gBAAgB;4BAClB;sCAECvC;;;kCAGL,KAAC0C;wBACCd,OAAO;4BACLa,QAAQ;wBACV;kCAEC1C;;;;;;AAKX,EAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAgC,MAAM,SAAS,CAAA;AAInE,OAAO,KAAK,EAKV,eAAe,EAChB,MAAM,YAAY,CAAA;AASnB,eAAO,MAAM,SAAS,iBACL,eAAe,cACrB,MAAM,KAAG,MAqRjB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -6,31 +6,32 @@ import { OverviewField } from './fields/Overview/index.js';
|
|
|
6
6
|
import { PreviewField } from './fields/Preview/index.js';
|
|
7
7
|
import { translations } from './translations/index.js';
|
|
8
8
|
export const seoPlugin = (pluginConfig)=>(config)=>{
|
|
9
|
+
const defaultFields = [
|
|
10
|
+
OverviewField({}),
|
|
11
|
+
MetaTitleField({
|
|
12
|
+
hasGenerateFn: typeof pluginConfig?.generateTitle === 'function'
|
|
13
|
+
}),
|
|
14
|
+
MetaDescriptionField({
|
|
15
|
+
hasGenerateFn: typeof pluginConfig?.generateDescription === 'function'
|
|
16
|
+
}),
|
|
17
|
+
...pluginConfig?.uploadsCollection ? [
|
|
18
|
+
MetaImageField({
|
|
19
|
+
hasGenerateFn: typeof pluginConfig?.generateImage === 'function',
|
|
20
|
+
relationTo: pluginConfig.uploadsCollection
|
|
21
|
+
})
|
|
22
|
+
] : [],
|
|
23
|
+
PreviewField({
|
|
24
|
+
hasGenerateFn: typeof pluginConfig?.generateURL === 'function'
|
|
25
|
+
})
|
|
26
|
+
];
|
|
9
27
|
const seoFields = [
|
|
10
28
|
{
|
|
11
29
|
name: 'meta',
|
|
12
30
|
type: 'group',
|
|
13
31
|
fields: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
overrides: pluginConfig?.fieldOverrides?.title
|
|
18
|
-
}),
|
|
19
|
-
MetaDescriptionField({
|
|
20
|
-
hasGenerateFn: typeof pluginConfig?.generateDescription === 'function',
|
|
21
|
-
overrides: pluginConfig?.fieldOverrides?.description
|
|
22
|
-
}),
|
|
23
|
-
...pluginConfig?.uploadsCollection ? [
|
|
24
|
-
MetaImageField({
|
|
25
|
-
hasGenerateFn: typeof pluginConfig?.generateImage === 'function',
|
|
26
|
-
overrides: pluginConfig?.fieldOverrides?.image,
|
|
27
|
-
relationTo: pluginConfig.uploadsCollection
|
|
28
|
-
})
|
|
29
|
-
] : [],
|
|
30
|
-
...pluginConfig?.fields || [],
|
|
31
|
-
PreviewField({
|
|
32
|
-
hasGenerateFn: typeof pluginConfig?.generateURL === 'function'
|
|
33
|
-
})
|
|
32
|
+
...pluginConfig?.fields && typeof pluginConfig.fields === 'function' ? pluginConfig.fields({
|
|
33
|
+
defaultFields
|
|
34
|
+
}) : defaultFields
|
|
34
35
|
],
|
|
35
36
|
interfaceName: pluginConfig.interfaceName,
|
|
36
37
|
label: 'SEO'
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import type { Config, GroupField, TabsField, TextField } from 'payload'\n\nimport { deepMergeSimple } from 'payload/shared'\n\nimport type {\n GenerateDescription,\n GenerateImage,\n GenerateTitle,\n GenerateURL,\n SEOPluginConfig,\n} from './types.js'\n\nimport { MetaDescriptionField } from './fields/MetaDescription/index.js'\nimport { MetaImageField } from './fields/MetaImage/index.js'\nimport { MetaTitleField } from './fields/MetaTitle/index.js'\nimport { OverviewField } from './fields/Overview/index.js'\nimport { PreviewField } from './fields/Preview/index.js'\nimport { translations } from './translations/index.js'\n\nexport const seoPlugin =\n (pluginConfig: SEOPluginConfig) =>\n (config: Config): Config => {\n const seoFields: GroupField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n OverviewField({}),\n MetaTitleField({\n hasGenerateFn: typeof pluginConfig?.generateTitle === 'function',\n overrides: pluginConfig?.fieldOverrides?.title,\n }),\n MetaDescriptionField({\n hasGenerateFn: typeof pluginConfig?.generateDescription === 'function',\n overrides: pluginConfig?.fieldOverrides?.description,\n }),\n ...(pluginConfig?.uploadsCollection\n ? [\n MetaImageField({\n hasGenerateFn: typeof pluginConfig?.generateImage === 'function',\n overrides: pluginConfig?.fieldOverrides?.image,\n relationTo: pluginConfig.uploadsCollection,\n }),\n ]\n : []),\n ...(pluginConfig?.fields || []),\n PreviewField({\n hasGenerateFn: typeof pluginConfig?.generateURL === 'function',\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 ...(config.endpoints ?? []),\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateTitle\n ? await pluginConfig.generateTitle({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } satisfies Parameters<GenerateTitle>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-title',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateDescription\n ? await pluginConfig.generateDescription({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } satisfies Parameters<GenerateDescription>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-description',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateURL\n ? await pluginConfig.generateURL({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } satisfies Parameters<GenerateURL>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-url',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateImage\n ? await pluginConfig.generateImage({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } as Parameters<GenerateImage>[0])\n : ''\n return new Response(result, { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-image',\n },\n ],\n globals:\n config.globals?.map((global) => {\n const { slug } = global\n const isEnabled = pluginConfig?.globals?.includes(slug)\n\n if (isEnabled) {\n if (pluginConfig?.tabbedUI) {\n const seoTabs: TabsField[] = [\n {\n type: 'tabs',\n tabs: [\n // append a new tab onto the end of the tabs array, if there is one at the first index\n // if needed, create a new `Content` tab in the first index for this global's base fields\n ...(global?.fields?.[0].type === 'tabs' && global?.fields?.[0].tabs\n ? global.fields[0].tabs\n : [\n {\n fields: [...(global?.fields || [])],\n label: global?.label || 'Content',\n },\n ]),\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n\n return {\n ...global,\n fields: [\n ...seoTabs,\n ...(global?.fields?.[0].type === 'tabs' ? global.fields.slice(1) : []),\n ],\n }\n }\n\n return {\n ...global,\n fields: [...(global?.fields || []), ...seoFields],\n }\n }\n\n return global\n }) || [],\n i18n: {\n ...config.i18n,\n translations: deepMergeSimple(translations, config.i18n?.translations),\n },\n }\n }\n"],"names":["deepMergeSimple","MetaDescriptionField","MetaImageField","MetaTitleField","OverviewField","PreviewField","translations","seoPlugin","pluginConfig","config","seoFields","name","type","fields","hasGenerateFn","generateTitle","overrides","fieldOverrides","title","generateDescription","description","uploadsCollection","generateImage","image","relationTo","generateURL","interfaceName","label","collections","map","collection","slug","isEnabled","includes","tabbedUI","emailField","auth","disableLocalStrategy","find","field","hasOnlyEmailField","length","seoTabs","tabs","filter","labels","singular","slice","endpoints","handler","req","data","json","result","collectionConfig","collectionSlug","c","globalConfig","globalSlug","globals","g","Response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ASR,QAAQ;4BAAEW,QAAQ;wBAAI;oBAC5C;oBACAC,QAAQ;oBACRC,MAAM;gBACR;aACD;YACDP,SACElD,OAAOkD,OAAO,EAAE9B,IAAI,CAACsC;gBACnB,MAAM,EAAEpC,IAAI,EAAE,GAAGoC;gBACjB,MAAMnC,YAAYxB,cAAcmD,SAAS1B,SAASF;gBAElD,IAAIC,WAAW;oBACb,IAAIxB,cAAc0B,UAAU;wBAC1B,MAAMQ,UAAuB;4BAC3B;gCACE9B,MAAM;gCACN+B,MAAM;oCACJ,sFAAsF;oCACtF,yFAAyF;uCACrFwB,QAAQtD,QAAQ,CAAC,EAAE,CAACD,SAAS,UAAUuD,QAAQtD,QAAQ,CAAC,EAAE,CAAC8B,OAC3DwB,OAAOtD,MAAM,CAAC,EAAE,CAAC8B,IAAI,GACrB;wCACE;4CACE9B,QAAQ;mDAAKsD,QAAQtD,UAAU,EAAE;6CAAE;4CACnCc,OAAOwC,QAAQxC,SAAS;wCAC1B;qCACD;oCACL;wCACEd,QAAQH;wCACRiB,OAAO;oCACT;iCACD;4BACH;yBACD;wBAED,OAAO;4BACL,GAAGwC,MAAM;4BACTtD,QAAQ;mCACH6B;mCACCyB,QAAQtD,QAAQ,CAAC,EAAE,CAACD,SAAS,SAASuD,OAAOtD,MAAM,CAACkC,KAAK,CAAC,KAAK,EAAE;6BACtE;wBACH;oBACF;oBAEA,OAAO;wBACL,GAAGoB,MAAM;wBACTtD,QAAQ;+BAAKsD,QAAQtD,UAAU,EAAE;+BAAMH;yBAAU;oBACnD;gBACF;gBAEA,OAAOyD;YACT,MAAM,EAAE;YACVC,MAAM;gBACJ,GAAG3D,OAAO2D,IAAI;gBACd9D,cAAcN,gBAAgBM,cAAcG,OAAO2D,IAAI,EAAE9D;YAC3D;QACF;IACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import type { Config, Field, GroupField, TabsField } from 'payload'\n\nimport { deepMergeSimple } from 'payload/shared'\n\nimport type {\n GenerateDescription,\n GenerateImage,\n GenerateTitle,\n GenerateURL,\n SEOPluginConfig,\n} from './types.js'\n\nimport { MetaDescriptionField } from './fields/MetaDescription/index.js'\nimport { MetaImageField } from './fields/MetaImage/index.js'\nimport { MetaTitleField } from './fields/MetaTitle/index.js'\nimport { OverviewField } from './fields/Overview/index.js'\nimport { PreviewField } from './fields/Preview/index.js'\nimport { translations } from './translations/index.js'\n\nexport const seoPlugin =\n (pluginConfig: SEOPluginConfig) =>\n (config: Config): Config => {\n const defaultFields: Field[] = [\n OverviewField({}),\n MetaTitleField({\n hasGenerateFn: typeof pluginConfig?.generateTitle === 'function',\n }),\n MetaDescriptionField({\n hasGenerateFn: typeof pluginConfig?.generateDescription === 'function',\n }),\n ...(pluginConfig?.uploadsCollection\n ? [\n MetaImageField({\n hasGenerateFn: typeof pluginConfig?.generateImage === 'function',\n relationTo: pluginConfig.uploadsCollection,\n }),\n ]\n : []),\n PreviewField({\n hasGenerateFn: typeof pluginConfig?.generateURL === 'function',\n }),\n ]\n\n const seoFields: GroupField[] = [\n {\n name: 'meta',\n type: 'group',\n fields: [\n ...(pluginConfig?.fields && typeof pluginConfig.fields === 'function'\n ? pluginConfig.fields({ defaultFields })\n : defaultFields),\n ],\n interfaceName: pluginConfig.interfaceName,\n label: 'SEO',\n },\n ]\n\n return {\n ...config,\n collections:\n config.collections?.map((collection) => {\n const { slug } = collection\n const isEnabled = pluginConfig?.collections?.includes(slug)\n\n if (isEnabled) {\n if (pluginConfig?.tabbedUI) {\n // prevent issues with auth enabled collections having an email field that shouldn't be moved to the SEO tab\n const emailField =\n (collection.auth ||\n !(typeof collection.auth === 'object' && collection.auth.disableLocalStrategy)) &&\n collection.fields?.find((field) => 'name' in field && field.name === 'email')\n const hasOnlyEmailField = collection.fields?.length === 1 && emailField\n\n const seoTabs: TabsField[] = hasOnlyEmailField\n ? [\n {\n type: 'tabs',\n tabs: [\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n : [\n {\n type: 'tabs',\n tabs: [\n // append a new tab onto the end of the tabs array, if there is one at the first index\n // if needed, create a new `Content` tab in the first index for this collection's base fields\n ...(collection?.fields?.[0]?.type === 'tabs' &&\n collection?.fields?.[0]?.tabs\n ? collection.fields[0].tabs\n : [\n {\n fields: [\n ...(emailField\n ? collection.fields.filter(\n (field) => 'name' in field && field.name !== 'email',\n )\n : collection.fields),\n ],\n label: collection?.labels?.singular || 'Content',\n },\n ]),\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n\n return {\n ...collection,\n fields: [\n ...(emailField ? [emailField] : []),\n ...seoTabs,\n ...(collection?.fields?.[0]?.type === 'tabs' ? collection.fields.slice(1) : []),\n ],\n }\n }\n\n return {\n ...collection,\n fields: [...(collection?.fields || []), ...seoFields],\n }\n }\n\n return collection\n }) || [],\n endpoints: [\n ...(config.endpoints ?? []),\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateTitle\n ? await pluginConfig.generateTitle({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } satisfies Parameters<GenerateTitle>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-title',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateDescription\n ? await pluginConfig.generateDescription({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } satisfies Parameters<GenerateDescription>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-description',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateURL\n ? await pluginConfig.generateURL({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } satisfies Parameters<GenerateURL>[0])\n : ''\n return new Response(JSON.stringify({ result }), { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-url',\n },\n {\n handler: async (req) => {\n const data: Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'req'\n > = await req.json()\n\n if (data) {\n req.data = data\n }\n\n const result = pluginConfig.generateImage\n ? await pluginConfig.generateImage({\n ...data,\n collectionConfig: req.data.collectionSlug\n ? config.collections?.find((c) => c.slug === req.data.collectionSlug)\n : null,\n globalConfig: req.data.globalSlug\n ? config.globals?.find((g) => g.slug === req.data.globalSlug)\n : null,\n req,\n } as Parameters<GenerateImage>[0])\n : ''\n return new Response(result, { status: 200 })\n },\n method: 'post',\n path: '/plugin-seo/generate-image',\n },\n ],\n globals:\n config.globals?.map((global) => {\n const { slug } = global\n const isEnabled = pluginConfig?.globals?.includes(slug)\n\n if (isEnabled) {\n if (pluginConfig?.tabbedUI) {\n const seoTabs: TabsField[] = [\n {\n type: 'tabs',\n tabs: [\n // append a new tab onto the end of the tabs array, if there is one at the first index\n // if needed, create a new `Content` tab in the first index for this global's base fields\n ...(global?.fields?.[0].type === 'tabs' && global?.fields?.[0].tabs\n ? global.fields[0].tabs\n : [\n {\n fields: [...(global?.fields || [])],\n label: global?.label || 'Content',\n },\n ]),\n {\n fields: seoFields,\n label: 'SEO',\n },\n ],\n },\n ]\n\n return {\n ...global,\n fields: [\n ...seoTabs,\n ...(global?.fields?.[0].type === 'tabs' ? global.fields.slice(1) : []),\n ],\n }\n }\n\n return {\n ...global,\n fields: [...(global?.fields || []), ...seoFields],\n }\n }\n\n return global\n }) || [],\n i18n: {\n ...config.i18n,\n translations: deepMergeSimple(translations, config.i18n?.translations),\n },\n }\n }\n"],"names":["deepMergeSimple","MetaDescriptionField","MetaImageField","MetaTitleField","OverviewField","PreviewField","translations","seoPlugin","pluginConfig","config","defaultFields","hasGenerateFn","generateTitle","generateDescription","uploadsCollection","generateImage","relationTo","generateURL","seoFields","name","type","fields","interfaceName","label","collections","map","collection","slug","isEnabled","includes","tabbedUI","emailField","auth","disableLocalStrategy","find","field","hasOnlyEmailField","length","seoTabs","tabs","filter","labels","singular","slice","endpoints","handler","req","data","json","result","collectionConfig","collectionSlug","c","globalConfig","globalSlug","globals","g","Response","JSON","stringify","status","method","path","global","i18n"],"mappings":"AAEA,SAASA,eAAe,QAAQ,iBAAgB;AAUhD,SAASC,oBAAoB,QAAQ,oCAAmC;AACxE,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,SAASC,YAAY,QAAQ,4BAA2B;AACxD,SAASC,YAAY,QAAQ,0BAAyB;AAEtD,OAAO,MAAMC,YACX,CAACC,eACD,CAACC;QACC,MAAMC,gBAAyB;YAC7BN,cAAc,CAAC;YACfD,eAAe;gBACbQ,eAAe,OAAOH,cAAcI,kBAAkB;YACxD;YACAX,qBAAqB;gBACnBU,eAAe,OAAOH,cAAcK,wBAAwB;YAC9D;eACIL,cAAcM,oBACd;gBACEZ,eAAe;oBACbS,eAAe,OAAOH,cAAcO,kBAAkB;oBACtDC,YAAYR,aAAaM,iBAAiB;gBAC5C;aACD,GACD,EAAE;YACNT,aAAa;gBACXM,eAAe,OAAOH,cAA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,MAAM;4BACT1C,QAAQ;mCACHiB;mCACCyB,QAAQ1C,QAAQ,CAAC,EAAE,CAACD,SAAS,SAAS2C,OAAO1C,MAAM,CAACsB,KAAK,CAAC,KAAK,EAAE;6BACtE;wBACH;oBACF;oBAEA,OAAO;wBACL,GAAGoB,MAAM;wBACT1C,QAAQ;+BAAK0C,QAAQ1C,UAAU,EAAE;+BAAMH;yBAAU;oBACnD;gBACF;gBAEA,OAAO6C;YACT,MAAM,EAAE;YACVC,MAAM;gBACJ,GAAGvD,OAAOuD,IAAI;gBACd1D,cAAcN,gBAAgBM,cAAcG,OAAOuD,IAAI,EAAE1D;YAC3D;QACF;IACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cs.d.ts","sourceRoot":"","sources":["../../src/translations/cs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAEzE,eAAO,MAAM,EAAE,EAAE,yBAyBhB,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const cs = {
|
|
2
|
+
$schema: './translation-schema.json',
|
|
3
|
+
'plugin-seo': {
|
|
4
|
+
almostThere: 'Skoro hotovo',
|
|
5
|
+
autoGenerate: 'Generovat automaticky',
|
|
6
|
+
bestPractices: 'osvědčené postupy',
|
|
7
|
+
characterCount: '{{current}}/{{minLength}}-{{maxLength}} znaků, ',
|
|
8
|
+
charactersLeftOver: '{{characters}} zbývá',
|
|
9
|
+
charactersToGo: '{{characters}} zbývá',
|
|
10
|
+
charactersTooMany: '{{characters}} navíc',
|
|
11
|
+
checksPassing: '{{current}}/{{max}} kontrol úspěšně splněno',
|
|
12
|
+
good: 'Dobré',
|
|
13
|
+
imageAutoGenerationTip: 'Automatická generace načte vybraný hero obrázek.',
|
|
14
|
+
lengthTipDescription: 'Toto by mělo mít mezi {{minLength}} a {{maxLength}} znaky. Pomoc při psaní kvalitních meta popisů navštivte ',
|
|
15
|
+
lengthTipTitle: 'Toto by mělo mít mezi {{minLength}} a {{maxLength}} znaky. Pomoc při psaní kvalitních meta titulů navštivte ',
|
|
16
|
+
missing: 'Chybí',
|
|
17
|
+
noImage: 'Bez obrázku',
|
|
18
|
+
preview: 'Náhled',
|
|
19
|
+
previewDescription: 'Přesný výsledek se může lišit v závislosti na obsahu a relevanci vyhledávání.',
|
|
20
|
+
tooLong: 'Příliš dlouhé',
|
|
21
|
+
tooShort: 'Příliš krátké'
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=cs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/translations/cs.ts"],"sourcesContent":["import type { GenericTranslationsObject } from '@payloadcms/translations'\n\nexport const cs: GenericTranslationsObject = {\n $schema: './translation-schema.json',\n 'plugin-seo': {\n almostThere: 'Skoro hotovo',\n autoGenerate: 'Generovat automaticky',\n bestPractices: 'osvědčené postupy',\n characterCount: '{{current}}/{{minLength}}-{{maxLength}} znaků, ',\n charactersLeftOver: '{{characters}} zbývá',\n charactersToGo: '{{characters}} zbývá',\n charactersTooMany: '{{characters}} navíc',\n checksPassing: '{{current}}/{{max}} kontrol úspěšně splněno',\n good: 'Dobré',\n imageAutoGenerationTip: 'Automatická generace načte vybraný hero obrázek.',\n lengthTipDescription:\n 'Toto by mělo mít mezi {{minLength}} a {{maxLength}} znaky. Pomoc při psaní kvalitních meta popisů navštivte ',\n lengthTipTitle:\n 'Toto by mělo mít mezi {{minLength}} a {{maxLength}} znaky. Pomoc při psaní kvalitních meta titulů navštivte ',\n missing: 'Chybí',\n noImage: 'Bez obrázku',\n preview: 'Náhled',\n previewDescription:\n 'Přesný výsledek se může lišit v závislosti na obsahu a relevanci vyhledávání.',\n tooLong: 'Příliš dlouhé',\n tooShort: 'Příliš krátké',\n },\n}\n"],"names":["cs","$schema","almostThere","autoGenerate","bestPractices","characterCount","charactersLeftOver","charactersToGo","charactersTooMany","checksPassing","good","imageAutoGenerationTip","lengthTipDescription","lengthTipTitle","missing","noImage","preview","previewDescription","tooLong","tooShort"],"mappings":"AAEA,OAAO,MAAMA,KAAgC;IAC3CC,SAAS;IACT,cAAc;QACZC,aAAa;QACbC,cAAc;QACdC,eAAe;QACfC,gBAAgB;QAChBC,oBAAoB;QACpBC,gBAAgB;QAChBC,mBAAmB;QACnBC,eAAe;QACfC,MAAM;QACNC,wBAAwB;QACxBC,sBACE;QACFC,gBACE;QACFC,SAAS;QACTC,SAAS;QACTC,SAAS;QACTC,oBACE;QACFC,SAAS;QACTC,UAAU;IACZ;AACF,EAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { GenericTranslationsObject, NestedKeysStripped } from '@payloadcms/translations';
|
|
2
2
|
export declare const translations: {
|
|
3
|
+
cs: GenericTranslationsObject;
|
|
3
4
|
de: GenericTranslationsObject;
|
|
4
5
|
en: GenericTranslationsObject;
|
|
5
6
|
es: GenericTranslationsObject;
|
|
@@ -9,6 +10,8 @@ export declare const translations: {
|
|
|
9
10
|
nb: GenericTranslationsObject;
|
|
10
11
|
pl: GenericTranslationsObject;
|
|
11
12
|
ru: GenericTranslationsObject;
|
|
13
|
+
sv: GenericTranslationsObject;
|
|
14
|
+
tr: GenericTranslationsObject;
|
|
12
15
|
uk: GenericTranslationsObject;
|
|
13
16
|
};
|
|
14
17
|
export type PluginSEOTranslations = GenericTranslationsObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/translations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/translations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAgB7F,eAAO,MAAM,YAAY;;;;;;;;;;;;;;CAcxB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,yBAAyB,CAAA;AAE7D,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,CAAC,qBAAqB,CAAC,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cs } from './cs.js';
|
|
1
2
|
import { de } from './de.js';
|
|
2
3
|
import { en } from './en.js';
|
|
3
4
|
import { es } from './es.js';
|
|
@@ -7,8 +8,11 @@ import { it } from './it.js';
|
|
|
7
8
|
import { nb } from './nb.js';
|
|
8
9
|
import { pl } from './pl.js';
|
|
9
10
|
import { ru } from './ru.js';
|
|
11
|
+
import { sv } from './sv.js';
|
|
12
|
+
import { tr } from './tr.js';
|
|
10
13
|
import { uk } from './uk.js';
|
|
11
14
|
export const translations = {
|
|
15
|
+
cs,
|
|
12
16
|
de,
|
|
13
17
|
en,
|
|
14
18
|
es,
|
|
@@ -18,6 +22,8 @@ export const translations = {
|
|
|
18
22
|
nb,
|
|
19
23
|
pl,
|
|
20
24
|
ru,
|
|
25
|
+
sv,
|
|
26
|
+
tr,
|
|
21
27
|
uk
|
|
22
28
|
};
|
|
23
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/translations/index.ts"],"sourcesContent":["import type { GenericTranslationsObject, NestedKeysStripped } from '@payloadcms/translations'\n\nimport { de } from './de.js'\nimport { en } from './en.js'\nimport { es } from './es.js'\nimport { fa } from './fa.js'\nimport { fr } from './fr.js'\nimport { it } from './it.js'\nimport { nb } from './nb.js'\nimport { pl } from './pl.js'\nimport { ru } from './ru.js'\nimport { uk } from './uk.js'\n\nexport const translations = {\n de,\n en,\n es,\n fa,\n fr,\n it,\n nb,\n pl,\n ru,\n uk,\n}\n\nexport type PluginSEOTranslations = GenericTranslationsObject\n\nexport type PluginSEOTranslationKeys = NestedKeysStripped<PluginSEOTranslations>\n"],"names":["de","en","es","fa","fr","it","nb","pl","ru","uk","translations"],"mappings":"AAEA,SAASA,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAE5B,OAAO,MAAMC,eAAe;
|
|
1
|
+
{"version":3,"sources":["../../src/translations/index.ts"],"sourcesContent":["import type { GenericTranslationsObject, NestedKeysStripped } from '@payloadcms/translations'\n\nimport { cs } from './cs.js'\nimport { de } from './de.js'\nimport { en } from './en.js'\nimport { es } from './es.js'\nimport { fa } from './fa.js'\nimport { fr } from './fr.js'\nimport { it } from './it.js'\nimport { nb } from './nb.js'\nimport { pl } from './pl.js'\nimport { ru } from './ru.js'\nimport { sv } from './sv.js'\nimport { tr } from './tr.js'\nimport { uk } from './uk.js'\n\nexport const translations = {\n cs,\n de,\n en,\n es,\n fa,\n fr,\n it,\n nb,\n pl,\n ru,\n sv,\n tr,\n uk,\n}\n\nexport type PluginSEOTranslations = GenericTranslationsObject\n\nexport type PluginSEOTranslationKeys = NestedKeysStripped<PluginSEOTranslations>\n"],"names":["cs","de","en","es","fa","fr","it","nb","pl","ru","sv","tr","uk","translations"],"mappings":"AAEA,SAASA,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAC5B,SAASC,EAAE,QAAQ,UAAS;AAE5B,OAAO,MAAMC,eAAe;IAC1Bb;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sv.d.ts","sourceRoot":"","sources":["../../src/translations/sv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAEzE,eAAO,MAAM,EAAE,EAAE,yBAyBhB,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const sv = {
|
|
2
|
+
$schema: './translation-schema.json',
|
|
3
|
+
'plugin-seo': {
|
|
4
|
+
almostThere: 'Nästan klar',
|
|
5
|
+
autoGenerate: 'Skapa automatiskt',
|
|
6
|
+
bestPractices: 'bästa praxis',
|
|
7
|
+
characterCount: '{{current}}/{{minLength}}-{{maxLength}} tecken, ',
|
|
8
|
+
charactersLeftOver: '{{characters}} tecken blir över',
|
|
9
|
+
charactersToGo: '{{characters}} tecken kvar',
|
|
10
|
+
charactersTooMany: '{{characters}} tecken för mycket',
|
|
11
|
+
checksPassing: '{{current}}/{{max}} kontroller är godkända',
|
|
12
|
+
good: 'Bra',
|
|
13
|
+
imageAutoGenerationTip: 'Den automatiska processen kommer att välja en hero-bild.',
|
|
14
|
+
lengthTipDescription: 'Bör vara mellan {{minLength}} och {{maxLength}} tecken. För hjälp med att skriva bra metabeskrivningar, se ',
|
|
15
|
+
lengthTipTitle: 'Bör vara mellan {{minLength}} och {{maxLength}} tecken. För hjälp med att skriva bra metatitlar, se ',
|
|
16
|
+
missing: 'Saknas',
|
|
17
|
+
noImage: 'Ingen bild',
|
|
18
|
+
preview: 'Förhandsgranska',
|
|
19
|
+
previewDescription: 'Exakta resultatlistningar kan variera baserat på innehåll och sökrelevans.',
|
|
20
|
+
tooLong: 'För lång',
|
|
21
|
+
tooShort: 'För kort'
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=sv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/translations/sv.ts"],"sourcesContent":["import type { GenericTranslationsObject } from '@payloadcms/translations'\n\nexport const sv: GenericTranslationsObject = {\n $schema: './translation-schema.json',\n 'plugin-seo': {\n almostThere: 'Nästan klar',\n autoGenerate: 'Skapa automatiskt',\n bestPractices: 'bästa praxis',\n characterCount: '{{current}}/{{minLength}}-{{maxLength}} tecken, ',\n charactersLeftOver: '{{characters}} tecken blir över',\n charactersToGo: '{{characters}} tecken kvar',\n charactersTooMany: '{{characters}} tecken för mycket',\n checksPassing: '{{current}}/{{max}} kontroller är godkända',\n good: 'Bra',\n imageAutoGenerationTip: 'Den automatiska processen kommer att välja en hero-bild.',\n lengthTipDescription:\n 'Bör vara mellan {{minLength}} och {{maxLength}} tecken. För hjälp med att skriva bra metabeskrivningar, se ',\n lengthTipTitle:\n 'Bör vara mellan {{minLength}} och {{maxLength}} tecken. För hjälp med att skriva bra metatitlar, se ',\n missing: 'Saknas',\n noImage: 'Ingen bild',\n preview: 'Förhandsgranska',\n previewDescription:\n 'Exakta resultatlistningar kan variera baserat på innehåll och sökrelevans.',\n tooLong: 'För lång',\n tooShort: 'För kort',\n },\n}\n"],"names":["sv","$schema","almostThere","autoGenerate","bestPractices","characterCount","charactersLeftOver","charactersToGo","charactersTooMany","checksPassing","good","imageAutoGenerationTip","lengthTipDescription","lengthTipTitle","missing","noImage","preview","previewDescription","tooLong","tooShort"],"mappings":"AAEA,OAAO,MAAMA,KAAgC;IAC3CC,SAAS;IACT,cAAc;QACZC,aAAa;QACbC,cAAc;QACdC,eAAe;QACfC,gBAAgB;QAChBC,oBAAoB;QACpBC,gBAAgB;QAChBC,mBAAmB;QACnBC,eAAe;QACfC,MAAM;QACNC,wBAAwB;QACxBC,sBACE;QACFC,gBACE;QACFC,SAAS;QACTC,SAAS;QACTC,SAAS;QACTC,oBACE;QACFC,SAAS;QACTC,UAAU;IACZ;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tr.d.ts","sourceRoot":"","sources":["../../src/translations/tr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAEzE,eAAO,MAAM,EAAE,EAAE,yBAwBhB,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const tr = {
|
|
2
|
+
$schema: './translation-schema.json',
|
|
3
|
+
'plugin-seo': {
|
|
4
|
+
almostThere: 'Neredeyse tamam',
|
|
5
|
+
autoGenerate: 'Otomatik oluştur',
|
|
6
|
+
bestPractices: 'en iyi uygulamalar',
|
|
7
|
+
characterCount: '{{current}}/{{minLength}}-{{maxLength}} karakter, ',
|
|
8
|
+
charactersLeftOver: '{{characters}} karakter kaldı',
|
|
9
|
+
charactersToGo: '{{characters}} karakter kaldı',
|
|
10
|
+
charactersTooMany: '{{characters}} karakter fazla',
|
|
11
|
+
checksPassing: '{{current}}/{{max}} kontrol başarılı',
|
|
12
|
+
good: 'İyi',
|
|
13
|
+
imageAutoGenerationTip: 'Otomatik oluşturma, seçilen ana görseli alacaktır.',
|
|
14
|
+
lengthTipDescription: '{{minLength}} ile {{maxLength}} karakter arasında olmalıdır. Kaliteli meta açıklamaları yazmak için yardım almak için bkz. ',
|
|
15
|
+
lengthTipTitle: '{{minLength}} ile {{maxLength}} karakter arasında olmalıdır. Kaliteli meta başlıkları yazmak için yardım almak için bkz. ',
|
|
16
|
+
missing: 'Eksik',
|
|
17
|
+
noImage: 'Görsel yok',
|
|
18
|
+
preview: 'Önizleme',
|
|
19
|
+
previewDescription: 'Kesin sonuç listeleri içeriğe ve arama alâkasına göre değişebilir.',
|
|
20
|
+
tooLong: 'Çok uzun',
|
|
21
|
+
tooShort: 'Çok kısa'
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=tr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/translations/tr.ts"],"sourcesContent":["import type { GenericTranslationsObject } from '@payloadcms/translations'\n\nexport const tr: GenericTranslationsObject = {\n $schema: './translation-schema.json',\n 'plugin-seo': {\n almostThere: 'Neredeyse tamam',\n autoGenerate: 'Otomatik oluştur',\n bestPractices: 'en iyi uygulamalar',\n characterCount: '{{current}}/{{minLength}}-{{maxLength}} karakter, ',\n charactersLeftOver: '{{characters}} karakter kaldı',\n charactersToGo: '{{characters}} karakter kaldı',\n charactersTooMany: '{{characters}} karakter fazla',\n checksPassing: '{{current}}/{{max}} kontrol başarılı',\n good: 'İyi',\n imageAutoGenerationTip: 'Otomatik oluşturma, seçilen ana görseli alacaktır.',\n lengthTipDescription:\n '{{minLength}} ile {{maxLength}} karakter arasında olmalıdır. Kaliteli meta açıklamaları yazmak için yardım almak için bkz. ',\n lengthTipTitle:\n '{{minLength}} ile {{maxLength}} karakter arasında olmalıdır. Kaliteli meta başlıkları yazmak için yardım almak için bkz. ',\n missing: 'Eksik',\n noImage: 'Görsel yok',\n preview: 'Önizleme',\n previewDescription: 'Kesin sonuç listeleri içeriğe ve arama alâkasına göre değişebilir.',\n tooLong: 'Çok uzun',\n tooShort: 'Çok kısa',\n },\n}\n"],"names":["tr","$schema","almostThere","autoGenerate","bestPractices","characterCount","charactersLeftOver","charactersToGo","charactersTooMany","checksPassing","good","imageAutoGenerationTip","lengthTipDescription","lengthTipTitle","missing","noImage","preview","previewDescription","tooLong","tooShort"],"mappings":"AAEA,OAAO,MAAMA,KAAgC;IAC3CC,SAAS;IACT,cAAc;QACZC,aAAa;QACbC,cAAc;QACdC,eAAe;QACfC,gBAAgB;QAChBC,oBAAoB;QACpBC,gBAAgB;QAChBC,mBAAmB;QACnBC,eAAe;QACfC,MAAM;QACNC,wBAAwB;QACxBC,sBACE;QACFC,gBACE;QACFC,SAAS;QACTC,SAAS;QACTC,SAAS;QACTC,oBAAoB;QACpBC,SAAS;QACTC,UAAU;IACZ;AACF,EAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { DocumentInfoContext } from '@payloadcms/ui';
|
|
2
|
-
import type { CollectionConfig, Field, GlobalConfig, PayloadRequest
|
|
3
|
-
export type
|
|
2
|
+
import type { CollectionConfig, Field, GlobalConfig, PayloadRequest } from 'payload';
|
|
3
|
+
export type FieldsOverride = (args: {
|
|
4
|
+
defaultFields: Field[];
|
|
5
|
+
}) => Field[];
|
|
6
|
+
export type PartialDocumentInfoContext = Pick<DocumentInfoContext, 'collectionSlug' | 'docPermissions' | 'globalSlug' | 'hasPublishedDoc' | 'hasPublishPermission' | 'hasSavePermission' | 'id' | 'initialData' | 'initialState' | 'preferencesKey' | 'title' | 'versionCount'>;
|
|
4
7
|
export type GenerateTitle<T = any> = (args: {
|
|
5
8
|
collectionConfig?: CollectionConfig;
|
|
6
9
|
doc: T;
|
|
@@ -30,20 +33,37 @@ export type GenerateURL<T = any> = (args: {
|
|
|
30
33
|
req: PayloadRequest;
|
|
31
34
|
} & PartialDocumentInfoContext) => Promise<string> | string;
|
|
32
35
|
export type SEOPluginConfig = {
|
|
36
|
+
/**
|
|
37
|
+
* Collections to include the SEO fields in
|
|
38
|
+
*/
|
|
33
39
|
collections?: string[];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
fields?:
|
|
40
|
+
/**
|
|
41
|
+
* Override the default fields inserted by the SEO plugin via a function that receives the default fields and returns the new fields
|
|
42
|
+
*
|
|
43
|
+
* If you need more flexibility you can insert the fields manually as needed. @link https://payloadcms.com/docs/beta/plugins/seo#direct-use-of-fields
|
|
44
|
+
*/
|
|
45
|
+
fields?: FieldsOverride;
|
|
40
46
|
generateDescription?: GenerateDescription;
|
|
41
47
|
generateImage?: GenerateImage;
|
|
42
48
|
generateTitle?: GenerateTitle;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
43
52
|
generateURL?: GenerateURL;
|
|
53
|
+
/**
|
|
54
|
+
* Globals to include the SEO fields in
|
|
55
|
+
*/
|
|
44
56
|
globals?: string[];
|
|
45
57
|
interfaceName?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Group fields into tabs, your content will be automatically put into a general tab and the SEO fields into an SEO tab
|
|
60
|
+
*
|
|
61
|
+
* If you need more flexibility you can insert the fields manually as needed. @link https://payloadcms.com/docs/beta/plugins/seo#direct-use-of-fields
|
|
62
|
+
*/
|
|
46
63
|
tabbedUI?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* The slug of the collection used to handle image uploads
|
|
66
|
+
*/
|
|
47
67
|
uploadsCollection?: string;
|
|
48
68
|
};
|
|
49
69
|
export type Meta = {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEpF,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE;IAAE,aAAa,EAAE,KAAK,EAAE,CAAA;CAAE,KAAK,KAAK,EAAE,CAAA;AAE1E,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,mBAAmB,EACjB,gBAAgB,GAChB,gBAAgB,GAChB,YAAY,GACZ,iBAAiB,G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AA;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,0BAA0B,KAC3B,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;AAE7B,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;IACzC,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,IAAI,GAAG;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { DocumentInfoContext } from '@payloadcms/ui'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { DocumentInfoContext } from '@payloadcms/ui'\nimport type { CollectionConfig, Field, GlobalConfig, PayloadRequest } from 'payload'\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type PartialDocumentInfoContext = Pick<\n DocumentInfoContext,\n | 'collectionSlug'\n | 'docPermissions'\n | 'globalSlug'\n | 'hasPublishedDoc'\n | 'hasPublishPermission'\n | 'hasSavePermission'\n | 'id'\n | 'initialData'\n | 'initialState'\n | 'preferencesKey'\n | 'title'\n | 'versionCount'\n>\n\nexport type GenerateTitle<T = any> = (\n args: {\n collectionConfig?: CollectionConfig\n doc: T\n globalConfig?: GlobalConfig\n locale?: string\n req: PayloadRequest\n } & PartialDocumentInfoContext,\n) => Promise<string> | string\n\nexport type GenerateDescription<T = any> = (\n args: {\n collectionConfig?: CollectionConfig\n doc: T\n globalConfig?: GlobalConfig\n locale?: string\n req: PayloadRequest\n } & PartialDocumentInfoContext,\n) => Promise<string> | string\n\nexport type GenerateImage<T = any> = (\n args: {\n collectionConfig?: CollectionConfig\n doc: T\n globalConfig?: GlobalConfig\n locale?: string\n req: PayloadRequest\n } & PartialDocumentInfoContext,\n) => Promise<string> | string\n\nexport type GenerateURL<T = any> = (\n args: {\n collectionConfig?: CollectionConfig\n doc: T\n globalConfig?: GlobalConfig\n locale?: string\n req: PayloadRequest\n } & PartialDocumentInfoContext,\n) => Promise<string> | string\n\nexport type SEOPluginConfig = {\n /**\n * Collections to include the SEO fields in\n */\n collections?: string[]\n /**\n * Override the default fields inserted by the SEO plugin via a function that receives the default fields and returns the new fields\n *\n * If you need more flexibility you can insert the fields manually as needed. @link https://payloadcms.com/docs/beta/plugins/seo#direct-use-of-fields\n */\n fields?: FieldsOverride\n generateDescription?: GenerateDescription\n generateImage?: GenerateImage\n generateTitle?: GenerateTitle\n /**\n *\n */\n generateURL?: GenerateURL\n /**\n * Globals to include the SEO fields in\n */\n globals?: string[]\n interfaceName?: string\n /**\n * Group fields into tabs, your content will be automatically put into a general tab and the SEO fields into an SEO tab\n *\n * If you need more flexibility you can insert the fields manually as needed. @link https://payloadcms.com/docs/beta/plugins/seo#direct-use-of-fields\n */\n tabbedUI?: boolean\n /**\n * The slug of the collection used to handle image uploads\n */\n uploadsCollection?: string\n}\n\nexport type Meta = {\n description?: string\n image?: any // TODO: type this\n keywords?: string\n title?: string\n}\n"],"names":[],"mappings":"AAgGA,WAKC"}
|
package/license.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2024 Payload CMS, Inc. <info@payloadcms.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-seo",
|
|
3
|
-
"version": "3.0.0-canary.
|
|
3
|
+
"version": "3.0.0-canary.5624723",
|
|
4
4
|
"description": "SEO plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -18,6 +18,13 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
21
|
+
"maintainers": [
|
|
22
|
+
{
|
|
23
|
+
"name": "Payload",
|
|
24
|
+
"email": "info@payloadcms.com",
|
|
25
|
+
"url": "https://payloadcms.com"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
21
28
|
"type": "module",
|
|
22
29
|
"exports": {
|
|
23
30
|
".": {
|
|
@@ -47,20 +54,20 @@
|
|
|
47
54
|
"dist"
|
|
48
55
|
],
|
|
49
56
|
"dependencies": {
|
|
50
|
-
"@payloadcms/translations": "3.0.0-canary.
|
|
51
|
-
"@payloadcms/ui": "3.0.0-canary.
|
|
57
|
+
"@payloadcms/translations": "3.0.0-canary.5624723",
|
|
58
|
+
"@payloadcms/ui": "3.0.0-canary.5624723"
|
|
52
59
|
},
|
|
53
60
|
"devDependencies": {
|
|
54
61
|
"@types/react": "npm:types-react@19.0.0-rc.1",
|
|
55
62
|
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
|
|
56
|
-
"@payloadcms/
|
|
57
|
-
"
|
|
58
|
-
"
|
|
63
|
+
"@payloadcms/eslint-config": "3.0.0-beta.112",
|
|
64
|
+
"@payloadcms/next": "3.0.0-canary.5624723",
|
|
65
|
+
"payload": "3.0.0-canary.5624723"
|
|
59
66
|
},
|
|
60
67
|
"peerDependencies": {
|
|
61
|
-
"react": "^19.0.0 || ^19.0.0-rc-
|
|
62
|
-
"react-dom": "^19.0.0 || ^19.0.0-rc-
|
|
63
|
-
"payload": "3.0.0-canary.
|
|
68
|
+
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
69
|
+
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
70
|
+
"payload": "3.0.0-canary.5624723"
|
|
64
71
|
},
|
|
65
72
|
"publishConfig": {
|
|
66
73
|
"registry": "https://registry.npmjs.org/"
|