Skip to content

Commit b6c109a

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

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
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/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)