generateStaticParams adding characters to my slug
Unanswered
Common Poorwill posted this in #help-forum
Common PoorwillOP
Hi folks, I'm trying to use dynamic pages in Next.js 13 with app router. This is my folder structure:
On
The problem is I'm getting characters added to my slug, like this:
while I would like to have something like this:
Any hints very welcomed!!!!
- app
-shows
- [slug]
- page.tsxOn
page.tsx I want to generateStaticParams, and use the slug to find elements in my database, this is what I have: export async function generateStaticParams() {
const data = await getData("shows")
const shows = data.content
return shows.map((show) => ({
slug: show.slug,
}))
}
export default async function ShowRoute({params}: {params: {slug: string}}) {
const shows = await getShows(shows)
const show = shows.find((show) => show.slug === params.slug )
if (!show){
notFound()
}
return (
<section>
<h1>Shows</h1>
<h2>{show.slug}</h2>
</section>
)
}The problem is I'm getting characters added to my slug, like this:
My%20show%20slug,while I would like to have something like this:
My-show-slugAny hints very welcomed!!!!