docs
docs copied to clipboard
⚠️ Issue Sample code for 'Building for static output (default)' throws a "Property 'render' does not exist on type 'never'"
Proposed fix:
---
import { CollectionEntry, getCollection } from "astro:content";
// 1. Generate a new path for every collection entry
export async function getStaticPaths() {
const blogEntries = await getCollection("blog");
return blogEntries.map((entry) => ({
params: { slug: entry.slug },
props: { entry },
}));
}
// 2. For your template, you can get the entry directly from the prop
const { entry } = Astro.props as { entry: CollectionEntry<"blog"> };
const { Content } = await entry.render();
---
<h1>{entry.data.title}</h1>
<Content />
I couldn't reproduce this somehow. Would it be possible for you to provide a minimal reproduction example?
closing for inactivity and not reproducible