Decap CMS with Astro and Netlify build error

site name: https://astro-test-rob.netlify.app/

it says I exceed the char limit if I post the netlify build log

Hi,
So I’m trying to setup Decap with my Astro site and I can’t get the Netlify Build to process (and locally) for images in blog posts.

thanks

But the build process fails. Below is my config.ts and config.yml files:

config.yml:

backend:
name: git-gateway
branch: main # Branch to update (optional; defaults to master)

media_folder: “public/images” # Location where files will be stored in the repo
public_folder: “/images/uploads” # The src attribute for uploaded media

collections:

  • name: ‘post’
    label: ‘Post’
    folder: ‘src/content/blog’
    create: true
    fields:
    • { label: ‘Title’, name: ‘title’, widget: ‘string’ }
    • { label: ‘Excerpt’, name: ‘excerpt’, widget: ‘string’ }
    • { label: ‘Category’, name: ‘category’, widget: ‘string’ }
    • {
      label: ‘Tags’,
      name: ‘tags’,
      widget: ‘list’,
      allow_add: true,
      allow_delete: true,
      collapsed: false,
      field: { label: ‘Tag’, name: ‘tag’, widget: ‘string’ },
      }
    • { label: “Featured Image”, name: “image”, widget: “image”,
      fields: { label: “url”, name: “src”, widget: “string” },
      { label: “Alt Text”, name: “alt”, widget: “string” }
      }
    • { label: ‘Publish Date’, name: ‘publishDate’, widget: ‘datetime’, required: false }
    • { label: ‘Author’, name: ‘author’, widget: ‘string’ }
    • { label: ‘Content’, name: ‘body’, widget: ‘markdown’ }

config.ts:
const metadataDefinition = () =>
z
.object({
title: z.string().optional(),
ignoreTitleTemplate: z.boolean().optional(),

  canonical: z.string().url().optional(),

  robots: z
    .object({
      index: z.boolean().optional(),
      follow: z.boolean().optional(),
    })
    .optional(),

  description: z.string().optional(),

  openGraph: z
    .object({
      url: z.string().optional(),
      siteName: z.string().optional(),
      images: z
        .array(
          z.object({
            url: z.string(),
            width: z.number().optional(),
            height: z.number().optional(),
          })
        )
        .optional(),
      locale: z.string().optional(),
      type: z.string().optional(),
    })
    .optional(),

  twitter: z
    .object({
      handle: z.string().optional(),
      site: z.string().optional(),
      cardType: z.string().optional(),
    })
    .optional(),
})
.optional();

const postCollection = defineCollection({
schema: z.object({
publishDate: z.date().optional(),
updateDate: z.date().optional(),
draft: z.boolean().optional(),

title: z.string(),
excerpt: z.string().optional(),
image: z.string().optional(),

category: z.string().optional(),
tags: z.array(z.string()).optional(),
author: z.string().optional(),

metadata: metadataDefinition(),

}),
});

export const collections = {
post: postCollection,
};

In DECAP CMS, the src and alt fields don’t appear so I can’t type them in.

@Roblou2 What is the error shown in the build log?

Hi Nathan,

thanks for your reply.

The error is:

blog/index.html[ExpectedImage] Expected src property for getImage or <Image /> to be either an ESM imported image or a string with the path of a remote image. Received undefined (type: undefined).

Error reference:
9:36:51 PM: Expected src to be an image. | Docs
9:36:51 PM: Stack trace:
9:36:51 PM: at getImage$1 (file:///opt/build/repo/dist/chunks/astro_assets_C0FgXj-.mjs:865:11)
9:36:51 PM: at file:///opt/build/repo/dist/chunks/astro_assets_C0FgXj-.mjs:980:31
9:36:51 PM: at file:///opt/build/repo/dist/chunks/astro_assets_C0FgXj-.mjs:979:13
9:36:51 PM: ​
9:36:51 PM: “build.command” failed

I know that the component doesn’t have the src attribute because there’s no where in Decap CMS for me to write it. So, my guess is that the error is in the config.yml or config.ts file but I can’t work out what it is.

I’ve fixed it. For anyone who runs into the same issue, it was the syntax in my config.yml file! Check it in VScode and with the Red Hat debugger

hi @Roblou2 :wave:t6: happy to hear you found your solution! thanks for writing back in that you found your solution.