Skip to content

🐛 BUG: Component in Markdown not recognised #2474

@delucis

Description

@delucis

What version of astro are you using?

0.22.18

Edit: Also reproduced with v0.23.2

Edit: Also reproduced with v0.24.3

What package manager are you using?

npm (8.1.2)

What operating system are you using?

macOS 12.1

Describe the Bug

In an Astro component we can import a map of components (for frameworks that support this kind of thing like React/Preact) and then use them by accessing properties of the object:

index.astro

---
import Components from './some-(p)react-components';
---

<Components.Button>Click me!</Components.Button>

If we do the same thing in a Markdown file, the component doesn’t seem to get picked up and it just renders plain text.

index.md

---
setup: |
  import Components from './some-(p)react-components';
---

<Components.Button>Click me!</Components.Button>

The reproduction link demonstrates this — the index page is a .astro page and renders <Components.RedP> as expected. The linked /markdown route is a .md page and fails to render the component, treating it as ordinary text content.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-vzflqt?file=src/pages/markdown.md

Metadata

Metadata

Assignees

Labels

- P3: minor bugAn edge case that only affects very specific usage (priority)feat: markdownRelated to Markdown (scope)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions