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

🐛 BUG: Component in Markdown not recognised #2474

Closed
delucis opened this issue Jan 26, 2022 · 2 comments · Fixed by #3410
Closed

🐛 BUG: Component in Markdown not recognised #2474

delucis opened this issue Jan 26, 2022 · 2 comments · Fixed by #3410
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: markdown Related to Markdown (scope)

Comments

@delucis
Copy link
Member

delucis commented Jan 26, 2022

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

@jonathantneal
Copy link
Contributor

Confirmed. Excellent reproduction.

@Princesseuh Princesseuh added feat: markdown Related to Markdown (scope) - P3: minor bug An edge case that only affects very specific usage (priority) s1-small and removed bb:investigate labels May 10, 2022
@Princesseuh
Copy link
Member

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 🤔

@natemoo-re natemoo-re linked a pull request May 19, 2022 that will close this issue
natemoo-re added a commit that referenced this issue May 24, 2022
* feat: use internal MDX tooling for markdown + components

* fix: improve MD + component tests

* chore: add changeset

* fix: make tsc happy

* fix(#3319): add regression test for component children

* fix(markdown): support HTML comments in markdown

* fix(#2474): ensure namespaced components are properly handled in markdown pages

* fix(#3220): ensure html in markdown pages does not have extra surrounding space

* fix(#3264): ensure that remark files pass in file information

* fix(#3254): enable experimentalStaticExtraction for `.md` pages

* fix: revert parsing change

* fix: remove `markdown.mode` option
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this issue Feb 3, 2023
* feat: use internal MDX tooling for markdown + components

* fix: improve MD + component tests

* chore: add changeset

* fix: make tsc happy

* fix(withastro#3319): add regression test for component children

* fix(markdown): support HTML comments in markdown

* fix(withastro#2474): ensure namespaced components are properly handled in markdown pages

* fix(withastro#3220): ensure html in markdown pages does not have extra surrounding space

* fix(withastro#3264): ensure that remark files pass in file information

* fix(withastro#3254): enable experimentalStaticExtraction for `.md` pages

* fix: revert parsing change

* fix: remove `markdown.mode` option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: markdown Related to Markdown (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants