Support content "sections"
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 25/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- typescript
- 領域
- content
研究方向
首先查看 issue 中展示的 makeSource 和 defineDocumentType 入口點,然後追蹤文件路徑和計算欄位如何成為 allDocsSections 等集合。將所要求的巢狀 sections 和每個 section 的中繼資料與 Hugo 和 Docusaurus 的範例進行比較。當提議的 API 和遞迴型別結構完成實作並通過適當的測試驗證後,即表示完成。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- TypeScript
- 星號
- 3.5k
- 分支
- 192
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
contentlayerdev/contentlayer 的其他 Issue
-
Error when building with contentlayer 0.3.4 and Next.js 13 App Router可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 3/5 1-2 天 新手友好度 25/100
contentlayerdev/contentlayer#506 · 84 則留言 · 47 個 reaction ·
-
Poor/broken monorepo DX: can't specify .contentlayer/ output path, no docs for custom config path未關閉help wanted meta: never-stale needs-research
難度 4/5 3-5 天 新手友好度 38/100
contentlayerdev/contentlayer#464 · 4 則留言 · 9 個 reaction ·
-
meta: never-stale
難度 5/5 一週以上 新手友好度 10/100
contentlayerdev/contentlayer#429 · 49 則留言 · 83 個 reaction ·
-
meta: never-stale topic: markdown/mdx
難度 4/5 3-5 天 新手友好度 42/100
contentlayerdev/contentlayer#421 · 4 個 reaction ·
-
meta: never-stale needs-research topic: schema
難度 5/5 一週以上 新手友好度 25/100
contentlayerdev/contentlayer#420 ·
查看 contentlayerdev/contentlayer 的全部 Issue
相似的 Issue
-
A hung CI job runs for 6 hours before it is cancelled可能已有人在做 @Olanetsoft 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
Olanetsoft/agent-lookout#110 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 90/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
thedotmack/claude-mem#4757 ·
維護者通常 1 天內回覆
-
🐛 bug 🗺️ MCP OAuth
難度 2/5 1-3 小時 新手友好度 62/100
LibreChat-AI/LibreChat#17077 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 75/100