Support plaintext contentType
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 28/100
- Tipo de issue
- Funcionalidade
- Clareza
- Precisa de esclarecimento
- Status de atividade
- Estagnada
- Stack de tecnologia
- react, typescript
- Domínio
- content
Direção de pesquisa
Comece pela configuração de defineDocumentType mostrada e rastreie como contentType é validado e como o conteúdo dos arquivos chega a computedField; a issue não nomeia arquivos nem testes do repositório. Para considerar o trabalho concluído, seria necessário chegar a um comportamento acordado para contentType: 'plain', sua definição padrão e a política de compatibilidade retroativa, o tratamento de texto versus binário, além da documentação e dos testes correspondentes.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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?
- Linguagem predominante
- TypeScript
- Estrelas
- 3.5k
- Forks
- 192
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de contentlayerdev/contentlayer
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 25/100
contentlayerdev/contentlayer#506 · 84 comentários · 47 reações ·
-
Poor/broken monorepo DX: can't specify .contentlayer/ output path, no docs for custom config path Abertahelp wanted meta: never-stale needs-research
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 38/100
contentlayerdev/contentlayer#464 · 4 comentários · 9 reações ·
-
State of the project Abertameta: never-stale
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 10/100
contentlayerdev/contentlayer#429 · 49 comentários · 83 reações ·
-
meta: never-stale topic: markdown/mdx
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 42/100
contentlayerdev/contentlayer#421 · 4 reações ·
-
meta: never-stale needs-research topic: schema
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
contentlayerdev/contentlayer#420 ·
Todas as issues de contentlayerdev/contentlayer
Issues semelhantes
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
-
Crush Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
ElementsProject/cln-application#167 · 1 comentário · 1 reação ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Quantco/pnpm-licenses#17 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100