withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!

Home Page:https://astro.build

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🐛 BUG: Component in Markdown not recognised

delucis opened this issue · comments

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

Confirmed. Excellent reproduction.

commented

I can confirm that this still happens on the latest version of Astro, I am not too sure where the issue comes from at the moment however as, I believe, we copy the import 1:1 into the generated file 🤔