Closed jesper-bylund closed 6 months ago
The reproduction project does not include a package.json. Does it need to be updated?
Hello @jesper-bylund. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro
will be closed if they have no activity within 3 days.
I don't know how that's even possible. I had serious problems setting up the StackBlitz project. For some reason it would not allow me to switch repo branches. 🤔 Looking into it...
https://github.com/jesper-bylund/stoutempire/tree/astro would be your minimal reproduction, by default stackblitz goes to the default branch.
can you remove the node_modules
from the astro branch so that it is not huge branch to clone?
Updated with a new repo that is clearer: https://stackblitz.com/edit/withastro-astro-dlftag?file=README.md
Hey @jesper-bylund,
In your reproduction, the post
is not found per the error message.
Update the [...slug].astro
with const {post} = Astro.props
and it'd work instead.
So two things that has fixed it:
[...slug].astro
with the following code:---
import { type CollectionEntry, getCollection } from 'astro:content';
import BlogPost from '../../layouts/BlogPost.astro';
export async function getStaticPaths() {
const posts = await getCollection('blog');
return posts.map((post) => ({
params: { slug: post.slug },
props: {post},
}))
}
type Props = CollectionEntry<'blog'>;
const {post} = Astro.props;
const {Content} = await post.render()
---
<BlogPost {...post.data}>
<Content />
</BlogPost>
---
- layout: post
title: Tripel De Garre
brewer: Brouwerij Van Steenberge
venue: Delirium Café Lisboa
reviewer: Agnes Haverling
pubDate: 2024-04-01
---
Best belgian ever?? I think so ⭐️⭐️⭐️⭐️⭐️
High ABV creating an amazing fullness, loads of banana bread 🍌🍞🥃, and almost a little bit of peach (?) but not too fruity. You must try it if you have the chance 🙌
# rest of your content
This is necessary as the layout -> post is not found in your application.
and this works!
Thank you very much! It was indeed the layout front matter. The only improvement I can think of is if the error states "layout post is missing". But I'm not sure how feasible that is.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
Safari
Describe the Bug
I'm rendering a collection of beer reviews, but the post content cannot be rendered.
Using a classic setup for rendering:
Results in the following error, which is hard for me to parse. The file is there. The content in the file is not causing the issue (removed it without change). Cannot trace the "module 'post'" reference.
What's the expected result?
Should render.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-dlftag
Participation