Imported local image is not being imported?
Hey everyone, I'm having trouble using the <Image> component from Astro when it is getting imported from a markdown file through the image() schema helper. I want to use a image from the frontmatter of a .md file in the layout.astro file. The src keeps on giving me errors, even though the image IS being imported just like described.
I have attached the error and the line that's giving me trouble + wrote the code below (omitted the lines which should not matter at all)
In my markdown (.md) file:
cover: "./unit.png"
---```
**My Layout.astro file:**
```---
import BaseLayout from "./BaseLayout.astro";
import type { CollectionEntry } from "astro:content";
import { Image } from "astro:assets";
import TableOfContentsList from "../components/TableOfContents/TableOfContentsList.astro";
import { generateToC } from "../components/TableOfContents/generateToC";
interface Props {
post: CollectionEntry<"chapters">;
}
const { post } = Astro.props;
const { headings } = await post.render();
const { remarkPluginFrontmatter } = await post.render();
---
<BaseLayout title={post.data.title}>
<div class="center-container">
<Image
src={post.data.cover.src}
alt={post.data.coverAlt}
class="cover-image"
width={1600}
height={900}
/>
</div>
</BaseLayout>```
**My config.ts:**
```const chapterCollection = defineCollection({
type: 'content',
schema: ({ image }) => z.object({
title: z.string(),
cover: image()
.refine((img) => img.width = 1600, {
message: "Cover image must be 1600 pixel wide!",
})
.refine((img) => img.height = 900, {
message: "Cover image must be 900 pixel high!",
}),
coverAlt: z.string(),
})
});```