As someone new to Next.js, I decided to delve into creating a basic news website where I could access articles through this specific route:
/[category]/[article]
The directory structure of pages
is organized as follows:
_pages
__[category]
____index.jsx
____[...all].jsx
Shown here is the content of [...all].jsx
:
export default function Article() {
const router = useRouter();
const { category, all } = router.query;
return (
<>
{category}/{all[0]}
</>
);
}
However, after incorporating the getStaticProps
and getStaticPaths
methods, I encountered a consistent 404 error:
export async function getStaticPaths() {
return {
paths: [],
fallback: false,
};
}
export async function getStaticProps({ params }) {
return { props: { params } };
}
In my search for a straightforward example of nested dynamic routing with getStaticProps
, I found that the official documentation lacked sufficient coverage on this topic. Can anyone provide guidance on how to resolve this issue?