the-happy-programmer / the-happy-programmer-nextjs

Programming Courses
https://thehappyprogrammer.com/
1 stars 1 forks source link

generateStaticParams lower case #34

Closed MyNameIsBond closed 9 months ago

MyNameIsBond commented 9 months ago

on build there is an issue with

export async function generateStaticParams() {
  const authors = getAllAuthors();
  console.log(authors);
  return authors.map((auth) => ({ slug: auth }));
}

on /author/[name]

the author names should be in lower case.

MyNameIsBond commented 9 months ago

I did


export async function generateStaticParams() {
  const authors = getAllAuthors()
  const lowercaseAthorNames = Array.from(authors, (name) => name.toLowerCase())

  return lowercaseAthorNames.map((auth) => ({ slug: auth }))
}

which seemed to solve the problem.