Currently, I am dynamically rendering a list of posts using next/router. Each post in this list contains the index, path, and title:
export const items = [
{
id: "0",
path: 'Post_Alpha',
title: "Title example 0",
},
{
id: "1",
path: 'Post_Beta',
title: "Title example 1",
},
To access the post beta by its index in the array, you can use the following code:
import {items} from '../posts/data'
function Posts() {
const router = useRouter()
const {post} = router.query
const postIndex = items.map(function(e) { return e.path; }).indexOf(post)
const post = items[courseIndex]
return (
<h2>
{post.title}
</h2>
)
}
export default Posts
I am curious if Next.js generates a separate page for each post or if it only creates one page that is dynamically filled. I also have a list of links that utilize <Link /> from 'next/link'
to navigate to each post. Additionally, how can I view the pages that Next.js generates, similar to viewing the sitemap.xml of a website?