Support content "sections"
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- typescript
- Bereich
- content
Rechercherichtung
Beginne damit, die im Issue gezeigten Einstiegspunkte makeSource und defineDocumentType zu überprüfen, und verfolge anschließend, wie Dokumentpfade und berechnete Felder zu Collections wie allDocsSections werden. Vergleiche die angeforderten verschachtelten Sections und Metadaten pro Section mit den Beispielen von Hugo und Docusaurus. Als abgeschlossen gilt die Implementierung und Überprüfung der vorgeschlagenen API und der rekursiven typisierten Struktur durch geeignete Tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 3.5k
- Forks
- 192
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus contentlayerdev/contentlayer
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 25/100
contentlayerdev/contentlayer#506 · 84 Kommentare · 47 Reaktionen ·
-
Poor/broken monorepo DX: can't specify .contentlayer/ output path, no docs for custom config path Offenhelp wanted meta: never-stale needs-research
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 38/100
contentlayerdev/contentlayer#464 · 4 Kommentare · 9 Reaktionen ·
-
State of the project Offenmeta: never-stale
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 10/100
contentlayerdev/contentlayer#429 · 49 Kommentare · 83 Reaktionen ·
-
meta: never-stale topic: markdown/mdx
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 42/100
contentlayerdev/contentlayer#421 · 4 Reaktionen ·
-
meta: never-stale needs-research topic: schema
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
contentlayerdev/contentlayer#420 ·
Alle Issues in contentlayerdev/contentlayer
Ähnliche Issues
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
-
Mend: dependency security vulnerability untriaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100