Support plaintext contentType
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 28/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- react, typescript
- 領域
- content
調査の方向性
示されている defineDocumentType 設定から始め、contentType がどのように検証され、ファイルの内容がどのように computedField に到達するかを追跡してください。issue にはリポジトリのファイルやテストが記載されていません。完了には、contentType: 'plain' の動作、そのデフォルト設定と後方互換性の方針、テキストとバイナリの扱い、ならびに対応するドキュメントとテストについて合意する必要があります。
索引モデルが issue の本文から書いたものです。
説明
I am trying to use .tsx files as input for a documentType. My use case is to turn them into JSON objects representing the associated components' properties via react-docgen-typescript.
The plan would be to have a computedField that uses react-docgen-typescript to parse the raw file content into a JSON object representing the properties.
But, Contentlayer doesn't support .tsxfiles, yet.
I tried this with the following config, assuming contentType: 'data' would just load the content of the files but was taught on Discord that it is only for frontmatter.
export const ComponentProp = defineDocumentType(() => ({
name: 'ComponentProp',
filePathPattern: `lib-src/**/*.tsx`,
contentType: 'data',
}));
Proposed solution
Add a contentType: 'plain' that just loads the entire file and leaves processing up to the user.
This contentType would solve my use-case but even better, enable users of Contentlayer to use it for their use-cases which we are not yet aware of or that are needed by only a small minority.
Implications
Default contentType
Currently, Contentlayer treats files as markdown by default. Assuming we add a 'plain' type I would suggest changing this behavior to read files as plaintext by default. That, however, could be a breaking change!
I am not 100% sure how Contentlayer currently treats files but use-cases of people who currently parse non *.md files as markdown would be broken.
Plain text defaults
Going with the above Contentlayer would start to treat all file extensions it doesn't know as plaintext.
This implies that Contentlayer assumes to be used on text files only. It would lead to errors when handling binary file types, such as jpg or mp3.
There should be documentation and logging around this fact. The question here is whether Contentlayer could confirm that a file it is processing is a text file or not?
Alternative implementation
A backward-compatible way of introducing plaintext file types would be to add a contentType: 'plain' as an additional, optional feature to use.
However, I could see people getting confused by having a plaintext interpretation available but this not being the treatment that Contentlayer default to.
Ont he other hand, Contentlayer is a system for handling content and might find it's audience largely in people processing markdown files which would justify leaving the default interpretation as markdown.
Open questions
- Is defaulting to plain text a good idea?
- Can we determine a file to be a text file?
- Should we potentially switch to requiring conentType to be set explicitly?
- 主要言語
- TypeScript
- スター
- 3.5k
- フォーク
- 192
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
contentlayerdev/contentlayer のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
contentlayerdev/contentlayer#506 · コメント 84 件 · リアクション 47 件 ·
-
Poor/broken monorepo DX: can't specify .contentlayer/ output path, no docs for custom config path オープンhelp wanted meta: never-stale needs-research
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
contentlayerdev/contentlayer#464 · コメント 4 件 · リアクション 9 件 ·
-
State of the project オープンmeta: never-stale
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
contentlayerdev/contentlayer#429 · コメント 49 件 · リアクション 83 件 ·
-
meta: never-stale topic: markdown/mdx
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
contentlayerdev/contentlayer#421 · リアクション 4 件 ·
-
meta: never-stale needs-research topic: schema
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
contentlayerdev/contentlayer#420 ·
contentlayerdev/contentlayer の issue をすべて見る
似ている issue
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
Mend: dependency security vulnerability untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100