Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images in Content Collections are not worked in Astro v5 #12772

Open
1 task
psephopaiktes opened this issue Dec 18, 2024 · 0 comments
Open
1 task

Images in Content Collections are not worked in Astro v5 #12772

psephopaiktes opened this issue Dec 18, 2024 · 0 comments
Labels
needs triage Issue needs to be triaged

Comments

@psephopaiktes
Copy link

Astro Info

Astro                    v5.0.9
Node                     v20.12.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

From v5, I can no longer access images placed in the same folder as mdx files in Content Collections.

Here is the usage from the official documentation:

I have created a sample here.
https://github.com/psephopaiktes/astro-images-in-content-collections

Most of it remains the same as the official blog sample for each version, but I have changed the following files:

  • /src/content/config.ts (in v5, it's /src/content.config.ts)
  • Directory structure for blog images
  • Frontmatter of blog Markdown

In v4, it works fine as per the documentation, but in v5, the images either return a 404 error or the following error occurs:

A getStaticPaths() route pattern was matched, but no matching static path was found for requested path /blog/first-post/[object%20Object]

The reason I want this structure is that I want to place the images for each blog post in the same folder as the post mdx file.

Bad:

  • src/content/blog/first-post.md
  • src/public/img/first-post-cover.jpg

Good:

  • src/content/blog/first-post/index.md
  • src/content/blog/first-post/cover.md

What's the expected result?

Images placed in the same location as the .md file should be handled as Content Collections without errors.

If there is another solution to place images in the same folder, that would be OK to me.

Link to Minimal Reproducible Example

https://github.com/psephopaiktes/astro-images-in-content-collections

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant