Next.js Discord

Discord Forum

Get name of page as title in generateMedatada

Unanswered
American Crocodile posted this in #help-forum
Open in Discord
American CrocodileOP
I'm trying to set the title for my generated pages, I get the name if each page from my CMS. But for some reason I can only see the slug in my generateMetadata. even though as far as I can see I should also see the name

export async function generateMetadata(
  { params }: Props,
  parent: ResolvingMetadata
): Promise<Metadata> {

 
  console.log("Params is:", params) // is only the slug 

  return {
    title: "Some title",
  }
}


// Return a list of `params` to populate the [slug] dynamic segment
export async function generateStaticParams() {
  const page = (await getAllServices()) as PageLinks;
  return page.allTjenester.edges.map((page) => ({
    slug: urlToSlug(page.node.url),
    name: page.node.name,
  })

Any ideas on what I could be doing wrong?

0 Replies