Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ Issue Sample code for 'Building for static output (default)' throws a "Property 'render' does not exist on type 'never'" #7035

Open
angyan opened this issue Feb 25, 2024 · 1 comment
Labels
help - confirm behaviour Walk through the example/issue and confirm this is a general behaviour, or a correct update to make.

Comments

@angyan
Copy link

angyan commented Feb 25, 2024

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 />

@sarah11918 sarah11918 added the help - confirm behaviour Walk through the example/issue and confirm this is a general behaviour, or a correct update to make. label Feb 27, 2024
@mingjunlu
Copy link
Contributor

mingjunlu commented Feb 28, 2024

I couldn't reproduce this somehow. Would it be possible for you to provide a minimal reproduction example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help - confirm behaviour Walk through the example/issue and confirm this is a general behaviour, or a correct update to make.
Projects
None yet
Development

No branches or pull requests

3 participants