fix(plugin-seo): titles being displayed twice (#8310)

This commit is contained in:
Paul
2024-09-25 09:05:18 -06:00
committed by GitHub
parent c6519aba8a
commit 8fadc3391b
6 changed files with 31 additions and 9 deletions

View File

@@ -100,7 +100,13 @@ export const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props)
}} }}
> >
<div className="plugin-seo__field"> <div className="plugin-seo__field">
<FieldLabel field={null} Label={Label} label={label} {...(labelProps || {})} /> <FieldLabel
field={null}
Label={Label}
label={label}
required={required}
{...(labelProps || {})}
/>
{hasGenerateDescriptionFn && ( {hasGenerateDescriptionFn && (
<React.Fragment> <React.Fragment>
&nbsp; &mdash; &nbsp; &nbsp; &mdash; &nbsp;
@@ -151,7 +157,6 @@ export const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props)
Component: null, Component: null,
RenderedComponent: errorMessage, RenderedComponent: errorMessage,
}} }}
label={label}
onChange={setValue} onChange={setValue}
path={pathFromContext} path={pathFromContext}
required={required} required={required}

View File

@@ -102,7 +102,13 @@ export const MetaImageComponent: React.FC<MetaImageProps> = (props) => {
}} }}
> >
<div className="plugin-seo__field"> <div className="plugin-seo__field">
<FieldLabel field={null} Label={Label} label={label} {...(labelProps || {})} /> <FieldLabel
field={null}
Label={Label}
label={label}
required={required}
{...(labelProps || {})}
/>
{hasGenerateImageFn && ( {hasGenerateImageFn && (
<React.Fragment> <React.Fragment>
&nbsp; &mdash; &nbsp; &nbsp; &mdash; &nbsp;
@@ -151,7 +157,6 @@ export const MetaImageComponent: React.FC<MetaImageProps> = (props) => {
RenderedComponent: errorMessage, RenderedComponent: errorMessage,
}} }}
filterOptions={field.filterOptions} filterOptions={field.filterOptions}
label={undefined}
onChange={(incomingImage) => { onChange={(incomingImage) => {
if (incomingImage !== null) { if (incomingImage !== null) {
if (typeof incomingImage === 'object') { if (typeof incomingImage === 'object') {

View File

@@ -37,11 +37,11 @@ export const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {
label, label,
required, required,
}, },
field: fieldFromProps,
hasGenerateTitleFn, hasGenerateTitleFn,
labelProps, labelProps,
} = props || {} } = props || {}
const { path: pathFromContext } = useFieldProps() const { path: pathFromContext } = useFieldProps()
const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>() const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()
const field: FieldType<string> = useField({ const field: FieldType<string> = useField({
@@ -98,7 +98,13 @@ export const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {
}} }}
> >
<div className="plugin-seo__field"> <div className="plugin-seo__field">
<FieldLabel field={null} Label={Label} label={label} {...(labelProps || {})} /> <FieldLabel
field={fieldFromProps}
Label={Label}
label={label}
required={required}
{...(labelProps || {})}
/>
{hasGenerateTitleFn && ( {hasGenerateTitleFn && (
<React.Fragment> <React.Fragment>
&nbsp; &mdash; &nbsp; &nbsp; &mdash; &nbsp;
@@ -150,7 +156,6 @@ export const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {
Component: null, Component: null,
RenderedComponent: errorMessage, RenderedComponent: errorMessage,
}} }}
label={label}
onChange={setValue} onChange={setValue}
path={pathFromContext} path={pathFromContext}
required={required} required={required}

View File

@@ -78,7 +78,11 @@ export const PreviewComponent: React.FC<PreviewProps> = (props) => {
}, [fields, href, locale, docInfo, hasGenerateURLFn, getData]) }, [fields, href, locale, docInfo, hasGenerateURLFn, getData])
return ( return (
<div> <div
style={{
marginBottom: '20px',
}}
>
<div>{t('plugin-seo:preview')}</div> <div>{t('plugin-seo:preview')}</div>
<div <div
style={{ style={{

View File

@@ -28,7 +28,7 @@ export const seoPlugin =
OverviewField({}), OverviewField({}),
MetaTitleField({ MetaTitleField({
hasGenerateFn: typeof pluginConfig?.generateTitle === 'function', hasGenerateFn: typeof pluginConfig?.generateTitle === 'function',
overrides: pluginConfig?.fieldOverrides?.title as unknown as TextField, overrides: pluginConfig?.fieldOverrides?.title,
}), }),
MetaDescriptionField({ MetaDescriptionField({
hasGenerateFn: typeof pluginConfig?.generateDescription === 'function', hasGenerateFn: typeof pluginConfig?.generateDescription === 'function',

View File

@@ -65,6 +65,9 @@ export const PagesWithImportedFields: CollectionConfig = {
fields: [ fields: [
MetaTitleField({ MetaTitleField({
hasGenerateFn: true, hasGenerateFn: true,
overrides: {
required: true,
},
}), }),
PreviewField({ PreviewField({
hasGenerateFn: true, hasGenerateFn: true,