facebook / facebook/docusaurus

MDX loader: use resource query to partially import a file

オープン
#6,480 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る
domain: markdown feature
主要言語
TypeScript
スター
66.2k
フォーク
10k
平均マージ
1日 3時間
マージ済み PR(30日)
52

説明

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#reporting-new-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 `` and `` 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

- [X] I'd be willing to contribute this feature to Docusaurus myself.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。