Support plaintext contentType
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 28/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- react, typescript
- Ambito
- content
Direzione di ricerca
Parti dalla configurazione di defineDocumentType mostrata e traccia come viene validato contentType e come il contenuto dei file raggiunge computedField; l’issue non indica alcun file o test del repository. Per considerare il lavoro completato, sarebbe necessario concordare il comportamento di contentType: 'plain', il suo valore predefinito e la politica di retrocompatibilità, la gestione del testo rispetto ai dati binari, oltre alla documentazione e ai test corrispondenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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?
- Lingua principale
- TypeScript
- Stelle
- 3.5k
- Fork
- 192
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di contentlayerdev/contentlayer
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
contentlayerdev/contentlayer#506 · 84 commenti · 47 reazioni ·
-
Poor/broken monorepo DX: can't specify .contentlayer/ output path, no docs for custom config path Apertahelp wanted meta: never-stale needs-research
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
contentlayerdev/contentlayer#464 · 4 commenti · 9 reazioni ·
-
State of the project Apertameta: never-stale
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
contentlayerdev/contentlayer#429 · 49 commenti · 83 reazioni ·
-
meta: never-stale topic: markdown/mdx
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
contentlayerdev/contentlayer#421 · 4 reazioni ·
-
meta: never-stale needs-research topic: schema
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
contentlayerdev/contentlayer#420 ·
Tutte le issue di contentlayerdev/contentlayer
Issue simili
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
Mend: dependency security vulnerability untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100