Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: make plugin work with dynamic zones #29

Open
WardenCommander opened this issue Dec 28, 2022 · 5 comments
Open

Feature Request: make plugin work with dynamic zones #29

WardenCommander opened this issue Dec 28, 2022 · 5 comments

Comments

@WardenCommander
Copy link

Please make option that plugin works with dynamic zones not only components.

Im using dynamic zones to dynamically render components on frontend.

@WardenCommander WardenCommander changed the title Feature Request: make plugin work with dinamic zones Feature Request: make plugin work with dynamic zones Dec 28, 2022
@WardenCommander
Copy link
Author

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;

@Mcastres
Copy link
Collaborator

Hello @WardenCommander 👋

Thanks for the suggestion! Would you mind creating a Pull Request?

@WardenCommander
Copy link
Author

@Mcastres PR created

@SalahAdDin
Copy link

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?

@WardenCommander
Copy link
Author

@SalahAdDin im using it inside dynamic zone, and on frontend I have dynamic component builder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants