Estoy trabajando en el proyecto de un cliente con NextJs, en la sección del blog tenemos diferentes rutas, blog/[:category] , blog/[:category]/[:post] y blog/author/[:author] Y para obtener hecho esto, estoy usando getStaticPaths y getStaticProps .
Primero busco todas las publicaciones y autores de ContentfulAPI y luego hago un bucle en ellos para crear una ruta válida para pasarla a la matriz de rutas.
PD: Funciona cuando codifico cada ruta individualmente.
esa es mi función:
export const getStaticPaths = async () => { const posts = await DataController.getEntriesByContentType( "componentBlog", ); const blogPosts = posts.items.map(item => { return {params: {blog_post: [item.fields.category.replace(/\s+/g, '-').replace(/'/g, '').toLowerCase(), item.fields.slug]}} }) const authors = await DataController.getEntriesByContentType( "author", ); const authorPaths = authors.items.map(item => { return {params: {blog_post: ['author', item.fields.slug]}} }) return { paths: [ blogPosts, authorPaths, ], fallback: false, } }Y recibo este error cuando intento acceder a un enlace de blog:
error - Error: Additional keys were returned from `getStaticPaths` in page "/blog/[...blog_post]". URL Parameters intended for this dynamic route must be nested under the `params` key, ie: return { params: { blog_post: ... } } Keys that need to be moved: 0, 1, 2, 3, 4, 5, 6, 7, 8. at C:\Workspace\phoenix-v2\next\new-phoenix\node_modules\next\dist\build\utils.js:518:23 at Array.forEach (<anonymous>) at Object.buildStaticPaths (C:\Workspace\phoenix-v2\next\new-phoenix\node_modules\next\dist\build\utils.js:492:17) at processTicksAndRejections (internal/process/task_queues.js:95:5) { type: 'Error', page: '/blog/[...blog_post]' }No estoy seguro de por qué me encuentro con este error... ¡gracias por ayudar!