#"Image not found" with an existing image

3 messages · Page 1 of 1 (latest)

restive stump
#

Hello there,
I'm trying to use the new content feature in v5.
I created my collection :

import { defineCollection, z } from 'astro:content';

import { glob } from 'astro/loaders';

const pagesCollection = defineCollection({
    loader: glob({ pattern: "**/*.md", base: "./src/content/pages" }),
    schema: ({ image }) => {
      const Hero = z.object({
        type: z.literal("hero"),
        title: z.string(),
        image: image(),
        text: z.string(),
        cta: z.object({
          target: z.boolean(),
          title: z.string(),
          link: z.string(),
        }).partial(),
      });
  
      return z.object({
        title: z.string(),
        content: z.array(z.discriminatedUnion("type", [
          Hero
        ])),
      });
    },
  });

export const collections = { pagesCollection };

here's my page created

---
title: Ma super page
content:
  - type: header
    title: Mon super hero
    text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer luctus
      non nisl in vestibulum. Suspendisse nisl arcu, rutrum sit amet auctor vel,
      rutrum viverra arcu. Maecenas dictum maximus ante, vestibulum suscipit
      lacus sodales ut. Mauris sit amet venenatis lectus, vitae rutrum neque. In
      euismod non massa eu malesuada
    cta:
      target: false
      title: Test
      link: test
    image: src/assets/content/images/site.jpg
---

When i'm trying to get it, an error pop : "Could not find requested image src/assets/content/images/site.jpg. Does it exist?"
and it actually exist, see capture.

Is there any config I missed ?
Thanks in advance,

#

I've also replaced the base tsconfig with the one provided in the content example

{
  // Inclus avec "astro/tsconfigs/strict" ou "astro/tsconfigs/strictest"
  "extends": "astro/tsconfigs/base",
  "compilerOptions": {
    "strictNullChecks": true, // ajouter si vous utilisez le modèle `base`
    "allowJs": true // requis et inclus avec tous les modèles Astro
  }
}
wide warren
#

Try enter relative path to content config, so "images/site.jpg". And I am not sure, but maybe the image should be inside the Content directory where you have the .md files.