-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Closed
Labels
- P2: has workaroundAn edge case that only affects very specific usage, but has a trivial workaround (priority)An edge case that only affects very specific usage, but has a trivial workaround (priority)feat: content collectionsRelated to the Content Collections feature (scope)Related to the Content Collections feature (scope)
Description
Astro Info
Astro v5.14.1
Vite v6.3.6
Node v24.7.0
System Windows (x64)
Package Manager pnpm
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
The image() helper in the Content Collection schema is not resolving images that have relative path without ./ only in json files. It works when the content is in .md frontmatter
content.config.ts
const md = defineCollection({
loader: glob({ base: 'content/md', pattern: '**/*.md' }),
schema: ({ image }) =>
z.object({
title: z.string(),
cover: image().optional(),
}),
});
const json = defineCollection({
loader: glob({ base: 'content/json', pattern: '**/*.json' }),
schema: ({ image }) =>
z.object({
title: z.string(),
cover: image().optional(),
}),
});index.json
{
"title": "Second Post JSON",
"cover": "cover2.jpg",
"_content": "This is the content of the second post in JSON format."
}index.md
---
title: "First Post Markdown"
cover: "cover1.jpg"
---
This is the content of the first post in Markdown format.What's the expected result?
Relative paths to resolve uniformly.
Link to Minimal Reproducible Example
Participation
- I am willing to submit a pull request for this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- P2: has workaroundAn edge case that only affects very specific usage, but has a trivial workaround (priority)An edge case that only affects very specific usage, but has a trivial workaround (priority)feat: content collectionsRelated to the Content Collections feature (scope)Related to the Content Collections feature (scope)