You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As absolute beginners in writing MDX, we were stumped by how to import markdown content in a .mdx file, even after reading the documentation.
Particularly confusing was how the name of the thing to import was derived from the file name.
In the documentation linked above
import PartialExample from './_markdown-partial-example.mdx';
where does PartialExample come from?
After too much trial and error, we determined that the name between import and from can in fact be anything, but its first letter must be uppercase:
import test from 'test.mdx'; did not work
import Test from 'test.mdx'; did work
import Anything from 'test.mdx'; also worked
This is implicitly shown in the documentation page, but we still don't understand why it behaves like that. I believe test.mdx is turned into javascript eventually, so presumably it exports some symbol/object/... How is it even possible that we can import this using any old name? Why does it need to start with uppercase?
Could you describe this more explicitly in the documentation?
I would create a PR, but I lack the terminology and understanding.
Self-service
I'd be willing to address this documentation request myself.
The text was updated successfully, but these errors were encountered:
This is just how JavaScript works: a default import can be imported with any name. It must be uppercase because that's how JSX works (lowercase for intrinsic elements, uppercase for components). There's nothing either MDX- or Docusaurus-specific here.
I will not object a one line addition saying "you can name the component anything you like but it must be capitalized".
Have you read the Contributing Guidelines on issues?
Description
As absolute beginners in writing MDX, we were stumped by how to import markdown content in a
.mdx
file, even after reading the documentation.Particularly confusing was how the name of the thing to import was derived from the file name.
In the documentation linked above
where does
PartialExample
come from?After too much trial and error, we determined that the name between
import
andfrom
can in fact be anything, but its first letter must be uppercase:import test from 'test.mdx';
did not workimport Test from 'test.mdx';
did workimport Anything from 'test.mdx';
also workedThis is implicitly shown in the documentation page, but we still don't understand why it behaves like that. I believe
test.mdx
is turned intojavascript
eventually, so presumably it exports some symbol/object/... How is it even possible that we can import this using any old name? Why does it need to start with uppercase?Could you describe this more explicitly in the documentation?
I would create a PR, but I lack the terminology and understanding.
Self-service
The text was updated successfully, but these errors were encountered: