#The error message indicates that the frontmatter in my blog post file does not match the schema defi
1 messages · Page 1 of 1 (latest)
Based on the error message and the schema you provided, it seems like the authorImage and cardImage fields are expected to be of type "string", but an "object" was received instead. Also, the authorImageAlt and cardImageAlt fields are required but missing.
In your schema, you have defined authorImage and cardImage with image(), which is not a standard Zod method and might be causing the issue. If image() is a custom function that returns an object, it would explain why an object is being received instead of a string.
To fix this, you should ensure that authorImage and cardImage are strings representing the image URLs. If you want to store more information about the images, you could use z.object() to define a schema for the image fields. For example:
const blogCollection = defineCollection({
type: "content",
schema: z.object({
title: z.string(),
description: z.string(),
contents: z.array(z.string()),
author: z.string(),
role: z.string().optional(),
authorImage: z.object({
url: z.string(),
alt: z.string(),
}),
pubDate: z.date(),
cardImage: z.object({
url: z.string(),
alt: z.string(),
}),
readTime: z.number(),
tags: z.array(z.string()).optional(),
}),
});
In this example, authorImage and cardImage are objects with url and alt fields, both of which are strings. This allows you to store the image URL and alt text for each image.
Remember to run npx astro sync after updating your schema to ensure that Astro recognizes your changes (source (https://docs.astro.build/en/tutorials/add-content-collections#create-a-collection-for-your-blog-posts)).
Also, ensure that all your blog post files include the authorImageAlt and cardImageAlt fields in their frontmatter, as these fields are required according to your schema (source (https://docs.astro.build/en/reference/errors/invalid-content-entry-frontmatter-error#_top)).
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@fluid axle kapa.ai is still learning and improving, please let us know how it did by reacting below
Let me check the knowledge base for you. One moment! :books:
Sorry @fluid axle, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?