Skip to content

Commit a510c3f

Browse files
fix: current order is not suitable and seems confusing to navigate (#45)
* fix: current order is not suitable and seems confusing to navigate * feat: move docker above as it is fundemental
1 parent a08c23b commit a510c3f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

site/.vitepress/config/sidebar.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,32 @@ function humanize(name: string): string {
2323
.replace(/\b\w/g, c => c.toUpperCase())
2424
}
2525

26+
// 学习顺序:入门准备 → Docker环境 → U-Boot → 内核 → 文件系统 → 驱动 → 实战 → 进阶
27+
const LEARNING_ORDER = [
28+
'start',
29+
'docker',
30+
'uboot',
31+
'kernel',
32+
'rootfs',
33+
'driver',
34+
'practical',
35+
'third_party',
36+
]
37+
2638
function sortEntries(a: string, b: string): number {
2739
const na = a.match(/^(\d+)/)?.[1]
2840
const nb = b.match(/^(\d+)/)?.[1]
2941
if (na && nb) return parseInt(na) - parseInt(nb)
3042
if (na) return -1
3143
if (nb) return 1
44+
45+
// 对于没有数字前缀的目录,按学习顺序排序
46+
const ia = LEARNING_ORDER.indexOf(a)
47+
const ib = LEARNING_ORDER.indexOf(b)
48+
if (ia !== -1 && ib !== -1) return ia - ib
49+
if (ia !== -1) return -1
50+
if (ib !== -1) return 1
51+
3252
return a.localeCompare(b, 'en')
3353
}
3454

0 commit comments

Comments
 (0)