@payloadcms/plugin-seo 3.0.0-canary.f6e77b8 → 3.0.0-canary.fb04843
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/defaults.js.map +1 -1
- package/dist/exports/client.d.ts +6 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +7 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/fields.d.ts +6 -0
- package/dist/exports/fields.d.ts.map +1 -0
- package/dist/exports/fields.js +7 -0
- package/dist/exports/fields.js.map +1 -0
- package/dist/exports/types.js.map +1 -1
- package/dist/fields/MetaDescription/MetaDescriptionComponent.d.ts +8 -0
- package/dist/fields/MetaDescription/MetaDescriptionComponent.d.ts.map +1 -0
- package/dist/fields/MetaDescription/MetaDescriptionComponent.js +162 -0
- package/dist/fields/MetaDescription/MetaDescriptionComponent.js.map +1 -0
- package/dist/fields/MetaDescription/index.d.ts +12 -0
- package/dist/fields/MetaDescription/index.d.ts.map +1 -0
- package/dist/fields/MetaDescription/index.js +20 -0
- package/dist/fields/MetaDescription/index.js.map +1 -0
- package/dist/fields/MetaImage/MetaImageComponent.d.ts +8 -0
- package/dist/fields/MetaImage/MetaImageComponent.d.ts.map +1 -0
- package/dist/fields/MetaImage/MetaImageComponent.js +169 -0
- package/dist/fields/MetaImage/MetaImageComponent.js.map +1 -0
- package/dist/fields/MetaImage/index.d.ts +13 -0
- package/dist/fields/MetaImage/index.d.ts.map +1 -0
- package/dist/fields/MetaImage/index.js +23 -0
- package/dist/fields/MetaImage/index.js.map +1 -0
- package/dist/fields/MetaTitle/MetaTitleComponent.d.ts +9 -0
- package/dist/fields/MetaTitle/MetaTitleComponent.d.ts.map +1 -0
- package/dist/fields/MetaTitle/MetaTitleComponent.js +165 -0
- package/dist/fields/MetaTitle/MetaTitleComponent.js.map +1 -0
- package/dist/fields/MetaTitle/index.d.ts +12 -0
- package/dist/fields/MetaTitle/index.d.ts.map +1 -0
- package/dist/fields/MetaTitle/index.js +20 -0
- package/dist/fields/MetaTitle/index.js.map +1 -0
- package/dist/fields/Overview/OverviewComponent.d.ts +18 -0
- package/dist/fields/Overview/OverviewComponent.d.ts.map +1 -0
- package/dist/fields/Overview/OverviewComponent.js +63 -0
- package/dist/fields/Overview/OverviewComponent.js.map +1 -0
- package/dist/fields/Overview/index.d.ts +34 -0
- package/dist/fields/Overview/index.d.ts.map +1 -0
- package/dist/fields/Overview/index.js +24 -0
- package/dist/fields/Overview/index.js.map +1 -0
- package/dist/fields/Preview/PreviewComponent.d.ts +10 -0
- package/dist/fields/Preview/PreviewComponent.d.ts.map +1 -0
- package/dist/fields/Preview/PreviewComponent.js +116 -0
- package/dist/fields/Preview/PreviewComponent.js.map +1 -0
- package/dist/fields/Preview/index.d.ts +24 -0
- package/dist/fields/Preview/index.d.ts.map +1 -0
- package/dist/fields/Preview/index.js +22 -0
- package/dist/fields/Preview/index.js.map +1 -0
- package/dist/fields/index.scss +5 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -103
- 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/de.d.ts +3 -0
- package/dist/translations/de.d.ts.map +1 -0
- package/dist/translations/de.js +25 -0
- package/dist/translations/de.js.map +1 -0
- package/dist/translations/en.d.ts +3 -0
- package/dist/translations/en.d.ts.map +1 -0
- package/dist/translations/en.js +25 -0
- package/dist/translations/en.js.map +1 -0
- package/dist/translations/es.d.ts +3 -0
- package/dist/translations/es.d.ts.map +1 -0
- package/dist/translations/es.js +25 -0
- package/dist/translations/es.js.map +1 -0
- package/dist/translations/fa.d.ts +3 -0
- package/dist/translations/fa.d.ts.map +1 -0
- package/dist/translations/fa.js +25 -0
- package/dist/translations/fa.js.map +1 -0
- package/dist/translations/fr.d.ts +3 -0
- package/dist/translations/fr.d.ts.map +1 -0
- package/dist/translations/fr.js +25 -0
- package/dist/translations/fr.js.map +1 -0
- package/dist/translations/index.d.ts +16 -154
- package/dist/translations/index.d.ts.map +1 -1
- package/dist/translations/index.js +26 -154
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/it.d.ts +3 -0
- package/dist/translations/it.d.ts.map +1 -0
- package/dist/translations/it.js +25 -0
- package/dist/translations/it.js.map +1 -0
- package/dist/translations/nb.d.ts +3 -0
- package/dist/translations/nb.d.ts.map +1 -0
- package/dist/translations/nb.js +25 -0
- package/dist/translations/nb.js.map +1 -0
- package/dist/translations/pl.d.ts +3 -0
- package/dist/translations/pl.d.ts.map +1 -0
- package/dist/translations/pl.js +25 -0
- package/dist/translations/pl.js.map +1 -0
- package/dist/translations/ru.d.ts +3 -0
- package/dist/translations/ru.d.ts.map +1 -0
- package/dist/translations/ru.js +25 -0
- package/dist/translations/ru.js.map +1 -0
- 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/translations/translation-schema.json +5 -1
- package/dist/translations/uk.d.ts +3 -0
- package/dist/translations/uk.d.ts.map +1 -0
- package/dist/translations/uk.js +25 -0
- package/dist/translations/uk.js.map +1 -0
- package/dist/translations/vi.d.ts +3 -0
- package/dist/translations/vi.d.ts.map +1 -0
- package/dist/translations/vi.js +25 -0
- package/dist/translations/vi.js.map +1 -0
- package/dist/types.d.ts +49 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/ui/LengthIndicator.d.ts.map +1 -1
- package/dist/ui/LengthIndicator.js +63 -42
- package/dist/ui/LengthIndicator.js.map +1 -1
- package/dist/ui/Pill.js +7 -3
- package/dist/ui/Pill.js.map +1 -1
- package/license.md +22 -0
- package/package.json +44 -21
- package/dist/fields/MetaDescription.d.ts +0 -9
- package/dist/fields/MetaDescription.d.ts.map +0 -1
- package/dist/fields/MetaDescription.js +0 -116
- package/dist/fields/MetaDescription.js.map +0 -1
- package/dist/fields/MetaImage.d.ts +0 -8
- package/dist/fields/MetaImage.d.ts.map +0 -1
- package/dist/fields/MetaImage.js +0 -120
- package/dist/fields/MetaImage.js.map +0 -1
- package/dist/fields/MetaTitle.d.ts +0 -9
- package/dist/fields/MetaTitle.d.ts.map +0 -1
- package/dist/fields/MetaTitle.js +0 -117
- package/dist/fields/MetaTitle.js.map +0 -1
- package/dist/translations/en.json +0 -22
- package/dist/translations/es.json +0 -22
- package/dist/translations/fa.json +0 -22
- package/dist/translations/fr.json +0 -22
- package/dist/translations/pl.json +0 -22
- package/dist/translations/uk.json +0 -22
- package/dist/ui/Overview.d.ts +0 -3
- package/dist/ui/Overview.d.ts.map +0 -1
- package/dist/ui/Overview.js +0 -51
- package/dist/ui/Overview.js.map +0 -1
- package/dist/ui/Preview.d.ts +0 -8
- package/dist/ui/Preview.d.ts.map +0 -1
- package/dist/ui/Preview.js +0 -79
- package/dist/ui/Preview.js.map +0 -1
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { TextareaInput } from '@payloadcms/ui/fields/Textarea';
|
|
3
|
-
import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
|
|
4
|
-
import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
|
|
5
|
-
import { useAllFormFields } from '@payloadcms/ui/forms/Form';
|
|
6
|
-
import { useField } from '@payloadcms/ui/forms/useField';
|
|
7
|
-
import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
|
|
8
|
-
import { useLocale } from '@payloadcms/ui/providers/Locale';
|
|
9
|
-
import { useTranslation } from '@payloadcms/ui/providers/Translation';
|
|
10
|
-
import React, { useCallback } from 'react';
|
|
11
|
-
import { defaults } from '../defaults.js';
|
|
12
|
-
import { LengthIndicator } from '../ui/LengthIndicator.js';
|
|
13
|
-
const { maxLength, minLength } = defaults.description;
|
|
14
|
-
export const MetaDescription = (props)=>{
|
|
15
|
-
const { CustomLabel, hasGenerateDescriptionFn, label, labelProps, path, required } = props;
|
|
16
|
-
const { path: pathFromContext } = useFieldProps();
|
|
17
|
-
const { t } = useTranslation();
|
|
18
|
-
const locale = useLocale();
|
|
19
|
-
const [fields] = useAllFormFields();
|
|
20
|
-
const docInfo = useDocumentInfo();
|
|
21
|
-
const field = useField({
|
|
22
|
-
path
|
|
23
|
-
});
|
|
24
|
-
const { errorMessage, setValue, showError, value } = field;
|
|
25
|
-
const regenerateDescription = useCallback(async ()=>{
|
|
26
|
-
if (!hasGenerateDescriptionFn) return;
|
|
27
|
-
const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description', {
|
|
28
|
-
body: JSON.stringify({
|
|
29
|
-
...docInfo,
|
|
30
|
-
doc: {
|
|
31
|
-
...fields
|
|
32
|
-
},
|
|
33
|
-
locale: typeof locale === 'object' ? locale?.code : locale
|
|
34
|
-
}),
|
|
35
|
-
credentials: 'include',
|
|
36
|
-
headers: {
|
|
37
|
-
'Content-Type': 'application/json'
|
|
38
|
-
},
|
|
39
|
-
method: 'POST'
|
|
40
|
-
});
|
|
41
|
-
const { result: generatedDescription } = await genDescriptionResponse.json();
|
|
42
|
-
setValue(generatedDescription || '');
|
|
43
|
-
}, [
|
|
44
|
-
fields,
|
|
45
|
-
setValue,
|
|
46
|
-
hasGenerateDescriptionFn,
|
|
47
|
-
locale,
|
|
48
|
-
docInfo
|
|
49
|
-
]);
|
|
50
|
-
return /*#__PURE__*/ React.createElement("div", {
|
|
51
|
-
style: {
|
|
52
|
-
marginBottom: '20px'
|
|
53
|
-
}
|
|
54
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
55
|
-
style: {
|
|
56
|
-
marginBottom: '5px',
|
|
57
|
-
position: 'relative'
|
|
58
|
-
}
|
|
59
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
60
|
-
className: "plugin-seo__field"
|
|
61
|
-
}, /*#__PURE__*/ React.createElement(FieldLabel, {
|
|
62
|
-
CustomLabel: CustomLabel,
|
|
63
|
-
label: label,
|
|
64
|
-
...labelProps || {}
|
|
65
|
-
}), hasGenerateDescriptionFn && /*#__PURE__*/ React.createElement(React.Fragment, null, " — ", /*#__PURE__*/ React.createElement("button", {
|
|
66
|
-
onClick: regenerateDescription,
|
|
67
|
-
style: {
|
|
68
|
-
background: 'none',
|
|
69
|
-
backgroundColor: 'transparent',
|
|
70
|
-
border: 'none',
|
|
71
|
-
color: 'currentcolor',
|
|
72
|
-
cursor: 'pointer',
|
|
73
|
-
padding: 0,
|
|
74
|
-
textDecoration: 'underline'
|
|
75
|
-
},
|
|
76
|
-
type: "button"
|
|
77
|
-
}, t('plugin-seo:autoGenerate')))), /*#__PURE__*/ React.createElement("div", {
|
|
78
|
-
style: {
|
|
79
|
-
color: '#9A9A9A'
|
|
80
|
-
}
|
|
81
|
-
}, t('plugin-seo:lengthTipDescription', {
|
|
82
|
-
maxLength,
|
|
83
|
-
minLength
|
|
84
|
-
}), /*#__PURE__*/ React.createElement("a", {
|
|
85
|
-
href: "https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions",
|
|
86
|
-
rel: "noopener noreferrer",
|
|
87
|
-
target: "_blank"
|
|
88
|
-
}, t('plugin-seo:bestPractices')))), /*#__PURE__*/ React.createElement("div", {
|
|
89
|
-
style: {
|
|
90
|
-
marginBottom: '10px',
|
|
91
|
-
position: 'relative'
|
|
92
|
-
}
|
|
93
|
-
}, /*#__PURE__*/ React.createElement(TextareaInput, {
|
|
94
|
-
CustomError: errorMessage,
|
|
95
|
-
onChange: setValue,
|
|
96
|
-
path: pathFromContext,
|
|
97
|
-
required: required,
|
|
98
|
-
showError: showError,
|
|
99
|
-
style: {
|
|
100
|
-
marginBottom: 0
|
|
101
|
-
},
|
|
102
|
-
value: value
|
|
103
|
-
})), /*#__PURE__*/ React.createElement("div", {
|
|
104
|
-
style: {
|
|
105
|
-
alignItems: 'center',
|
|
106
|
-
display: 'flex',
|
|
107
|
-
width: '100%'
|
|
108
|
-
}
|
|
109
|
-
}, /*#__PURE__*/ React.createElement(LengthIndicator, {
|
|
110
|
-
maxLength: maxLength,
|
|
111
|
-
minLength: minLength,
|
|
112
|
-
text: value
|
|
113
|
-
})));
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
//# sourceMappingURL=MetaDescription.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/MetaDescription.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { FieldType, Options } from '@payloadcms/ui/forms/useField'\n\nimport { TextareaInput } from '@payloadcms/ui/fields/Textarea'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useAllFormFields } from '@payloadcms/ui/forms/Form'\nimport { useField } from '@payloadcms/ui/forms/useField'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useLocale } from '@payloadcms/ui/providers/Locale'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback } from 'react'\n\nimport type { GenerateDescription } from '../types.js'\n\nimport { defaults } from '../defaults.js'\nimport { LengthIndicator } from '../ui/LengthIndicator.js'\n\nconst { maxLength, minLength } = defaults.description\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaDescriptionProps = FormFieldBase & {\n hasGenerateDescriptionFn: boolean\n path: string\n}\n\nexport const MetaDescription: React.FC<MetaDescriptionProps> = (props) => {\n const { CustomLabel, hasGenerateDescriptionFn, label, labelProps, path, required } = props\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const docInfo = useDocumentInfo()\n\n const field: FieldType<string> = useField({\n path,\n } as Options)\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateDescription = useCallback(async () => {\n if (!hasGenerateDescriptionFn) return\n\n const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateDescription>[0]),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedDescription } = await genDescriptionResponse.json()\n\n setValue(generatedDescription || '')\n }, [fields, setValue, hasGenerateDescriptionFn, locale, docInfo])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel CustomLabel={CustomLabel} label={label} {...(labelProps || {})} />\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n — \n <button\n onClick={regenerateDescription}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipDescription', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextareaInput\n CustomError={errorMessage}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["TextareaInput","FieldLabel","useFieldProps","useAllFormFields","useField","useDocumentInfo","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","description","MetaDescription","props","CustomLabel","hasGenerateDescriptionFn","label","labelProps","path","required","pathFromContext","t","locale","fields","docInfo","field","errorMessage","setValue","showError","value","regenerateDescription","genDescriptionResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedDescription","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","CustomError","onChange","alignItems","display","width","text"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAKA,SAASA,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,QAAQ,QAAQ,iBAAgB;AACzC,SAASC,eAAe,QAAQ,2BAA0B;AAE1D,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGH,SAASI,WAAW;AAQrD,OAAO,MAAMC,kBAAkD,CAACC;IAC9D,MAAM,EAAEC,WAAW,EAAEC,wBAAwB,EAAEC,KAAK,EAAEC,UAAU,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGN;IACrF,MAAM,EAAEK,MAAME,eAAe,EAAE,GAAGrB;IAElC,MAAM,EAAEsB,CAAC,EAAE,GAAGjB;IAEd,M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,EAAE,8CAIT,oBAACuB;QACCC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAAClD;QACCmE,aAAatC;QACbuC,UAAUtC;QACVT,MAAME;QACND,UAAUA;QACVS,WAAWA;QACXiB,OAAO;YACLC,cAAc;QAChB;QACAjB,OAAOA;uBAGX,oBAACe;QACCC,OAAO;YACLqB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAAC5D;QAAgBC,WAAWA;QAAWC,WAAWA;QAAW2D,MAAMxC;;AAI3E,EAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { UploadInputProps } from '@payloadcms/ui/fields/Upload';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
type MetaImageProps = UploadInputProps & {
|
|
4
|
-
hasGenerateImageFn: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare const MetaImage: React.FC<MetaImageProps>;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=MetaImage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MetaImage.d.ts","sourceRoot":"","sources":["../../src/fields/MetaImage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAWpE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,KAAK,cAAc,GAAG,gBAAgB,GAAG;IACvC,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAoI9C,CAAA"}
|
package/dist/fields/MetaImage.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { UploadInput } from '@payloadcms/ui/fields/Upload';
|
|
3
|
-
import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
|
|
4
|
-
import { useAllFormFields } from '@payloadcms/ui/forms/Form';
|
|
5
|
-
import { useField } from '@payloadcms/ui/forms/useField';
|
|
6
|
-
import { useConfig } from '@payloadcms/ui/providers/Config';
|
|
7
|
-
import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
|
|
8
|
-
import { useLocale } from '@payloadcms/ui/providers/Locale';
|
|
9
|
-
import { useTranslation } from '@payloadcms/ui/providers/Translation';
|
|
10
|
-
import React, { useCallback } from 'react';
|
|
11
|
-
import { Pill } from '../ui/Pill.js';
|
|
12
|
-
export const MetaImage = (props)=>{
|
|
13
|
-
const { CustomLabel, hasGenerateImageFn, label, labelProps, relationTo, required } = props || {};
|
|
14
|
-
const field = useField(props);
|
|
15
|
-
const { t } = useTranslation();
|
|
16
|
-
const locale = useLocale();
|
|
17
|
-
const [fields] = useAllFormFields();
|
|
18
|
-
const docInfo = useDocumentInfo();
|
|
19
|
-
const { errorMessage, setValue, showError, value } = field;
|
|
20
|
-
const regenerateImage = useCallback(async ()=>{
|
|
21
|
-
if (!hasGenerateImageFn) return;
|
|
22
|
-
const genImageResponse = await fetch('/api/plugin-seo/generate-image', {
|
|
23
|
-
body: JSON.stringify({
|
|
24
|
-
...docInfo,
|
|
25
|
-
doc: {
|
|
26
|
-
...fields
|
|
27
|
-
},
|
|
28
|
-
locale: typeof locale === 'object' ? locale?.code : locale
|
|
29
|
-
}),
|
|
30
|
-
credentials: 'include',
|
|
31
|
-
headers: {
|
|
32
|
-
'Content-Type': 'application/json'
|
|
33
|
-
},
|
|
34
|
-
method: 'POST'
|
|
35
|
-
});
|
|
36
|
-
const { result: generatedImage } = await genImageResponse.json();
|
|
37
|
-
setValue(generatedImage || '');
|
|
38
|
-
}, [
|
|
39
|
-
fields,
|
|
40
|
-
setValue,
|
|
41
|
-
hasGenerateImageFn,
|
|
42
|
-
locale,
|
|
43
|
-
docInfo
|
|
44
|
-
]);
|
|
45
|
-
const hasImage = Boolean(value);
|
|
46
|
-
const config = useConfig();
|
|
47
|
-
const { collections, routes: { api } = {}, serverURL } = config;
|
|
48
|
-
const collection = collections?.find((coll)=>coll.slug === relationTo) || undefined;
|
|
49
|
-
return /*#__PURE__*/ React.createElement("div", {
|
|
50
|
-
style: {
|
|
51
|
-
marginBottom: '20px'
|
|
52
|
-
}
|
|
53
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
54
|
-
style: {
|
|
55
|
-
marginBottom: '5px',
|
|
56
|
-
position: 'relative'
|
|
57
|
-
}
|
|
58
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
59
|
-
className: "plugin-seo__field"
|
|
60
|
-
}, /*#__PURE__*/ React.createElement(FieldLabel, {
|
|
61
|
-
CustomLabel: CustomLabel,
|
|
62
|
-
label: label,
|
|
63
|
-
...labelProps || {}
|
|
64
|
-
}), hasGenerateImageFn && /*#__PURE__*/ React.createElement(React.Fragment, null, " — ", /*#__PURE__*/ React.createElement("button", {
|
|
65
|
-
onClick: regenerateImage,
|
|
66
|
-
style: {
|
|
67
|
-
background: 'none',
|
|
68
|
-
backgroundColor: 'transparent',
|
|
69
|
-
border: 'none',
|
|
70
|
-
color: 'currentcolor',
|
|
71
|
-
cursor: 'pointer',
|
|
72
|
-
padding: 0,
|
|
73
|
-
textDecoration: 'underline'
|
|
74
|
-
},
|
|
75
|
-
type: "button"
|
|
76
|
-
}, t('plugin-seo:autoGenerate')))), hasGenerateImageFn && /*#__PURE__*/ React.createElement("div", {
|
|
77
|
-
style: {
|
|
78
|
-
color: '#9A9A9A'
|
|
79
|
-
}
|
|
80
|
-
}, t('plugin-seo:imageAutoGenerationTip'))), /*#__PURE__*/ React.createElement("div", {
|
|
81
|
-
style: {
|
|
82
|
-
marginBottom: '10px',
|
|
83
|
-
position: 'relative'
|
|
84
|
-
}
|
|
85
|
-
}, /*#__PURE__*/ React.createElement(UploadInput, {
|
|
86
|
-
CustomError: errorMessage,
|
|
87
|
-
api: api,
|
|
88
|
-
collection: collection,
|
|
89
|
-
filterOptions: {},
|
|
90
|
-
label: undefined,
|
|
91
|
-
onChange: (incomingImage)=>{
|
|
92
|
-
if (incomingImage !== null) {
|
|
93
|
-
const { id: incomingID } = incomingImage;
|
|
94
|
-
setValue(incomingID);
|
|
95
|
-
} else {
|
|
96
|
-
setValue(null);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
relationTo: relationTo,
|
|
100
|
-
required: required,
|
|
101
|
-
serverURL: serverURL,
|
|
102
|
-
showError: showError,
|
|
103
|
-
style: {
|
|
104
|
-
marginBottom: 0
|
|
105
|
-
},
|
|
106
|
-
value: value
|
|
107
|
-
})), /*#__PURE__*/ React.createElement("div", {
|
|
108
|
-
style: {
|
|
109
|
-
alignItems: 'center',
|
|
110
|
-
display: 'flex',
|
|
111
|
-
width: '100%'
|
|
112
|
-
}
|
|
113
|
-
}, /*#__PURE__*/ React.createElement(Pill, {
|
|
114
|
-
backgroundColor: hasImage ? 'green' : 'red',
|
|
115
|
-
color: "white",
|
|
116
|
-
label: hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')
|
|
117
|
-
})));
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
//# sourceMappingURL=MetaImage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/MetaImage.tsx"],"sourcesContent":["'use client'\n\nimport type { UploadInputProps } from '@payloadcms/ui/fields/Upload'\nimport type { FieldType, Options } from '@payloadcms/ui/forms/useField'\n\nimport { UploadInput } from '@payloadcms/ui/fields/Upload'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport { useAllFormFields } from '@payloadcms/ui/forms/Form'\nimport { useField } from '@payloadcms/ui/forms/useField'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useLocale } from '@payloadcms/ui/providers/Locale'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback } from 'react'\n\nimport type { GenerateImage } from '../types.js'\n\nimport { Pill } from '../ui/Pill.js'\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaImageProps = UploadInputProps & {\n hasGenerateImageFn: boolean\n}\n\nexport const MetaImage: React.FC<MetaImageProps> = (props) => {\n const { CustomLabel, hasGenerateImageFn, label, labelProps, relationTo, required } = props || {}\n\n const field: FieldType<string> = useField(props as Options)\n\n const { t } = useTranslation()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateImage = useCallback(async () => {\n if (!hasGenerateImageFn) return\n\n const genImageResponse = await fetch('/api/plugin-seo/generate-image', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateImage>[0]),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedImage } = await genImageResponse.json()\n\n setValue(generatedImage || '')\n }, [fields, setValue, hasGenerateImageFn, locale, docInfo])\n\n const hasImage = Boolean(value)\n\n const config = useConfig()\n\n const { collections, routes: { api } = {}, serverURL } = config\n\n const collection = collections?.find((coll) => coll.slug === relationTo) || undefined\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel CustomLabel={CustomLabel} label={label} {...(labelProps || {})} />\n {hasGenerateImageFn && (\n <React.Fragment>\n — \n <button\n onClick={regenerateImage}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n {hasGenerateImageFn && (\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:imageAutoGenerationTip')}\n </div>\n )}\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <UploadInput\n CustomError={errorMessage}\n api={api}\n collection={collection}\n filterOptions={{}}\n label={undefined}\n onChange={(incomingImage) => {\n if (incomingImage !== null) {\n const { id: incomingID } = incomingImage\n setValue(incomingID)\n } else {\n setValue(null)\n }\n }}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <Pill\n backgroundColor={hasImage ? 'green' : 'red'}\n color=\"white\"\n label={hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')}\n />\n </div>\n </div>\n )\n}\n"],"names":["UploadInput","FieldLabel","useAllFormFields","useField","useConfig","useDocumentInfo","useLocale","useTranslation","React","useCallback","Pill","MetaImage","props","CustomLabel","hasGenerateImageFn","label","labelProps","relationTo","required","field","t","locale","fields","docInfo","errorMessage","setValue","showError","value","regenerateImage","genImageResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedImage","json","hasImage","Boolean","config","collections","routes","api","serverURL","collection","find","coll","slug","undefined","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","CustomError","filterOptions","onChange","incomingImage","id","incomingID","alignItems","display","width"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAKA,SAASA,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,u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CC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAACH;QAAII,WAAU;qBACb,oBAACzD;QAAWY,aAAaA;QAAaE,OAAOA;QAAQ,GAAIC,cAAc,CAAC,CAAC;QACxEF,oCACC,oBAACN,MAAMmD,QAAQ,QAAC,uBAEd,oBAACC;QACCC,SAASjC;QACT2B,OAAO;YACLO,YAAY;YACZC,iBAAiB;YACjBC,QAAQ;YACRC,OAAO;YACPC,QAAQ;YACRC,SAAS;YACTC,gBAAgB;QAClB;QACAC,MAAK;OAEJjD,EAAE,+BAKVN,oCACC,oBAACwC;QACCC,OAAO;YACLU,OAAO;QACT;OAEC7C,EAAE,sDAIT,oBAACkC;QACCC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAACzD;QACCsE,aAAa9C;QACbuB,KAAKA;QACLE,YAAYA;QACZsB,eAAe,CAAC;QAChBxD,OAAOsC;QACPmB,UAAU,CAACC;YACT,IAAIA,kBAAkB,MAAM;gBAC1B,MAAM,EAAEC,IAAIC,UAAU,EAAE,GAAGF;gBAC3BhD,SAASkD;YACX,OAAO;gBACLlD,SAAS;YACX;QACF;QACAR,YAAYA;QACZC,UAAUA;QACV8B,WAAWA;QACXtB,WAAWA;QACX6B,OAAO;YACLC,cAAc;QAChB;QACA7B,OAAOA;uBAGX,oBAAC2B;QACCC,OAAO;YACLqB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAACpE;QACCqD,iBAAiBrB,WAAW,UAAU;QACtCuB,OAAM;QACNlD,OAAO2B,WAAWtB,EAAE,qBAAqBA,EAAE;;AAKrD,EAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FormFieldBase } from '@payloadcms/ui/fields/shared';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import './index.scss';
|
|
4
|
-
type MetaTitleProps = FormFieldBase & {
|
|
5
|
-
hasGenerateTitleFn: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const MetaTitle: React.FC<MetaTitleProps>;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=MetaTitle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MetaTitle.d.ts","sourceRoot":"","sources":["../../src/fields/MetaTitle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAYjE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAM1C,OAAO,cAAc,CAAA;AAKrB,KAAK,cAAc,GAAG,aAAa,GAAG;IACpC,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAqH9C,CAAA"}
|
package/dist/fields/MetaTitle.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { TextInput } from '@payloadcms/ui/fields/Text';
|
|
3
|
-
import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
|
|
4
|
-
import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
|
|
5
|
-
import { useAllFormFields } from '@payloadcms/ui/forms/Form';
|
|
6
|
-
import { useField } from '@payloadcms/ui/forms/useField';
|
|
7
|
-
import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
|
|
8
|
-
import { useLocale } from '@payloadcms/ui/providers/Locale';
|
|
9
|
-
import { useTranslation } from '@payloadcms/ui/providers/Translation';
|
|
10
|
-
import React, { useCallback } from 'react';
|
|
11
|
-
import { defaults } from '../defaults.js';
|
|
12
|
-
import { LengthIndicator } from '../ui/LengthIndicator.js';
|
|
13
|
-
import './index.scss';
|
|
14
|
-
const { maxLength, minLength } = defaults.title;
|
|
15
|
-
export const MetaTitle = (props)=>{
|
|
16
|
-
const { CustomLabel, hasGenerateTitleFn, label, labelProps, path, required } = props || {};
|
|
17
|
-
const { path: pathFromContext } = useFieldProps();
|
|
18
|
-
const { t } = useTranslation();
|
|
19
|
-
const field = useField({
|
|
20
|
-
path
|
|
21
|
-
});
|
|
22
|
-
const locale = useLocale();
|
|
23
|
-
const [fields] = useAllFormFields();
|
|
24
|
-
const docInfo = useDocumentInfo();
|
|
25
|
-
const { errorMessage, setValue, showError, value } = field;
|
|
26
|
-
const regenerateTitle = useCallback(async ()=>{
|
|
27
|
-
if (!hasGenerateTitleFn) return;
|
|
28
|
-
const genTitleResponse = await fetch('/api/plugin-seo/generate-title', {
|
|
29
|
-
body: JSON.stringify({
|
|
30
|
-
...docInfo,
|
|
31
|
-
doc: {
|
|
32
|
-
...fields
|
|
33
|
-
},
|
|
34
|
-
locale: typeof locale === 'object' ? locale?.code : locale
|
|
35
|
-
}),
|
|
36
|
-
credentials: 'include',
|
|
37
|
-
headers: {
|
|
38
|
-
'Content-Type': 'application/json'
|
|
39
|
-
},
|
|
40
|
-
method: 'POST'
|
|
41
|
-
});
|
|
42
|
-
const { result: generatedTitle } = await genTitleResponse.json();
|
|
43
|
-
setValue(generatedTitle || '');
|
|
44
|
-
}, [
|
|
45
|
-
fields,
|
|
46
|
-
setValue,
|
|
47
|
-
hasGenerateTitleFn,
|
|
48
|
-
locale,
|
|
49
|
-
docInfo
|
|
50
|
-
]);
|
|
51
|
-
return /*#__PURE__*/ React.createElement("div", {
|
|
52
|
-
style: {
|
|
53
|
-
marginBottom: '20px'
|
|
54
|
-
}
|
|
55
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
56
|
-
style: {
|
|
57
|
-
marginBottom: '5px',
|
|
58
|
-
position: 'relative'
|
|
59
|
-
}
|
|
60
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
61
|
-
className: "plugin-seo__field"
|
|
62
|
-
}, /*#__PURE__*/ React.createElement(FieldLabel, {
|
|
63
|
-
CustomLabel: CustomLabel,
|
|
64
|
-
label: label,
|
|
65
|
-
...labelProps || {}
|
|
66
|
-
}), hasGenerateTitleFn && /*#__PURE__*/ React.createElement(React.Fragment, null, " — ", /*#__PURE__*/ React.createElement("button", {
|
|
67
|
-
onClick: regenerateTitle,
|
|
68
|
-
style: {
|
|
69
|
-
background: 'none',
|
|
70
|
-
backgroundColor: 'transparent',
|
|
71
|
-
border: 'none',
|
|
72
|
-
color: 'currentcolor',
|
|
73
|
-
cursor: 'pointer',
|
|
74
|
-
padding: 0,
|
|
75
|
-
textDecoration: 'underline'
|
|
76
|
-
},
|
|
77
|
-
type: "button"
|
|
78
|
-
}, t('plugin-seo:autoGenerate')))), /*#__PURE__*/ React.createElement("div", {
|
|
79
|
-
style: {
|
|
80
|
-
color: '#9A9A9A'
|
|
81
|
-
}
|
|
82
|
-
}, t('plugin-seo:lengthTipTitle', {
|
|
83
|
-
maxLength,
|
|
84
|
-
minLength
|
|
85
|
-
}), /*#__PURE__*/ React.createElement("a", {
|
|
86
|
-
href: "https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles",
|
|
87
|
-
rel: "noopener noreferrer",
|
|
88
|
-
target: "_blank"
|
|
89
|
-
}, t('plugin-seo:bestPractices')), ".")), /*#__PURE__*/ React.createElement("div", {
|
|
90
|
-
style: {
|
|
91
|
-
marginBottom: '10px',
|
|
92
|
-
position: 'relative'
|
|
93
|
-
}
|
|
94
|
-
}, /*#__PURE__*/ React.createElement(TextInput, {
|
|
95
|
-
CustomError: errorMessage,
|
|
96
|
-
onChange: setValue,
|
|
97
|
-
path: pathFromContext,
|
|
98
|
-
required: required,
|
|
99
|
-
showError: showError,
|
|
100
|
-
style: {
|
|
101
|
-
marginBottom: 0
|
|
102
|
-
},
|
|
103
|
-
value: value
|
|
104
|
-
})), /*#__PURE__*/ React.createElement("div", {
|
|
105
|
-
style: {
|
|
106
|
-
alignItems: 'center',
|
|
107
|
-
display: 'flex',
|
|
108
|
-
width: '100%'
|
|
109
|
-
}
|
|
110
|
-
}, /*#__PURE__*/ React.createElement(LengthIndicator, {
|
|
111
|
-
maxLength: maxLength,
|
|
112
|
-
minLength: minLength,
|
|
113
|
-
text: value
|
|
114
|
-
})));
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
//# sourceMappingURL=MetaTitle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/MetaTitle.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { Options } from '@payloadcms/ui/forms/useField'\nimport type { FieldType } from '@payloadcms/ui/forms/useField'\n\nimport { TextInput } from '@payloadcms/ui/fields/Text'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useAllFormFields } from '@payloadcms/ui/forms/Form'\nimport { useField } from '@payloadcms/ui/forms/useField'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useLocale } from '@payloadcms/ui/providers/Locale'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback } from 'react'\n\nimport type { GenerateTitle } from '../types.js'\n\nimport { defaults } from '../defaults.js'\nimport { LengthIndicator } from '../ui/LengthIndicator.js'\nimport './index.scss'\n\nconst { maxLength, minLength } = defaults.title\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaTitleProps = FormFieldBase & {\n hasGenerateTitleFn: boolean\n}\n\nexport const MetaTitle: React.FC<MetaTitleProps> = (props) => {\n const { CustomLabel, hasGenerateTitleFn, label, labelProps, path, required } = props || {}\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation()\n\n const field: FieldType<string> = useField({\n path,\n } as Options)\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) return\n\n const genTitleResponse = await fetch('/api/plugin-seo/generate-title', {\n body: JSON.stringify({\n ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateTitle>[0]),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedTitle } = await genTitleResponse.json()\n\n setValue(generatedTitle || '')\n }, [fields, setValue, hasGenerateTitleFn, locale, docInfo])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel CustomLabel={CustomLabel} label={label} {...(labelProps || {})} />\n {hasGenerateTitleFn && (\n <React.Fragment>\n — \n <button\n onClick={regenerateTitle}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipTitle', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n .\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextInput\n CustomError={errorMessage}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["TextInput","FieldLabel","useFieldProps","useAllFormFields","useField","useDocumentInfo","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","title","MetaTitle","props","CustomLabel","hasGenerateTitleFn","label","labelProps","path","required","pathFromContext","t","field","locale","fields","docInfo","errorMessage","setValue","showError","value","regenerateTitle","genTitleResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedTitle","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","CustomError","onChange","alignItems","display","width","text"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAMA,SAASA,SAAS,QAAQ,6BAA4B;AACtD,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,QAAQ,QAAQ,iBAAgB;AACzC,SAASC,eAAe,QAAQ,2BAA0B;AAC1D,OAAO,eAAc;AAErB,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGH,SAASI,KAAK;AAO/C,OAAO,MAAMC,YAAsC,CAACC;IAClD,MAAM,EAAEC,WAAW,EAAEC,kBAAkB,EAAEC,KAAK,EAAEC,UAAU,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGN,SAAS,CAAC;IACzF,MAAM,EAAEK,MAAME,eAAe,EAAE,GAAGrB;IAElC,MAAM,EAAEsB,CAAC,EAAE,GAAGjB;IAEd,MAAMkB,QAA2BrB,SAAS;QACxCiB;IACF;IAEA,MAAMK,SAASpB;IACf,MAAM,CAACqB,OAAO,GAAGxB;IACjB,MAAMyB,UAAUvB;IAEhB,MAAM,EAAEwB,YAAY,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGP;IAErD,MAAM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oBAACe;QACCC,OAAO;YACLqB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAAC5D;QAAgBC,WAAWA;QAAWC,WAAWA;QAAW2D,MAAMxC;;AAI3E,EAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./translation-schema.json",
|
|
3
|
-
"plugin-seo": {
|
|
4
|
-
"almostThere": "Almost there",
|
|
5
|
-
"autoGenerate": "Auto-generate",
|
|
6
|
-
"bestPractices": "best practices",
|
|
7
|
-
"characterCount": "{{current}}/{{minLength}}-{{maxLength}} chars, ",
|
|
8
|
-
"charactersLeftOver": "{{characters}} left over",
|
|
9
|
-
"charactersToGo": "{{characters}} to go",
|
|
10
|
-
"charactersTooMany": "{{characters}} too many",
|
|
11
|
-
"checksPassing": "{{current}}/{{max}} checks are passing",
|
|
12
|
-
"good": "Good",
|
|
13
|
-
"imageAutoGenerationTip": "Auto-generation will retrieve the selected hero image.",
|
|
14
|
-
"lengthTipDescription": "This should be between {{minLength}} and {{maxLength}} characters. For help in writing quality meta descriptions, see ",
|
|
15
|
-
"lengthTipTitle": "This should be between {{minLength}} and {{maxLength}} characters. For help in writing quality meta titles, see ",
|
|
16
|
-
"noImage": "No image",
|
|
17
|
-
"preview": "Preview",
|
|
18
|
-
"previewDescription": "Exact result listings may vary based on content and search relevancy.",
|
|
19
|
-
"tooLong": "Too long",
|
|
20
|
-
"tooShort": "Too short"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./translation-schema.json",
|
|
3
|
-
"plugin-seo": {
|
|
4
|
-
"almostThere": "Ya casi está",
|
|
5
|
-
"autoGenerate": "Autogénerar",
|
|
6
|
-
"bestPractices": "mejores prácticas",
|
|
7
|
-
"characterCount": "{{current}}/{{minLength}}-{{maxLength}} letras, ",
|
|
8
|
-
"charactersLeftOver": "{{characters}} letras sobrantes",
|
|
9
|
-
"charactersToGo": "{{characters}} letras sobrantes",
|
|
10
|
-
"charactersTooMany": "{{characters}} letras demasiados",
|
|
11
|
-
"checksPassing": "{{current}}/{{max}} las comprobaciones están pasando",
|
|
12
|
-
"good": "Bien",
|
|
13
|
-
"imageAutoGenerationTip": "La autogeneración recuperará la imagen de héroe seleccionada.",
|
|
14
|
-
"lengthTipDescription": "Esto debe estar entre {{minLength}} y {{maxLength}} caracteres. Para obtener ayuda sobre cómo escribir meta descripciones de calidad, consulte ",
|
|
15
|
-
"lengthTipTitle": "Debe tener entre {{minLength}} y {{maxLength}} caracteres. Para obtener ayuda sobre cómo escribir metatítulos de calidad, consulte ",
|
|
16
|
-
"noImage": "Sin imagen",
|
|
17
|
-
"preview": "Vista previa",
|
|
18
|
-
"previewDescription": "Las listas de resultados pueden variar segun la relevancia de buesqueda y el contenido.",
|
|
19
|
-
"tooLong": "Demasiado largo",
|
|
20
|
-
"tooShort": "Demasiado corto"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./translation-schema.json",
|
|
3
|
-
"plugin-seo": {
|
|
4
|
-
"almostThere": "چیزیی باقی نمونده",
|
|
5
|
-
"autoGenerate": "تولید خودکار",
|
|
6
|
-
"bestPractices": "آموزش بیشتر",
|
|
7
|
-
"characterCount": "{{current}}/{{minLength}}-{{maxLength}} کلمه، ",
|
|
8
|
-
"charactersLeftOver": "{{characters}} باقی مانده",
|
|
9
|
-
"charactersToGo": "{{characters}} باقی مانده",
|
|
10
|
-
"charactersTooMany": "{{characters}} بیش از حد",
|
|
11
|
-
"checksPassing": "{{current}}/{{max}} بررسیها با موفقیت انجام شده است",
|
|
12
|
-
"good": "خوب",
|
|
13
|
-
"imageAutoGenerationTip": "این قابلیت، تصویر فعلی بارگذاری شده در مجموعه محتوای شما را بازیابی میکند",
|
|
14
|
-
"lengthTipDescription": "این باید بین {{minLength}} و {{maxLength}} کلمه باشد. برای کمک در نوشتن توضیحات متا با کیفیت، مراجعه کنید به ",
|
|
15
|
-
"lengthTipTitle": "این باید بین {{minLength}} و {{maxLength}} کلمه باشد. برای کمک در نوشتن عناوین متا با کیفیت، مراجعه کنید به ",
|
|
16
|
-
"noImage": "بدون تصویر",
|
|
17
|
-
"preview": "پیشنمایش",
|
|
18
|
-
"previewDescription": "فهرست نتایج ممکن است بر اساس محتوا و متناسب با کلمه کلیدی جستجو شده باشند",
|
|
19
|
-
"tooLong": "خیلی طولانی",
|
|
20
|
-
"tooShort": "خیلی کوتاه"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./translation-schema.json",
|
|
3
|
-
"plugin-seo": {
|
|
4
|
-
"almostThere": "On y est presque",
|
|
5
|
-
"autoGenerate": "Auto-générer",
|
|
6
|
-
"bestPractices": "bonnes pratiques",
|
|
7
|
-
"characterCount": "{{current}}/{{minLength}}-{{maxLength}} caractères, ",
|
|
8
|
-
"charactersLeftOver": "{{characters}} restants",
|
|
9
|
-
"charactersToGo": "{{characters}} à ajouter",
|
|
10
|
-
"charactersTooMany": "{{characters}} en trop",
|
|
11
|
-
"checksPassing": "{{current}}/{{max}} vérifications réussies",
|
|
12
|
-
"good": "Bien",
|
|
13
|
-
"imageAutoGenerationTip": "L'auto-génération récupérera l'image principale sélectionnée.",
|
|
14
|
-
"lengthTipDescription": "Ceci devrait contenir entre {{minLength}} et {{maxLength}} caractères. Pour obtenir de l'aide pour rédiger des descriptions meta de qualité, consultez les ",
|
|
15
|
-
"lengthTipTitle": "Ceci devrait contenir entre {{minLength}} et {{maxLength}} caractères. Pour obtenir de l'aide pour rédiger des titres meta de qualité, consultez les ",
|
|
16
|
-
"noImage": "Pas d'image",
|
|
17
|
-
"preview": "Aperçu",
|
|
18
|
-
"previewDescription": "Les résultats exacts peuvent varier en fonction du contenu et de la pertinence de la recherche.",
|
|
19
|
-
"tooLong": "Trop long",
|
|
20
|
-
"tooShort": "Trop court"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./translation-schema.json",
|
|
3
|
-
"plugin-seo": {
|
|
4
|
-
"almostThere": "Prawie gotowe",
|
|
5
|
-
"autoGenerate": "Wygeneruj automatycznie",
|
|
6
|
-
"bestPractices": "najlepsze praktyki",
|
|
7
|
-
"characterCount": "{{current}}/{{minLength}}-{{maxLength}} znaków, ",
|
|
8
|
-
"charactersLeftOver": "zostało {{characters}} znaków",
|
|
9
|
-
"charactersToGo": "pozostało {{characters}} znaków",
|
|
10
|
-
"charactersTooMany": "{{characters}} znaków za dużo",
|
|
11
|
-
"checksPassing": "{{current}}/{{max}} testów zakończonych pomyślnie",
|
|
12
|
-
"good": "Dobrze",
|
|
13
|
-
"imageAutoGenerationTip": "Automatyczne generowanie pobierze wybrany główny obraz.",
|
|
14
|
-
"lengthTipDescription": "Długość powinna wynosić od {{minLength}} do {{maxLength}} znaków. Po porady dotyczące pisania wysokiej jakości meta opisów zobacz ",
|
|
15
|
-
"lengthTipTitle": "Długość powinna wynosić od {{minLength}} do {{maxLength}} znaków. Po porady dotyczące pisania wysokiej jakości meta tytułów zobacz ",
|
|
16
|
-
"noImage": "Brak obrazu",
|
|
17
|
-
"preview": "Podgląd",
|
|
18
|
-
"previewDescription": "Dokładne wyniki listowania mogą się różnić w zależności od treści i zgodności z kryteriami wyszukiwania.",
|
|
19
|
-
"tooLong": "Zbyt długie",
|
|
20
|
-
"tooShort": "Zbyt krótkie"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./translation-schema.json",
|
|
3
|
-
"plugin-seo": {
|
|
4
|
-
"almostThere": "Ще трошки",
|
|
5
|
-
"autoGenerate": "Згенерувати",
|
|
6
|
-
"bestPractices": "найкращі практики",
|
|
7
|
-
"characterCount": "{{current}}/{{minLength}}-{{maxLength}} символів, ",
|
|
8
|
-
"charactersLeftOver": "залишилось {{characters}} символів",
|
|
9
|
-
"charactersToGo": " на {{characters}} символів коротше",
|
|
10
|
-
"charactersTooMany": "на {{characters}} символів довше",
|
|
11
|
-
"checksPassing": "{{current}}/{{max}} перевірок пройдено",
|
|
12
|
-
"good": "Чудово",
|
|
13
|
-
"imageAutoGenerationTip": "Автоматична генерація використає зображення з головного блоку",
|
|
14
|
-
"lengthTipDescription": "Має бути від {{minLength}} до {{maxLength}} символів. Щоб дізнатися, як писати якісні метаописи — перегляньте ",
|
|
15
|
-
"lengthTipTitle": "Має бути від {{minLength}} до {{maxLength}} символів. Щоб дізнатися, як писати якісні метазаголовки — перегляньте ",
|
|
16
|
-
"noImage": "Немає зображення",
|
|
17
|
-
"preview": "Попередній перегляд",
|
|
18
|
-
"previewDescription": "Реальне відображення може відрізнятися в залежності від вмісту та релевантності пошуку.",
|
|
19
|
-
"tooLong": "Задовгий",
|
|
20
|
-
"tooShort": "Закороткий"
|
|
21
|
-
}
|
|
22
|
-
}
|
package/dist/ui/Overview.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Overview.d.ts","sourceRoot":"","sources":["../../src/ui/Overview.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAS/D,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAoD5B,CAAA"}
|