I'm currently working on a Next.js app with Contentful as the CMS. The file structure relevant to my question is:
pages
-[category]
-[slug].js
My goal is to access the category value when a user visits category/slug. Currently, I have the category hardcoded. Is there a way for me to dynamically access the category using params?
const category = 'mains';
export async function getStaticPaths() {
let data = await client.getEntries({ content_type: category });
return {
paths: data.items.map((path) => ({
params: { category: category, slug: path.fields.slug }
})),
fallback: false
};
}