strapi-plugin-seo
strapi-plugin-seo copied to clipboard
Feature Request: make plugin work with dynamic zones
Please make option that plugin works with dynamic zones not only components.
Im using dynamic zones to dynamically render components on frontend.
Replace code in RightLinksCompo>index.js
const SeoChecker = () => {
const { modifiedData } = useCMEditViewDataManager();
if (modifiedData.hasOwnProperty('seo')) {
return (
<Box
background="neutral0"
borderColor="neutral150"
hasRadius
paddingBottom={4}
paddingLeft={4}
paddingRight={4}
paddingTop={6}
shadow="tableShadow"
>
<Summary />
</Box>
);
}
return <></>;
};
export default SeoChecker;
with this, and you can have SEO working no matter if its in dynamic zone, in repeatable component or just component it self in collection type
const SeoChecker = () => {
const { modifiedData } = useCMEditViewDataManager();
let viewSEO = false;
for (let key in modifiedData) {
//console.log(modifiedData[key] instanceof Object)
if(modifiedData[key] instanceof Array){
modifiedData[key].forEach(data =>{
data.hasOwnProperty("metaTitle") ? viewSEO = true : ""
//data.hasOwnProperty("__component") && data.__component=="shared.seo"
})
}
else if(modifiedData[key] instanceof Object){
modifiedData[key].hasOwnProperty("metaTitle") ? viewSEO = true : ""
};
console.log(viewSEO)
}
if (viewSEO) {
return (
<Box
as="aside"
aria-labelledby="additional-informations"
background="neutral0"
borderColor="neutral150"
hasRadius
paddingBottom={4}
paddingLeft={4}
paddingRight={4}
paddingTop={6}
shadow="tableShadow"
>
<Summary />
</Box>
);
}
return <></>;
};
export default SeoChecker;
Hello @WardenCommander 👋
Thanks for the suggestion! Would you mind creating a Pull Request?
@Mcastres PR created
Is it logical that this component can be also repeatable? It should be restricted to a single component I think. @Mcastres What is the approach to this?
@SalahAdDin im using it inside dynamic zone, and on frontend I have dynamic component builder