Skip to content

Commit 6a44712

Browse files
authored
feat(sidebar): get directory title from frontmatter (#483)
1 parent 5565c31 commit 6a44712

File tree

51 files changed

+383
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+383
-296
lines changed

docs/.vitepress/config.ts

Lines changed: 8 additions & 257 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { InlineLinkPreviewElementTransform } from '@nolebase/vitepress-plugin-in
77

88
import { transformHeadMeta } from '@nolebase/vitepress-plugin-meta/vitepress'
99
import { buildEndGenerateOpenGraphImages } from '@nolebase/vitepress-plugin-og-image/vitepress'
10+
import { calculateSidebar } from '@nolebase/vitepress-plugin-sidebar'
1011
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
1112
import { gray } from 'colorette'
1213
import MarkdownItFootnote from 'markdown-it-footnote'
@@ -19,265 +20,15 @@ function noTwoslash() {
1920
return argv.some(v => v.includes('vitepress')) && argv.includes('dev')
2021
}
2122

22-
export const sidebars: Record<string, DefaultTheme.Sidebar> = {
23+
export const sidebars: Record<string, DefaultTheme.SidebarItem[] | DefaultTheme.SidebarMulti> = {
2324
'en': {
24-
'/': [
25-
{
26-
text: 'Guides',
27-
items: [
28-
{ text: 'Getting Started', link: '/pages/en/guide/getting-started' },
29-
{ text: 'Recent Updated', link: '/pages/en/recent-updates' },
30-
],
31-
},
32-
{
33-
text: 'Integrations',
34-
items: [
35-
{ text: 'Overview', link: '/pages/en/integrations/' },
36-
],
37-
},
38-
{
39-
text: 'Markdown It Plugins',
40-
items: [
41-
{
42-
text: 'Bi-directional links',
43-
collapsed: true,
44-
items: [
45-
{ text: 'Overview', link: '/pages/en/integrations/markdown-it-bi-directional-links/' },
46-
{ text: 'Getting Started', link: '/pages/en/integrations/markdown-it-bi-directional-links/getting-started' },
47-
{ text: 'Syntax', link: '/pages/en/integrations/markdown-it-bi-directional-links/syntax' },
48-
],
49-
},
50-
{ text: 'Elements Transformation', link: '/pages/en/integrations/markdown-it-element-transform/' },
51-
{ text: 'Lazy loading blurred thumbnails', link: '/pages/en/integrations/markdown-it-unlazy-img/' },
52-
],
53-
},
54-
{
55-
text: 'VitePress Plugins',
56-
items: [
57-
{ text: 'Auto Sidebar', link: '/pages/en/integrations/vitepress-plugin-sidebar/' },
58-
{ text: 'Breadcrumbs', link: '/pages/en/integrations/vitepress-plugin-breadcrumbs/' },
59-
{ text: 'Enhanced Readabilities', link: '/pages/en/integrations/vitepress-plugin-enhanced-readabilities/' },
60-
{ text: 'Index Page', link: '/pages/en/integrations/vitepress-plugin-index/' },
61-
{
62-
text: 'Inline Links Previewing',
63-
collapsed: true,
64-
items: [
65-
{ text: 'Overview', link: '/pages/en/integrations/vitepress-plugin-inline-link-preview/' },
66-
{ text: 'Getting started', link: '/pages/en/integrations/vitepress-plugin-inline-link-preview/getting-started' },
67-
{ text: 'Configuration', link: '/pages/en/integrations/vitepress-plugin-inline-link-preview/configuration' },
68-
],
69-
},
70-
{ text: 'Blinking highlight targeted heading', link: '/pages/en/integrations/vitepress-plugin-highlight-targeted-heading/' },
71-
{
72-
text: 'Git-based page histories',
73-
collapsed: true,
74-
items: [
75-
{ text: 'Overview', link: '/pages/en/integrations/vitepress-plugin-git-changelog/' },
76-
{ text: 'Getting started', link: '/pages/en/integrations/vitepress-plugin-git-changelog/getting-started' },
77-
{ text: 'Configure Vite Plugins', link: '/pages/en/integrations/vitepress-plugin-git-changelog/configure-vite-plugins' },
78-
{ text: 'Configure UI', link: '/pages/en/integrations/vitepress-plugin-git-changelog/configure-ui' },
79-
],
80-
},
81-
{ text: 'Page properties', link: '/pages/en/integrations/vitepress-plugin-page-properties/' },
82-
{ text: 'Page metadata generation', link: '/pages/en/integrations/vitepress-plugin-meta/' },
83-
{ text: 'Previewing image (social media card) generation', link: '/pages/en/integrations/vitepress-plugin-og-image/' },
84-
{ text: 'Enhanced mark elements', link: '/pages/en/integrations/vitepress-plugin-enhanced-mark/' },
85-
{
86-
text: 'Thumbnail hashing for images',
87-
collapsed: true,
88-
items: [
89-
{ text: 'Usage', link: '/pages/en/integrations/vitepress-plugin-thumbnail-hash/' },
90-
{ text: 'Try ThumbHash', link: '/pages/en/integrations/vitepress-plugin-thumbnail-hash/thumbhash' },
91-
],
92-
},
93-
],
94-
},
95-
{
96-
text: 'Obsidian Plugins',
97-
items: [
98-
{ text: 'UnoCSS', link: '/pages/en/integrations/obsidian-plugin-unocss/' },
99-
],
100-
},
101-
{
102-
text: 'UI Components',
103-
items: [
104-
{ text: 'Overview', link: '/pages/en/ui/' },
105-
],
106-
},
107-
{
108-
text: 'Releasing',
109-
items: [
110-
{
111-
text: 'Migration guides',
112-
items: [
113-
{
114-
text: 'Migrate from v1 to v2',
115-
link: '/pages/en/releases/migrations/v1-to-v2',
116-
},
117-
{
118-
text: 'Migrate from v2 to v3',
119-
link: '/pages/en/releases/migrations/v2-to-v3',
120-
},
121-
],
122-
},
123-
],
124-
},
125-
],
126-
'/pages/en/ui/': [
127-
{
128-
text: 'UI Components',
129-
items: [
130-
{ text: 'Overview', link: '/pages/en/ui/' },
131-
],
132-
},
133-
{
134-
text: 'Actions',
135-
items: [
136-
{ text: 'Button', link: '/pages/en/ui/button/' },
137-
],
138-
},
139-
{
140-
text: 'Inputs',
141-
items: [
142-
{ text: 'Radio Group (Horizontal)', link: '/pages/en/ui/input-horizontal-radio-group/' },
143-
{ text: 'Slider', link: '/pages/en/ui/input-slider/' },
144-
],
145-
},
146-
{
147-
text: 'Animations',
148-
items: [
149-
{ text: 'Asciinema player', link: '/pages/en/ui/asciinema-player/' },
150-
{ text: 'Rive Canvas (Lazy Teleport)', link: '/pages/en/ui/lazy-teleport-rive-canvas/' },
151-
],
152-
},
153-
],
154-
},
25+
'/pages/en/': calculateSidebar(['pages/en/guide', 'pages/en/integrations', 'pages/en/releases'], undefined, { '/': 2 }),
26+
'/pages/en/ui/': calculateSidebar(['pages/en/ui'], undefined, { '/': 2 }),
27+
} as DefaultTheme.SidebarMulti,
15528
'zh-CN': {
156-
'/': [
157-
{
158-
text: '指南',
159-
items: [
160-
{ text: '如何开始', link: '/pages/zh-CN/guide/getting-started' },
161-
],
162-
},
163-
{
164-
text: '集成',
165-
items: [
166-
{ text: '概览', link: '/pages/zh-CN/integrations/' },
167-
{ text: '最近更新', link: '/pages/zh-CN/recent-updates' },
168-
],
169-
},
170-
{
171-
text: 'Markdown It 插件',
172-
items: [
173-
{
174-
text: '双向链接',
175-
collapsed: true,
176-
items: [
177-
{ text: '介绍', link: '/pages/zh-CN/integrations/markdown-it-bi-directional-links/' },
178-
{ text: '快速上手', link: '/pages/zh-CN/integrations/markdown-it-bi-directional-links/getting-started' },
179-
{ text: '语法', link: '/pages/zh-CN/integrations/markdown-it-bi-directional-links/syntax' },
180-
],
181-
},
182-
{ text: '元素转换', link: '/pages/zh-CN/integrations/markdown-it-element-transform/' },
183-
{ text: '懒加载模糊缩略图', link: '/pages/zh-CN/integrations/markdown-it-unlazy-img/' },
184-
],
185-
},
186-
{
187-
text: 'VitePress 插件',
188-
items: [
189-
{ text: '自动生成侧边栏', link: '/pages/zh-CN/integrations/vitepress-plugin-sidebar/' },
190-
{ text: '面包屑导航', link: '/pages/zh-CN/integrations/vitepress-plugin-breadcrumbs/' },
191-
{ text: '阅读增强', link: '/pages/zh-CN/integrations/vitepress-plugin-enhanced-readabilities/' },
192-
{ text: '索引页', link: '/pages/zh-CN/integrations/vitepress-plugin-index/' },
193-
{
194-
text: '行内链接预览',
195-
collapsed: true,
196-
items: [
197-
{ text: '介绍', link: '/pages/zh-CN/integrations/vitepress-plugin-inline-link-preview/' },
198-
{ text: '快速上手', link: '/pages/zh-CN/integrations/vitepress-plugin-inline-link-preview/getting-started' },
199-
{ text: '配置', link: '/pages/zh-CN/integrations/vitepress-plugin-inline-link-preview/configuration' },
200-
],
201-
},
202-
{ text: '闪烁高亮当前的目标标题', link: '/pages/zh-CN/integrations/vitepress-plugin-highlight-targeted-heading/' },
203-
{
204-
text: '基于 Git 的页面历史',
205-
collapsed: true,
206-
items: [
207-
{ text: '介绍', link: '/pages/zh-CN/integrations/vitepress-plugin-git-changelog/' },
208-
{ text: '快速上手', link: '/pages/zh-CN/integrations/vitepress-plugin-git-changelog/getting-started' },
209-
{ text: '配置 Vite 插件', link: '/pages/zh-CN/integrations/vitepress-plugin-git-changelog/configure-vite-plugins' },
210-
{ text: '配置 UI 组件', link: '/pages/zh-CN/integrations/vitepress-plugin-git-changelog/configure-ui' },
211-
],
212-
},
213-
{ text: '页面属性', link: '/pages/zh-CN/integrations/vitepress-plugin-page-properties/' },
214-
{ text: '页面元信息生成', link: '/pages/zh-CN/integrations/vitepress-plugin-meta/' },
215-
{ text: '预览图片(社交媒体卡片)生成', link: '/pages/zh-CN/integrations/vitepress-plugin-og-image/' },
216-
{ text: 'mark 元素增强', link: '/pages/zh-CN/integrations/vitepress-plugin-enhanced-mark/' },
217-
{
218-
text: '缩略图模糊哈希生成',
219-
collapsed: true,
220-
items: [
221-
{ text: '用法', link: '/pages/zh-CN/integrations/vitepress-plugin-thumbnail-hash/' },
222-
{ text: '尝试 ThumbHash', link: '/pages/zh-CN/integrations/vitepress-plugin-thumbnail-hash/thumbhash' },
223-
],
224-
},
225-
],
226-
},
227-
{
228-
text: 'Obsidian 插件',
229-
items: [
230-
{ text: 'UnoCSS', link: '/pages/zh-CN/integrations/obsidian-plugin-unocss/' },
231-
],
232-
},
233-
{
234-
text: '版本发布',
235-
items: [
236-
{
237-
text: '迁移指南',
238-
items: [
239-
{
240-
text: '自 v1 迁移至 v2',
241-
link: '/pages/zh-CN/releases/migrations/v1-to-v2',
242-
},
243-
{
244-
text: '自 v2 迁移至 v3',
245-
link: '/pages/zh-CN/releases/migrations/v2-to-v3',
246-
},
247-
],
248-
},
249-
],
250-
},
251-
],
252-
'/pages/zh-CN/ui/': [
253-
{
254-
text: 'UI 组件',
255-
items: [
256-
{ text: '概览', link: '/pages/zh-CN/ui/' },
257-
],
258-
},
259-
{
260-
text: '操作',
261-
items: [
262-
{ text: '按钮', link: '/pages/zh-CN/ui/button/' },
263-
],
264-
},
265-
{
266-
text: '输入',
267-
items: [
268-
{ text: '多个单选(水平)', link: '/pages/zh-CN/ui/input-horizontal-radio-group/' },
269-
{ text: '滑块', link: '/pages/zh-CN/ui/input-slider/' },
270-
],
271-
},
272-
{
273-
text: '动画',
274-
items: [
275-
{ text: 'Asciinema 播放器', link: '/pages/en/ui/asciinema-player/' },
276-
{ text: 'Rive Canvas(懒 Teleport)', link: '/pages/zh-CN/ui/lazy-teleport-rive-canvas/' },
277-
],
278-
},
279-
],
280-
},
29+
'/pages/zh-CN/': calculateSidebar(['pages/zh-CN/guide', 'pages/zh-CN/integrations', 'pages/zh-CN/releases'], undefined, { '/': 2 }),
30+
'/pages/zh-CN/ui/': calculateSidebar(['pages/zh-CN/ui'], undefined, { '/': 2 }),
31+
} as DefaultTheme.SidebarMulti,
28132
}
28233

28334
function getVueProdHydrationMismatchDetailsFlag() {

docs/pages/en/guide/_page.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
sidebarTitle: Guide
3+
sidebarCollapsed: false
4+
---
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
2+
title: Recent Updates
23
nolebase:
34
gitChangelog: false
45
pageProperties: false
56
---
67

78
<script setup>
8-
import { data } from '../../data/en/recentUpdates.data'
9+
import { data } from '../../../data/en/recentUpdates.data'
910
</script>
1011

1112
<NolebaseRecentUpdates :data="data" />

docs/pages/en/integrations/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Integrations
33
category: Index
4+
sidebarCollapsed: false
45
---
56

67
<script setup>

docs/pages/en/integrations/markdown-it-bi-directional-links/Bi-directional Links Example Page.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: Bi-directional Links
33
category: Bi-directional Links
4+
sidebarTitle: Bi-directional Links Example Page
5+
sidebarHide: true
46
---
57

68
# Bi-directional Links Example Page

docs/pages/en/integrations/markdown-it-bi-directional-links/Bi-directional Links Example Same Name Page.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: Bi-directional Links
33
category: Bi-directional Links
4+
sidebarTitle: Bi-directional Links Example Same Name Page
5+
sidebarHide: true
46
---
57

68
# Bi-directional Links Example Same Name Page

docs/pages/en/integrations/markdown-it-bi-directional-links/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Bi-directional Links
33
category: Bi-directional Links
4+
sidebarTitle: Getting Started
45
---
56

67
# Getting started
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
---
2+
sidebarHide: true
3+
---
4+
15
All images are provided by [Lorem Picsum](https://picsum.photos/) - The Lorem Ipsum for photos.

docs/pages/en/integrations/markdown-it-bi-directional-links/same-name/Bi-directional Links Example Same Name Page.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Bi-directional Links
33
category: Bi-directional Links
4+
sidebarHide: true
45
---
56

67
# Bi-directional Links Example Same Name Page

docs/pages/en/integrations/markdown-it-bi-directional-links/syntax.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Bi-directional Links
33
category: Bi-directional Links
4+
sidebarTitle: Syntax
45
---
56

67
# Syntax

0 commit comments

Comments
 (0)