Skip to content

Commit 8ec05ce

Browse files
authored
Merge pull request #38 from godwei123/develop
feat202401
2 parents b8be529 + 2643198 commit 8ec05ce

Some content is hidden

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

55 files changed

+9374
-4182
lines changed

Diff for: docs/.vitepress/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default defineConfig({
2222
provider: "local",
2323
options: {
2424
locales: {
25-
zh: {
25+
root: {
2626
translations: {
2727
button: {
2828
buttonText: "搜索文档",

Diff for: docs/.vitepress/project.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const baseURL: string = "/javascript-guide/";

Diff for: docs/.vitepress/scripts/sidebar.ts

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import fg from "fast-glob";
2+
3+
const javaScriptIntroduction = { text: "Introduction", link: "/javascript/introduction" };
4+
const javaScriptOptions: Record<string, string> = {
5+
type: "类型和语法",
6+
"array-string": "Array & String",
7+
object: "Object",
8+
"type-conversion": "类型转换",
9+
prototype: "原型和原型链",
10+
this: "this",
11+
closure: "闭包",
12+
"throttle-debounce": "节流和防抖",
13+
async: "同步和异步",
14+
regexp: "正则",
15+
"ES5+": "ES6+",
16+
"proxy-reflect": "代理和反射",
17+
"broadcast-channel": "Broadcast Channel API",
18+
"web-speech-api": "Web Speech API",
19+
observer: "Observer API",
20+
other: "其他",
21+
eventloop: "Event Loop",
22+
};
23+
24+
const blogIntroduction = { text: "Introduction", link: "/blog/introduction" };
25+
const cssIntroduction = { text: "Introduction", link: "/basic/css/introduction" };
26+
27+
const CSSOptions = {
28+
"@font-face": "@font-face",
29+
center: "居中",
30+
flex: "flex布局",
31+
layout: "常见布局",
32+
grid: "grid布局",
33+
"text-hidden-overflow": "文本溢出",
34+
bfc: "BFC",
35+
position: "层叠与定位",
36+
"pseudo-classes-element": "伪类与伪元素",
37+
selectors: "CSS选择器",
38+
};
39+
40+
/**
41+
* @description: 生成侧边栏
42+
*/
43+
const generateSidebar = (
44+
cwd: string,
45+
introduction: Record<string, string>,
46+
options: Record<string, string>,
47+
prefix: string
48+
) => {
49+
const files = fg.sync(["./*.md"], { cwd: cwd, ignore: ["./introduction.md"] });
50+
const result = files.map((file) => {
51+
const path = file.replace(/(\/index)?\.md$/, "");
52+
const text = path.replace(/\/$/, "").split("/").pop();
53+
return { text: options[text] || text, link: `/${prefix}/${path}` };
54+
});
55+
return [introduction, ...result];
56+
};
57+
58+
export const generateJavaScriptSidebar = () => {
59+
console.log("javascript sidebar generate");
60+
return generateSidebar(
61+
"./docs/javascript",
62+
javaScriptIntroduction,
63+
javaScriptOptions,
64+
"javascript"
65+
);
66+
};
67+
68+
export const generateBlogSidebar = () => {
69+
console.log("blog sidebar generate");
70+
return generateSidebar("./docs/blog", blogIntroduction, {}, "blog");
71+
};
72+
73+
export const generateCSSSidebar = () => {
74+
console.log("css sidebar generate");
75+
return generateSidebar("./docs/basic/css", cssIntroduction, CSSOptions, "css");
76+
};

Diff for: docs/.vitepress/sidebar/configs/sidebarBlog.ts

-21
This file was deleted.

Diff for: docs/.vitepress/sidebar/configs/sidebarJavaScript.ts

-24
This file was deleted.

Diff for: docs/.vitepress/sidebar/index.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
import {
2-
sidebarBaseBrowserAndNetwork,
3-
sidebarBaseHTMLAndCSS,
4-
sidebarCode,
5-
} from "./configs/sidebarBase";
6-
import sidebarJavaScript from "./configs/sidebarJavaScript";
1+
import { sidebarBaseBrowserAndNetwork, sidebarBaseHTMLAndCSS, sidebarCode } from "./sidebarBase";
72
import { DefaultTheme } from "vitepress";
8-
import { sidebarBlog } from "./configs/sidebarBlog";
3+
import { generateJavaScriptSidebar, generateBlogSidebar } from "../scripts/sidebar";
94

105
const sidebar: DefaultTheme.SidebarMulti = {
11-
"/javascript": sidebarJavaScript,
6+
"/javascript": generateJavaScriptSidebar(),
127
"/basic/html": sidebarBaseHTMLAndCSS,
138
"/basic/css": sidebarBaseHTMLAndCSS,
149
"/basic/network": sidebarBaseBrowserAndNetwork,
1510
"/basic/browser": sidebarBaseBrowserAndNetwork,
1611
"/basic/code": sidebarCode,
17-
"/blog": sidebarBlog,
12+
"/blog": generateBlogSidebar(),
1813
};
1914
export default sidebar;

Diff for: docs/.vitepress/sidebar/configs/sidebarBase.ts renamed to docs/.vitepress/sidebar/sidebarBase.ts

+2-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DefaultTheme } from "vitepress";
2+
import { generateCSSSidebar } from "../scripts/sidebar";
23

34
export const sidebarBaseHTMLAndCSS: DefaultTheme.SidebarItem[] = [
45
{
@@ -11,27 +12,7 @@ export const sidebarBaseHTMLAndCSS: DefaultTheme.SidebarItem[] = [
1112
},
1213
{
1314
text: "CSS",
14-
items: [
15-
{ text: "Introduction", link: "/basic/css/introduction" },
16-
{ text: "flex布局", link: "/basic/css/flex" },
17-
{ text: "grid布局", link: "/basic/css/grid" },
18-
{ text: "居中", link: "/basic/css/center" },
19-
{ text: "常见布局", link: "/basic/css/layout" },
20-
{ text: "BFC", link: "/basic/css/bfc" },
21-
{ text: "层叠与定位", link: "/basic/css/position" },
22-
{ text: "过渡与动画", link: "/basic/css/transition-animation" },
23-
{ text: "伪类与伪元素", link: "/basic/css/pseudo-classes-element" },
24-
{ text: "CSS选择器", link: "/basic/css/selectors" },
25-
{ text: "@font-face", link: "/basic/css/@font-face" },
26-
{ text: "basic-shape", link: "/basic/css/basic-shape" },
27-
{ text: "blend-mode", link: "/basic/css/blend-mode" },
28-
{ text: "clip-path", link: "/basic/css/clip-path" },
29-
{ text: "filter", link: "/basic/css/filter" },
30-
{ text: "masking", link: "/basic/css/masking" },
31-
{ text: "shapes", link: "/basic/css/shapes" },
32-
{ text: "color", link: "/basic/css/color-var-fun" },
33-
{ text: "text-hidden-overflow", link: "/basic/css/text-hidden-overflow" },
34-
],
15+
items: generateCSSSidebar(),
3516
},
3617
];
3718
export const sidebarBaseBrowserAndNetwork: DefaultTheme.SidebarItem[] = [

Diff for: docs/.vitepress/theme/Layout.vue

-70
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ const theme = ref();
1111
watch(isDark, (val) => {
1212
theme.value = val ? darkTheme : null;
1313
});
14-
const showWatermark = ref(false);
15-
const active = ref(false);
1614
</script>
1715

1816
<template>
@@ -29,74 +27,6 @@ const active = ref(false);
2927
</n-message-provider>
3028
</n-notification-provider>
3129
</n-config-provider>
32-
<!-- <n-watermark-->
33-
<!-- v-show="showWatermark"-->
34-
<!-- content="javascript guide"-->
35-
<!-- cross-->
36-
<!-- fullscreen-->
37-
<!-- :font-size="14"-->
38-
<!-- :line-height="16"-->
39-
<!-- :width="384"-->
40-
<!-- :height="284"-->
41-
<!-- :x-offset="12"-->
42-
<!-- :y-offset="60"-->
43-
<!-- :rotate="-15"-->
44-
<!-- :z-index="99"-->
45-
<!-- :font-family="'IBM Plex Mono'"-->
46-
<!-- />-->
47-
<!-- <n-element-->
48-
<!-- :style="{-->
49-
<!-- position: 'fixed',-->
50-
<!-- zIndex: 10,-->
51-
<!-- bottom: '40px',-->
52-
<!-- right: `calc(40px + 20px)`,-->
53-
<!-- width: '44px',-->
54-
<!-- height: '44px',-->
55-
<!-- fontSize: '26px',-->
56-
<!-- display: 'flex',-->
57-
<!-- alignItems: 'center',-->
58-
<!-- justifyContent: 'center',-->
59-
<!-- borderRadius: '50%',-->
60-
<!-- backgroundColor: 'var(&#45;&#45;popover-color)',-->
61-
<!-- color: 'var(&#45;&#45;text-color-2)',-->
62-
<!-- boxShadow: '0 2px 8px 0px rgba(0, 0, 0, .12)',-->
63-
<!-- cursor: 'pointer',-->
64-
<!-- }"-->
65-
<!-- @click="active = true"-->
66-
<!-- >-->
67-
<!-- <svg-->
68-
<!-- viewBox="0 0 16 16"-->
69-
<!-- fill="none"-->
70-
<!-- xmlns="http://www.w3.org/2000/svg"-->
71-
<!-- style="width: 1em; height: 1em; color: currentcolor"-->
72-
<!-- >-->
73-
<!-- <path-->
74-
<!-- d="M13.5 1C13.7761 1 14 1.22386 14 1.5V2H14.5C14.7761 2 15 2.22386 15 2.5C15 2.77614 14.7761 3 14.5 3H14V3.5C14 3.77614 13.7761 4 13.5 4C13.2239 4 13 3.77614 13 3.5V3H12.5C12.2239 3 12 2.77614 12 2.5C12 2.22386 12.2239 2 12.5 2H13V1.5C13 1.22386 13.2239 1 13.5 1Z"-->
75-
<!-- fill="currentColor"-->
76-
<!-- ></path>-->
77-
<!-- <path-->
78-
<!-- d="M3.5 3C3.77615 3 4 3.22386 4 3.5V4H4.5C4.77615 4 5 4.22386 5 4.5C5 4.77614 4.77615 5 4.5 5H4V5.5C4 5.77614 3.77615 6 3.5 6C3.22386 6 3 5.77614 3 5.5V5H2.5C2.22386 5 2 4.77614 2 4.5C2 4.22386 2.22386 4 2.5 4H3V3.5C3 3.22386 3.22386 3 3.5 3Z"-->
79-
<!-- fill="currentColor"-->
80-
<!-- ></path>-->
81-
<!-- <path-->
82-
<!-- d="M12.5 12C12.7761 12 13 11.7761 13 11.5C13 11.2239 12.7761 11 12.5 11H12V10.5C12 10.2239 11.7761 10 11.5 10C11.2239 10 11 10.2239 11 10.5V11H10.5C10.2239 11 10 11.2239 10 11.5C10 11.7761 10.2239 12 10.5 12H11V12.5C11 12.7761 11.2239 13 11.5 13C11.7761 13 12 12.7761 12 12.5V12H12.5Z"-->
83-
<!-- fill="currentColor"-->
84-
<!-- ></path>-->
85-
<!-- <path-->
86-
<!-- d="M8.72956 4.56346C9.4771 3.81592 10.6891 3.81592 11.4367 4.56347C12.1842 5.31102 12.1842 6.52303 11.4367 7.27058L4.26679 14.4404C3.51924 15.1879 2.30723 15.1879 1.55968 14.4404C0.812134 13.6928 0.812138 12.4808 1.55969 11.7333L8.72956 4.56346ZM8.25002 6.4572L2.26679 12.4404C1.90977 12.7974 1.90977 13.3763 2.26679 13.7333C2.62381 14.0903 3.20266 14.0903 3.55968 13.7333L9.54292 7.75009L8.25002 6.4572ZM10.25 7.04299L10.7295 6.56347C11.0866 6.20645 11.0866 5.6276 10.7296 5.27057C10.3725 4.91355 9.79368 4.91355 9.43666 5.27057L8.95713 5.7501L10.25 7.04299Z"-->
87-
<!-- fill="currentColor"-->
88-
<!-- ></path>-->
89-
<!-- </svg>-->
90-
<!-- </n-element>-->
91-
<!-- <n-drawer v-model:show="active" :width="300">-->
92-
<!-- <n-drawer-content title="主题配置">-->
93-
<!-- <n-form-item label="开启水印" label-placement="left">-->
94-
<!-- <n-switch v-model:value="showWatermark">-->
95-
<!-- <template #icon> 🤔</template>-->
96-
<!-- </n-switch>-->
97-
<!-- </n-form-item>-->
98-
<!-- </n-drawer-content>-->
99-
<!-- </n-drawer>-->
10030
</template>
10131

10232
<style></style>

0 commit comments

Comments
 (0)