For a next.js pages directory that contains a bunch of static pages (not dynamic routes!)…
pages/
├── index.tsx
├── SomePage.tsx
├── someOtherPage
│ └── index.tsx
├── someOtherOtherPage
│ └── index.tsx
└── someOtherOtherOtherPage
└── index.tsx
…is it possible to create links at build time, rather than typing all out manually?
I.e.: not this:
// index.js
<ol>
<li>
<Link href="/somePage/">Some Page</Link>
</li>
<li>
<Link href="/someOtherPage/">Some Other Page</Link>
</li>
…
</ol>
…but something comparable to Gatsby's approach that uses Graphql nodes as location props:
// Example Gatsby.js page
const IndexPage = ({
data: {
allMarkdownRemark: { edges },
},
}) => {
const Posts = edges
.filter(edge => !!edge.node.frontmatter.date) // You can filter your posts based on some criteria
.map(edge => <PostLink key={edge.node.id} post={edge.node} />)
return <div>{Posts}</div>
}