I've got a content collection named 'blog'. When I run my website locally with astro dev, the routes generated by my [...slug].astro exist and I can view those pages. However, when I run astro build, those routes aren't generated.
After a little testing, I've found that components that call getCollection (as in the below code) get results and are rendered correctly.
const featuredBlogPosts = await getCollection(
'blog',
(entry) => entry.data.featured && entry.data.featured > 0
)
But the getCollection within getStaticPaths is returning no entries. Oddly, it does return entities for a separate data collection.
export async function getStaticPaths() {
const blogEntries = await getCollection('blog')
const gearEntries = await getCollection('gear')
console.log(`Found ${blogEntries.length} blog entries`)
console.log(`Found ${gearEntries.length} gear entries`)
return blogEntries.map((entry) => ({
params: { slug: entry.slug },
props: { post: entry },
}))
}
The console.log's in the getStaticPaths above generate:
▶ src/pages/blog/[...slug].astro
Found 0 blog entries
Found 6 gear entries