I'm new to Next.js so I created a simple news website so I can read an article by using this route:
/[category]/[article]
This is the structure of pages:
_pages
__[category]
____index.jsx
____[...all].jsx
This is [...all].jsx:
export default function Article() {
const router = useRouter();
const { category, all } = router.query;
return (
<>
{category}/{all[0]}
</>
);
}
But when I added this getStaticProps and getStaticPaths, I started getting 404:
export async function getStaticPaths() {
return {
paths: [],
fallback: false,
};
}
export async function getStaticProps({ params }) {
return { props: { params } };
}
I was looking everywhere online for a simple example for a nested dynamic routing with getStaticProps. For some reasons the official docs skip on that. How can I fix it?