Skip to content

Commit 43aeaff

Browse files
author
Chu Fan
committed
feat: 配置采用ts语法,新增代码文件引入
- 优化主题配置 - 修复代码引入异常问题
1 parent 8e4fbb6 commit 43aeaff

22 files changed

+112
-123
lines changed
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
import pluginsConfig from "./config/plugins.config";
22
import themeConfig from "./config/theme.config";
3+
import {defineUserConfig} from "vuepress";
4+
import { fileURLToPath } from 'node:url'
5+
// @ts-ignore
6+
import {path} from "@vuepress/utils";
7+
// @ts-ignore
8+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
39

410
// 用于区分base路径,是否nginx代理
511
const PROXY_DOMAIN=process.env.PROXY_DOMAIN||false
612

7-
export default {
13+
export default defineUserConfig({
814
title: "凡是过往、皆为序章",
915
description: "一本有趣的JavaScript合集",
1016
base: PROXY_DOMAIN ? "/JavaScriptCollection/":"/",
1117
port: 5000,
1218
head: [
1319
["link", {rel: "icon", href: "/fight_favicon.ico"}]
1420
],
21+
markdown: {
22+
// todo 引入代码文件时的路径替换
23+
importCode: {
24+
handleImportPath: (str) =>{
25+
return str.replace(/^@code/, path.resolve(__dirname, '../../code/'))
26+
},
27+
},
28+
},
1529
// 主题配置
1630
...themeConfig,
1731
// 插件配置
1832
...pluginsConfig,
19-
};
33+
shouldPrefetch: false,
34+
})
2035

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
export const FOOTER_HTML_INFO=`Copyrights ©2019-${new Date().getFullYear()}
32
<a href="https://github.com/mmdapl" target="_blank">Chu·Fan</a> All Rights Reserved Rong姐姐好可爱`
43

File renamed without changes.

docs/.vuepress/config/navbar/read-books.js renamed to docs/.vuepress/config/navbar/read-books.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
export default {
22
text: "读书整理",
3+
collapsible: true,
34
children: [
45
{
56
text: "技术类",
7+
collapsible: true,
68
children: [
79
{
810
text: "ES6标准入门",
911
link: "/school",
1012
},
1113
{
1214
text: "了不起的Node.js",
13-
link: "/",
15+
link: "/read-books/cs-books/深入浅出的Node.js",
1416
},
1517
{
1618
text: "深入浅出Node.js",
17-
link: "/go",
19+
link: "/read-books/cs-books/深入浅出的Node.js",
1820
},
1921
{
2022
text: "高性能Web服务器详解【Nginx】",

docs/.vuepress/config/plugins.config.js renamed to docs/.vuepress/config/plugins.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default {
1111
// 为分类和标签添加索引
1212
customFields: [
1313
{
14-
getter: (page) => page.frontmatter.category,
14+
getter: (page:any) => page.frontmatter.category,
1515
formatter: "分类:$content",
1616
},
1717
{

docs/.vuepress/config/sidebar/index.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import readBooksContentSidebar from "./read-books-content.sidebar";
2+
import frontEnd from "../navbar/front-end";
3+
import serverEnd from "../navbar/server-end";
4+
import microservice from "../navbar/microservice";
5+
import devTool from "../navbar/dev-tool";
6+
import soloAlgorithm from "../navbar/solo-algorithm";
7+
import battleInterview from "../navbar/battle-interview";
8+
import readBooks from "../navbar/read-books";
9+
10+
export default {
11+
"/read-books": readBooksContentSidebar,
12+
"/":[{
13+
text: "首页", link: "/",
14+
},
15+
frontEnd,
16+
serverEnd,
17+
microservice,
18+
devTool,
19+
soloAlgorithm,
20+
battleInterview,
21+
readBooks,
22+
{
23+
text:"其他",
24+
children: [
25+
{
26+
text: "常用网站",
27+
link: "/sum-links",
28+
},
29+
{
30+
text: "技术文档",
31+
link:'/test'
32+
},
33+
{
34+
text: "todo计划",
35+
link: "/sum-links",
36+
},
37+
{
38+
text: "变更记录",
39+
link: "/sum-links",
40+
},
41+
],
42+
}]
43+
}

docs/.vuepress/config/sidebar/read-books-content.sidebar.js renamed to docs/.vuepress/config/sidebar/read-books-content.sidebar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default [
22
{
3-
text: "Foo",
3+
text: "测试",
44
link: "/foo/",
55
children: [
66
// SidebarItem

docs/.vuepress/config/theme.config.js renamed to docs/.vuepress/config/theme.config.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default {
3232
sidebar: sidebar,
3333
// sidebar: "heading",
3434

35+
pageInfo: ["Author", "Original", "Date", "Category", "Tag", "ReadingTime"],
3536
// 主题布局选项
3637
docsRepo: "https://github.com/142vip/JavaScriptCollection.git",
3738
repo: "https://github.com/142vip/JavaScriptCollection",
@@ -45,7 +46,7 @@ export default {
4546
intro: '',
4647
roundAvatar: true,
4748
timeline: "时间轴的顶部文字",
48-
articleInfo: "",
49+
// articleInfo: "",
4950
medias: {
5051
"BiliBili": "https://space.bilibili.com/350937042?spm_id_from=333.1007.0.0"
5152
}
@@ -79,6 +80,30 @@ export default {
7980
imgMark: true,
8081
// 启用图片大小
8182
imgSize: true,
83+
playground: {
84+
presets: ["ts", "vue"],
85+
},
86+
presentation: {
87+
plugins: ["highlight", "math", "search", "notes", "zoom"],
88+
},
89+
stylize: [
90+
{
91+
matcher: "Recommended",
92+
replacer: ({ tag }) => {
93+
if (tag === "em")
94+
return {
95+
tag: "Badge",
96+
attrs: { type: "tip" },
97+
content: "Recommended",
98+
};
99+
},
100+
},
101+
],
102+
sub: true,
103+
sup: true,
104+
tabs: true,
105+
vPre: true,
106+
vuePlayground: true,
82107
},
83108
copyCode: {
84109
showInMobile: true

docs/.vuepress/styles/config.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// 参考:https://theme-hope.vuejs.press/zh/guide/interface/code-theme.htm
22

33
// 浅色主题
4-
$code-light-them: "dark";
4+
$code-light-them: "atom-dark";
55

66
// 深色主题
77
$code-dark-theme: "atom-dark";

docs/.vuepress/styles/palette.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// 主题色
2-
$theme-color: #2196f3;
2+
$theme-color: #2980B9;

docs/quick-start.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@
2323
</p>
2424

2525

26-
<!-- ## -->
27-
<div align="center" style="font-size:20px">
26+
<div style="font-size:20px;text-align: center">
2827
<!-- <a href="https://gitee.com/mmdapl/JavaScriptCollection" target="_blank">国内访问</a> -->
2928
<!-- ||
3029
<a href="readme-wechat.md" target="_blank">微信版</a> -->
3130
</div>
3231

33-
##
3432

3533
## 写最前面
3634

@@ -52,9 +50,6 @@
5250
## 日常推荐
5351

5452

55-
- [云服务器推荐](docs/recommend/云服务器推荐.md)
56-
- [学习网站、使用工具](docs/recommend/学习网站、效率工具.md)
57-
- [值得细读的技术文章推荐](docs/recommend/值得细读的技术文章推荐.md)
5853

5954

6055
## 文章笔记

docs/server-end/database/redis/sentinel.md

Lines changed: 4 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Redis的Sentinel系统用于管理多个Redis,主要执行:
77
- 提醒:当某个Redis服务器出现故障,可通过API或者其他应用程序发送通知
88
- 自动故障迁移:当一个主服务器不能正常工作时,Sentinel会进行一次故障自动迁移,会将失效主服务器的从服务器选举出一个新的主服务器,剩下的从服务器将会自动连接复制选举出来的新服务器的数据。
99
- 配置提供者:在 Redis Sentinel 模式下,客户端应用 在初始化时连接的是 Sentinel 节点集合,从中获取主节点 的信息。
10+
1011

1112
![基本原理](./sentinel.png)
1213

@@ -29,98 +30,9 @@ Redis的Sentinel系统是一个分布式的系统,可以在系统中配置一
2930

3031
### 快速搭建
3132

32-
```yaml
33-
##
34-
## 功能:redis主从集群 1主2从
35-
## 使用:
36-
## - docker-compose up -d
37-
## 默认密码:123456
38-
##
39-
## 参考链接:https://blog.51cto.com/u_15127508/4395149
33+
@[code yaml](@code/redis/sentinel/docker-compose.yaml)
4034

41-
version: '2'
42-
services:
43-
redis-master-6380:
44-
image: redis:latest
45-
container_name: redis-master-6380
46-
restart: always
47-
command: redis-server --port 6380 --requirepass 123456 --appendonly yes
48-
ports:
49-
- "6380:6380"
50-
networks:
51-
net:
52-
ipv4_address: 172.19.0.3
5335

54-
redis-slave-6381:
55-
image: redis:latest
56-
container_name: redis-slave-6381
57-
restart: always
58-
command: redis-server --slaveof redis-master-6380 6380 --port 6381 --requirepass 123456 --masterauth 123456 --appendonly yes
59-
ports:
60-
- "6381:6381"
61-
networks:
62-
net:
63-
ipv4_address: 172.19.0.4
36+
@[code conf{1-3}](@code/redis/sentinel/conf/redis-sentinel-26380.conf)
6437

65-
redis-slave-6382:
66-
image: redis:latest
67-
container_name: redis-slave-6382
68-
restart: always
69-
command: redis-server --slaveof redis-master-6380 6380 --port 6382 --requirepass 123456 --masterauth 123456 --appendonly yes
70-
ports:
71-
- "6382:6382"
72-
networks:
73-
net:
74-
ipv4_address: 172.19.0.5
75-
76-
77-
redis-sentinel-26380:
78-
image: redis:latest
79-
container_name: redis-sentinel-26380
80-
ports:
81-
- "26380:26379"
82-
command: redis-sentinel /usr/local/etc/redis/sentinel.conf
83-
volumes:
84-
- ./conf/redis-sentinel-26380.conf:/usr/local/etc/redis/sentinel.conf
85-
networks:
86-
net:
87-
ipv4_address: 172.19.0.11
88-
89-
redis-sentinel-26381:
90-
image: redis:latest
91-
container_name: redis-sentinel-26381
92-
ports:
93-
- "26381:26379"
94-
command: redis-sentinel /usr/local/etc/redis/sentinel.conf
95-
volumes:
96-
- ./conf/redis-sentinel-26381.conf:/usr/local/etc/redis/sentinel.conf
97-
networks:
98-
net:
99-
ipv4_address: 172.19.0.12
100-
101-
redis-sentinel-26382:
102-
image: redis:latest
103-
container_name: redis-sentinel-26382
104-
ports:
105-
- "26382:26379"
106-
command: redis-sentinel /usr/local/etc/redis/sentinel.conf
107-
volumes:
108-
- ./conf/redis-sentinel-26382.conf:/usr/local/etc/redis/sentinel.conf
109-
networks:
110-
net:
111-
ipv4_address: 172.19.0.13
112-
## 创建桥接网络
113-
networks:
114-
## 桥接网络名称,配合文件前缀,最后为dev_test_env_net 参考:https://www.jianshu.com/p/d70c61d45364
115-
net:
116-
driver: bridge
117-
# external: true
118-
ipam:
119-
driver: default
120-
config:
121-
- subnet: 172.19.0.0/24
122-
## 网关
123-
gateway: 172.19.0.1
124-
```
125-
126-
[//]: # (注意修改各容器redis映射的配置文件;[源码]&#40;../../../../code/redis/sentinel&#41;)
38+
注意修改各容器redis映射的配置文件;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"devDependencies": {
1717
"@vuepress/client": "2.0.0-beta.60",
18+
"@vuepress/utils": "2.0.0-beta.60",
1819
"eslint": "^8.34.0",
1920
"vue": "^3.2.47",
2021
"vuepress": "2.0.0-beta.60",

0 commit comments

Comments
 (0)