Support content "sections"
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
- Área
- content
Línea de trabajo
Empieza revisando los puntos de entrada makeSource y defineDocumentType mostrados en el issue; después, sigue cómo las rutas de los documentos y los campos calculados se convierten en colecciones como allDocsSections. Compara las secciones anidadas solicitadas y los metadatos por sección con los ejemplos de Hugo y Docusaurus. Se considera terminado cuando la API propuesta y la estructura tipada recursiva estén implementadas y verificadas mediante las pruebas adecuadas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
One of the things that I really like about Hugo is its sections feature, which enables you to separate nested directories of content into well-defined groups. So instead of a kind of "flat" array of files you end up getting a nested structure like this:
Documentation
\_ Getting started
\_ Installation
\_ Platforms
\_ Administration
\_ Kubernetes
\_ Setup
\_ Configuration
\_ etc
As expected, sections can be infinitely nested and each can have its own metadata. I don't necessarily endorse the way that Hugo does this (you need to sprinkle _index.md files throughout your tree) but I do think that having this kind of rich structure available to you is great for creating tables of content, sidebar navs, and all of that good stuff. Personally, it's the thing that I'm missing the most as I cross the chasm from mostly doing things in Hugo to doing things in JS world.
I could envision being able to do something like this in Contentlayer:
export const Doc = defineDocumentType(() => ({
name: 'Doc',
filePathPattern: `**/*.md`,
fields: {
title: {
type: 'string',
description: 'The title of the doc',
required: true,
},
},
computedFields: {
url: {
type: 'string',
resolve: (post) => `/docs/${post._raw.flattenedPath}`,
},
},
}))
export default makeSource({
contentDirPath: 'docs',
documentTypes: [Doc],
// tiny little change
sections: true,
})
This could export an allDocsSections object of type Sections<Doc> that would enable you to recurse through the tree.
<ul>
{allDocs.sections.map(section => (
<li>
<p>{section.title}</p>
<ul>
{section.docs.map(doc => (
<li>
{doc.title}
</li>
))}
{section.sections.map(section => ( /* nest */ ))}
</ul>
</li>)}
</ul>
This is very off the cuff but hopefully provides some sense of what I'm suggesting. I'd be quite happy to help out with this if others find the idea compelling. Just wanted to register it here in this forum.
Note: Docusaurus also supports this using a _category_.{json|yml} file that creates a new "category" (basically an analogue to the sections concept) wherever it's found in the directory tree.
- Lenguaje dominante
- TypeScript
- Estrellas
- 3.5k
- Forks
- 192
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de contentlayerdev/contentlayer
-
Dificultad 3/5 1-2 días Aptitud para principiantes 25/100
contentlayerdev/contentlayer#506 · 84 comentarios · 47 reacciones ·
-
Poor/broken monorepo DX: can't specify .contentlayer/ output path, no docs for custom config path Abiertohelp wanted meta: never-stale needs-research
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
contentlayerdev/contentlayer#464 · 4 comentarios · 9 reacciones ·
-
State of the project Abiertometa: never-stale
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
contentlayerdev/contentlayer#429 · 49 comentarios · 83 reacciones ·
-
meta: never-stale topic: markdown/mdx
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
contentlayerdev/contentlayer#421 · 4 reacciones ·
-
meta: never-stale needs-research topic: schema
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
contentlayerdev/contentlayer#420 ·
Todos los issues de contentlayerdev/contentlayer
Issues similares
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
-
Mend: dependency security vulnerability untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100