Skip to content

Local markdown/images using LoaderContect.renderMarkdown #14620

@abhijit-hota

Description

@abhijit-hota

Astro Info

Astro                    v5.15.1
Node                     v24.5.0
System                   macOS (arm64)
Package Manager          bun
Output                   static
Adapter                  none
Integrations             none

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

No response

Describe the Bug

Hello, all. I'm trying to implement a custom loader using the Object loader API.

The purpose is to split a single markdown file with multiple sections into different content entries.

https://github.com/abhijit-hota/astro-markdown-splitter/blob/main/src/loader.ts

While it works, it doesn't load images. (404 errors because of wrong path).

Image Image

How to fix this?

I've found that the renderMarkdown method is an @astrojs/markdown-remark wrapper which can have a renderOpts option passed with a fileURL but isn't doing so now.

So I've tried following what glob does. I imported the createMarkdownProcessor directly to pass a fileURL but it still doesn't work.

Relevant issue I found: #14205

What's the expected result?

renderMarkdown should support local markdown files, etc.

Link to Minimal Reproducible Example

https://github.com/abhijit-hota/astro-markdown-splitter

https://stackblitz.com/edit/github-tdyozzko?file=package.json (Stackblitz doesn't really work because of Bun. Will fix that.)

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P3: minor bugAn edge case that only affects very specific usage (priority)feat: content collectionsRelated to the Content Collections feature (scope)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions