Skip to content

Commit 78c2e61

Browse files
committed
revert: always use single quote
1 parent b471c2a commit 78c2e61

File tree

3 files changed

+44
-41
lines changed

3 files changed

+44
-41
lines changed

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

.vitepress/config.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,60 @@
1-
import { defineConfig } from "vitepress";
2-
import { generateNavAndSidebar } from "./navSidebar";
1+
import { defineConfig } from 'vitepress';
2+
import { generateNavAndSidebar } from './navSidebar';
33

44
const { nav: zhNav, sidebar: zhSidebar } = generateNavAndSidebar(process.cwd());
55
const { nav: enNav, sidebar: enSidebar } = generateNavAndSidebar(
66
process.cwd(),
7-
"en"
7+
'en'
88
);
99

1010
export default defineConfig({
11-
lang: "zh-CN",
12-
title: "CookLikeHOC",
13-
description: "像老乡鸡那样做饭",
11+
lang: 'zh-CN',
12+
title: 'CookLikeHOC',
13+
description: '像老乡鸡那样做饭',
1414
lastUpdated: true,
1515
cleanUrls: true,
1616
themeConfig: {
17-
logo: "/logo.png",
17+
logo: '/logo.png',
1818
nav: [
19-
{ text: "首页", link: "/" },
19+
{ text: '首页', link: '/' },
2020
...zhNav,
21-
{ text: "GitHub", link: "https://github.com/Gar-b-age/CookLikeHOC" },
21+
{ text: 'GitHub', link: 'https://github.com/Gar-b-age/CookLikeHOC' },
2222
],
2323
sidebar: zhSidebar,
2424
search: {
25-
provider: "local",
25+
provider: 'local',
2626
},
2727
outline: [2, 3],
2828
docFooter: {
29-
prev: "上一页",
30-
next: "下一页",
29+
prev: '上一页',
30+
next: '下一页',
3131
},
32-
lastUpdatedText: "上次更新",
32+
lastUpdatedText: '上次更新',
3333
},
3434
locales: {
3535
root: {
36-
label: "简体中文",
37-
lang: "zh-CN",
36+
label: '简体中文',
37+
lang: 'zh-CN',
3838
},
3939
en: {
40-
label: "English",
41-
lang: "en",
42-
link: "/en/",
43-
title: "CookLikeHOC",
44-
description: "Cook like HOC - Traditional Chinese recipes",
40+
label: 'English',
41+
lang: 'en',
42+
link: '/en/',
43+
title: 'CookLikeHOC',
44+
description: 'Cook like HOC - Traditional Chinese recipes',
4545
themeConfig: {
4646
nav: [
47-
{ text: "Home", link: "/en/" },
47+
{ text: 'Home', link: '/en/' },
4848
...enNav,
49-
{ text: "GitHub", link: "https://github.com/Gar-b-age/CookLikeHOC" },
49+
{ text: 'GitHub', link: 'https://github.com/Gar-b-age/CookLikeHOC' },
5050
],
5151
sidebar: enSidebar,
5252
outline: [2, 3],
5353
docFooter: {
54-
prev: "Previous",
55-
next: "Next",
54+
prev: 'Previous',
55+
next: 'Next',
5656
},
57-
lastUpdatedText: "Last Updated",
57+
lastUpdatedText: 'Last Updated',
5858
},
5959
},
6060
},

.vitepress/navSidebar.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import fs from "node:fs";
2-
import path from "node:path";
1+
import fs from 'node:fs';
2+
import path from 'node:path';
33

44
export type SidebarItem = {
55
text: string;
@@ -8,14 +8,14 @@ export type SidebarItem = {
88
};
99
export type Sidebar = Record<string, SidebarItem[]>;
1010

11-
const DOC_EXT = [".md"];
11+
const DOC_EXT = ['.md'];
1212
const EXCLUDED_DIRS = new Set([
13-
".git",
14-
".github",
15-
".vitepress",
16-
"node_modules",
17-
"public",
18-
"en", // 排除 en 目录,避免在中文版导航中显示
13+
'.git',
14+
'.github',
15+
'.vitepress',
16+
'node_modules',
17+
'public',
18+
'en', // 排除 en 目录,避免在中文版导航中显示
1919
]);
2020

2121
function isDirectory(p: string) {
@@ -32,16 +32,16 @@ function isMarkdown(p: string) {
3232

3333
function titleFromName(name: string) {
3434
// strip extension & use as-is (Chinese names kept)
35-
return name.replace(/\.md$/i, "");
35+
return name.replace(/\.md$/i, '');
3636
}
3737

3838
function sortByPinyinOrName(a: string, b: string) {
39-
return a.localeCompare(b, "zh-Hans-CN-u-co-pinyin");
39+
return a.localeCompare(b, 'zh-Hans-CN-u-co-pinyin');
4040
}
4141

4242
export function generateNavAndSidebar(
4343
rootDir: string,
44-
localePrefix: string = ""
44+
localePrefix: string = ''
4545
) {
4646
const scanDir = localePrefix ? path.join(rootDir, localePrefix) : rootDir;
4747

@@ -52,7 +52,7 @@ export function generateNavAndSidebar(
5252
const entries = fs.readdirSync(scanDir);
5353
const sections = entries
5454
.filter((e: string) => isDirectory(path.join(scanDir, e)))
55-
.filter((e: string) => !EXCLUDED_DIRS.has(e) && !e.startsWith("."));
55+
.filter((e: string) => !EXCLUDED_DIRS.has(e) && !e.startsWith('.'));
5656
sections.sort(sortByPinyinOrName);
5757

5858
const nav: { text: string; link: string }[] = [];
@@ -68,13 +68,13 @@ export function generateNavAndSidebar(
6868
// Build sidebar for this section
6969
const items: SidebarItem[] = files.map((f: string) => ({
7070
text: titleFromName(f),
71-
link: `/${localePrefix}${localePrefix ? "/" : ""}${encodeURI(
71+
link: `/${localePrefix}${localePrefix ? '/' : ''}${encodeURI(
7272
dir
7373
)}/${encodeURI(f)}`,
7474
}));
7575

7676
if (items.length > 0) {
77-
const sidebarKey = `/${localePrefix}${localePrefix ? "/" : ""}${dir}/`;
77+
const sidebarKey = `/${localePrefix}${localePrefix ? '/' : ''}${dir}/`;
7878
sidebar[sidebarKey] = [
7979
{
8080
text: dir,
@@ -88,7 +88,7 @@ export function generateNavAndSidebar(
8888
// Empty section: still show in nav to directory index if exists
8989
nav.push({
9090
text: dir,
91-
link: `/${localePrefix}${localePrefix ? "/" : ""}${encodeURI(dir)}/`,
91+
link: `/${localePrefix}${localePrefix ? '/' : ''}${encodeURI(dir)}/`,
9292
});
9393
}
9494
}

0 commit comments

Comments
 (0)