Next.js Discord

Discord Forum

Any way to use generateMetadata with generateStaticParams?

Unanswered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
I'm trying to set the metadata of my generated pages according to the data coming from the CMS. This is the code I have to generate the static sites:
export const generateStaticParams = async () => {
  const { items } = await client.getEntries({ content_type: "landingPage" });
  return items.map((article) => ({
    slug: article.fields.slug?.toString(),
  }));
};

This is how I grab that data:
  const { items } = await client.getEntries({
    content_type: "landingPage",
    "fields.slug": params?.slug,
  });

Is there any way for me to hook into this rather than trying to fetch the same data again?

0 Replies