Support content "sections"
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
- Ambito
- content
Direzione di ricerca
Inizia esaminando gli entry point makeSource e defineDocumentType mostrati nell’issue, quindi traccia come i percorsi dei documenti e i campi calcolati diventano collection come allDocsSections. Confronta le sezioni annidate richieste e i metadati per sezione con gli esempi di Hugo e Docusaurus. Il lavoro è completato quando l’API proposta e la struttura tipizzata ricorsiva sono implementate e verificate tramite test appropriati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- 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
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
TanStack/tanstack.com#1293 ·