#Images not optimized at build

4 messages · Page 1 of 1 (latest)

raw hazel
#

I have a card component which gets the image src as a prop like this:

---
import { Image } from "astro:assets";
const { frontmatter, url } = Astro.props;
const { title, date, description, author, image } = frontmatter;
---
<Image
    src={image.src}
    alt={image.alt}
    class="aspect-[5/3] h-auto w-full rounded-t-3xl object-cover"
    format="avif"
    quality="max"
    height="300"
    width="300"
  />

But on the build version there's no optimized image in the dist folder, and neither the img tag gets the url of the optimized image. What am I doing wrong?

#

image.src gives something like "/src/assets/photo.jpg

#

This is the content of /src/content/config.ts, just in case if it's relevant:

const blog = defineCollection({
  type: "content",
  schema: z.object({
    title: z
      .string()
      .max(
        40,
        "For optimum styling, please keep the title under 40 characters"
      ),
    author: z.string(),
    date: z.date(),
    description: z
      .string()
      .max(
        90,
        "For optimum styling, please keep the description under 80 characters"
      ),
    image: z.object({
      src: z.string(),
      alt: z.string(),
    }),
  }),
});
crimson remnant