Skip to content

MDX loader: use resource query to partially import a file #6480

Open
@Josh-Cena

Description

Have you read the Contributing Guidelines on issues?

Description

Currently, our blog plugin is able to truncate a post based on the ?truncated=true resource query. E.g. "modulePath": "blog/2018-12-14-Happy-First-Birthday-Slash.md?truncated=true" Maybe we can implement something similar in the MDX loader itself.

Has this been requested on Canny?

no

Motivation

Allow partial imports instead of cutting a piece of Markdown out as partial

API design

We could allow several types of queries:

  • By file line number ?lines=3-9. Prone to breaking when editing files but easy to implement and easy to reason about
  • By heading ID ?section=caveats. Less flexible, but still very easy to reason about
  • By an arbitrary marker ?from=from&to=to, and in the imported Markdown file, there are corresponding <!-- from --> and <!-- to --> markers. This may lead to broken syntax in some cases, but should still be fun to try

Have you tried building it?

No

Self-service

  • I'd be willing to contribute this feature to Docusaurus myself.

Metadata

Assignees

No one assigned

    Labels

    domain: markdownRelated to Markdown parsing or syntaxfeatureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions