The code you've provided seems to be correct in terms of how you're using the getEntry function to retrieve a specific entry from the writing collection using the slug from the request parameters.
However, the issue might be with how you're using the BlogPost component. In Astro, components are invoked using an HTML-like syntax, not like a function call.
Here's how you might want to adjust your code:
---
import BlogPost from '../../components/BlogPost';
import { getEntry } from "astro:content";
const { slug } = Astro.params;
if (slug === undefined) {
throw new Error("Slug is required");
}
const entry = await getEntry("writing", slug);
if (entry === undefined) {
return Astro.redirect("/404");
}
---
<html>
<head>
<title>{entry.data.title}</title>
</head>
<body>
<BlogPost title={entry.data.title} paragraphs={entry.data.paragraphs} />
</body>
</html>
In this adjusted code, the BlogPost component is invoked as an HTML-like element, with title and paragraphs passed as props. Make sure your BlogPost component is set up to receive and handle these props correctly.
If you're still encountering issues, it might be helpful to check the Astro documentation (https://docs.astro.build/) or the Astro GitHub issues (https://github.com/withastro/astro/issues) for further assistance.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: