mirror of
https://github.com/Gar-b-age/CookLikeHOC.git
synced 2026-03-22 04:47:16 +08:00
Merge pull request #96 from YaoSiQian/main
fix(nav & index.md): 默认进入各菜品的README和包子
This commit is contained in:
@@ -42,7 +42,7 @@ export function generateNavAndSidebar(rootDir: string) {
|
||||
|
||||
for (const dir of sections) {
|
||||
const abs = path.join(rootDir, dir)
|
||||
const files = fs
|
||||
const files = fs
|
||||
.readdirSync(abs)
|
||||
.filter((f) => isMarkdown(path.join(abs, f)))
|
||||
.sort(sortByPinyinOrName)
|
||||
@@ -50,9 +50,12 @@ export function generateNavAndSidebar(rootDir: string) {
|
||||
// Build sidebar for this section
|
||||
const items: SidebarItem[] = files.map((f) => ({
|
||||
text: titleFromName(f),
|
||||
link: `/${encodeURI(dir)}/${encodeURI(f)}`,
|
||||
link: `/${encodeURI(dir)}/${encodeURI(f)}`,
|
||||
}))
|
||||
|
||||
// Find README.md、readme.md、index.md
|
||||
const readme = ['README.md', 'readme.md', 'index.md'].find((n) => fs.existsSync(path.join(abs, n)))
|
||||
|
||||
if (items.length > 0) {
|
||||
sidebar[`/${dir}/`] = [
|
||||
{
|
||||
@@ -60,11 +63,12 @@ export function generateNavAndSidebar(rootDir: string) {
|
||||
items,
|
||||
},
|
||||
]
|
||||
|
||||
// First doc becomes nav link for section
|
||||
nav.push({ text: dir, link: items[0].link! })
|
||||
if (readme) {
|
||||
nav.push({ text: dir, link: `/${encodeURI(dir)}/${encodeURI(readme)}` })
|
||||
} else {
|
||||
nav.push({ text: dir, link: items[0].link! })
|
||||
}
|
||||
} else {
|
||||
// Empty section: still show in nav to directory index if exists
|
||||
nav.push({ text: dir, link: `/${encodeURI(dir)}/` })
|
||||
}
|
||||
}
|
||||
|
||||
2
index.md
2
index.md
@@ -7,7 +7,7 @@ hero:
|
||||
actions:
|
||||
- theme: brand
|
||||
text: 开始浏览
|
||||
link: /炒菜/菠萝咕咾肉
|
||||
link: /炒菜/README
|
||||
- theme: alt
|
||||
text: GitHub
|
||||
link: https://github.com/Gar-b-age/CookLikeHOC
|
||||
|
||||
7
早餐/奶黄鸡包.md
Normal file
7
早餐/奶黄鸡包.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# 奶黄鸡包
|
||||
|
||||
## 配料
|
||||
- 奶黄鸡包(小麦粉、玉米粉、鸡蛋、白砂糖等)(来自郑州千味央厨)
|
||||
|
||||
## 步骤
|
||||
- 蒸柜上汽后,蒸制 8 分钟。
|
||||
@@ -1,7 +1,7 @@
|
||||
# 荠菜鲜肉蒸饺
|
||||
|
||||
## 配料
|
||||
- 奶黄鸡包(来自郑州千味央厨)
|
||||
- 荠菜鲜肉蒸饺(小麦粉、猪肉、荠菜、盐、鸡精等)(来自郑州千味央厨、山东康喜)
|
||||
|
||||
## 步骤
|
||||
- 蒸柜上汽后,蒸制 8 分钟。
|
||||
- 蒸柜上汽后,蒸制 10 分钟。
|
||||
Reference in New Issue
Block a user