Skip to content

Elaborate on importing markdown #10542

@jackrabbit128

Description

@jackrabbit128

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationThe issue is related to the documentation of Docusaurus

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions