Skip to content

Commit 4c3ab73

Browse files
committed
feat: 更新配置
1 parent c82e9d7 commit 4c3ab73

File tree

12 files changed

+209
-104
lines changed

12 files changed

+209
-104
lines changed

.babelrc

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

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: [14.x]
18+
node-version: [16.x]
1919

2020
steps:
2121
# 使用的动作。格式:userName/repoName。作用:检出仓库,获取源码。 官方actions库:https://github.com/actions

docs/.vuepress/config.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ module.exports = {
1212
// 注入到页面<head> 中的标签,格式[tagName, { attrName: attrValue }, innerHTML?]
1313
['link', { rel: 'icon', href: '/img/favicon.ico' }], //favicons,资源放在public文件夹
1414
['meta', { name: 'keywords', content: 'vuepress,theme,blog,vdoing' }],
15-
['meta', { name: 'theme-color', content: '#11a8cd' }] // 移动浏览器主题颜色
15+
['meta', { name: 'theme-color', content: '#11a8cd' }], // 移动浏览器主题颜色
16+
17+
['meta', { name: 'wwads-cn-verify', content: 'mxqWx62nfQQ9ocT4e5DzISHzOWyF4s' }], // 广告相关,你可以去掉
18+
['script', { src: 'https://cdn.wwads.cn/js/makemoney.js', type: 'text/javascript' }], // 广告相关,你可以去掉
1619
],
1720
markdown: {
1821
// lineNumbers: true,
@@ -63,9 +66,10 @@ module.exports = {
6366
editLinkText: '📝 帮助改善此页面!',
6467

6568
// 以下配置是Vdoing主题改动的和新增的配置
66-
sidebar: { mode: 'structuring', collapsable: false }, // 侧边栏 'structuring' | { mode: 'structuring', collapsable: Boolean} | 'auto' | 自定义 温馨提示:目录页数据依赖于结构化的侧边栏数据,如果你不设置为'structuring',将无法使用目录页
69+
sidebar: { mode: 'structuring', collapsable: true }, // 侧边栏 'structuring' | { mode: 'structuring', collapsable:
70+
// Boolean} | 'auto' | 自定义 温馨提示:目录页数据依赖于结构化的侧边栏数据,如果你不设置为'structuring',将无法使用目录页
6771

68-
// sidebarOpen: false, // 初始状态是否打开侧边栏,默认true
72+
sidebarOpen: true, // 初始状态是否打开侧边栏,默认true
6973
updateBar: {
7074
// 最近更新栏
7175
showToArticle: true // 显示到文章页底部,默认true

docs/.vuepress/config/htmlModules.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,42 @@
2020

2121
module.exports = {
2222
// 万维广告
23-
pageB: `
24-
<div class="wwads-cn wwads-horizontal pageB" data-id="136" style="width:100%;max-height:80px;min-height:auto;"></div>
25-
<style>
26-
.pageB img{width:80px!important;}
27-
.wwads-horizontal .wwads-text, .wwads-content .wwads-text{line-height:1;}
28-
</style>
29-
`,
23+
// pageT: `
24+
// <div class="wwads-cn wwads-horizontal page-wwads" data-id="261"></div>
25+
// <style>
26+
// .page-wwads{
27+
// width:100%!important;
28+
// min-height: 0;
29+
// margin: 0;
30+
// }
31+
// .page-wwads .wwads-img img{
32+
// width:80px!important;
33+
// }
34+
// .page-wwads .wwads-poweredby{
35+
// width: 40px;
36+
// position: absolute;
37+
// right: 25px;
38+
// bottom: 3px;
39+
// }
40+
// .wwads-content .wwads-text, .page-wwads .wwads-text{
41+
// height: 100%;
42+
// padding-top: 5px;
43+
// display: block;
44+
// }
45+
// </style>
46+
// `,
3047
windowRB: `
31-
<div class="wwads-cn wwads-vertical windowRB" data-id="136" style="max-width:160px;
48+
<div class="wwads-cn wwads-vertical windowRB" data-id="261" style="max-width:160px;
3249
min-width: auto;min-height:auto;"></div>
3350
<style>
3451
.windowRB{ padding: 0;}
3552
.windowRB .wwads-img{margin-top: 10px;}
36-
.windowRB .wwads-content{margin: 0 10px 10px 10px;}
53+
.windowRB .wwads-content{margin: 0 10px 40px 10px;}
3754
.custom-html-window-rb .close-but{
3855
display: none;
3956
}
4057
</style>
41-
`
58+
`,
4259
}
4360

4461
// module.exports = {

docs/.vuepress/enhanceApp.js

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,59 @@
1-
// import vue from 'vue/dist/vue.esm.browser'
1+
/**
2+
* to主题使用者:你可以去掉本文件的所有代码
3+
*/
24
export default ({
35
Vue, // VuePress 正在使用的 Vue 构造函数
46
options, // 附加到根实例的一些选项
57
router, // 当前应用的路由实例
6-
siteData // 站点元数据
8+
siteData, // 站点元数据
9+
isServer // 当前应用配置是处于 服务端渲染 还是 客户端
710
}) => {
8-
// window.Vue = vue // 使页面中可以使用Vue构造函数 (使页面中的vue demo生效)
11+
12+
// 用于监控在路由变化时检查广告拦截器 (to主题使用者:你可以去掉本文件的所有代码)
13+
if (!isServer) {
14+
router.afterEach(() => {
15+
//check if wwads' fire function was blocked after document is ready with 3s timeout (waiting the ad loading)
16+
docReady(function () {
17+
setTimeout(function () {
18+
if (window._AdBlockInit === undefined) {
19+
ABDetected();
20+
}
21+
}, 3000);
22+
});
23+
24+
// 删除事件改为隐藏事件
25+
setTimeout(() => {
26+
const pageAD = document.querySelector('.page-wwads');
27+
if (!pageAD) return;
28+
const btnEl = pageAD.querySelector('.wwads-hide');
29+
if (btnEl) {
30+
btnEl.onclick = () => {
31+
pageAD.style.display = 'none';
32+
}
33+
}
34+
// 显示广告模块
35+
if (pageAD.style.display === 'none') {
36+
pageAD.style.display = 'flex';
37+
}
38+
}, 900);
39+
})
40+
}
41+
}
42+
43+
44+
function ABDetected() {
45+
const h = "<style>.wwads-horizontal,.wwads-vertical{background-color:#f4f8fa;padding:5px;min-height:120px;margin-top:20px;box-sizing:border-box;border-radius:3px;font-family:sans-serif;display:flex;min-width:150px;position:relative;overflow:hidden;}.wwads-horizontal{flex-wrap:wrap;justify-content:center}.wwads-vertical{flex-direction:column;align-items:center;padding-bottom:32px}.wwads-horizontal a,.wwads-vertical a{text-decoration:none}.wwads-horizontal .wwads-img,.wwads-vertical .wwads-img{margin:5px}.wwads-horizontal .wwads-content,.wwads-vertical .wwads-content{margin:5px}.wwads-horizontal .wwads-content{flex:130px}.wwads-vertical .wwads-content{margin-top:10px}.wwads-horizontal .wwads-text,.wwads-content .wwads-text{font-size:14px;line-height:1.4;color:#0e1011;-webkit-font-smoothing:antialiased}.wwads-horizontal .wwads-poweredby,.wwads-vertical .wwads-poweredby{display:block;font-size:11px;color:#a6b7bf;margin-top:1em}.wwads-vertical .wwads-poweredby{position:absolute;left:10px;bottom:10px}.wwads-horizontal .wwads-poweredby span,.wwads-vertical .wwads-poweredby span{transition:all 0.2s ease-in-out;margin-left:-1em}.wwads-horizontal .wwads-poweredby span:first-child,.wwads-vertical .wwads-poweredby span:first-child{opacity:0}.wwads-horizontal:hover .wwads-poweredby span,.wwads-vertical:hover .wwads-poweredby span{opacity:1;margin-left:0}.wwads-horizontal .wwads-hide,.wwads-vertical .wwads-hide{position:absolute;right:-23px;bottom:-23px;width:46px;height:46px;border-radius:23px;transition:all 0.3s ease-in-out;cursor:pointer;}.wwads-horizontal .wwads-hide:hover,.wwads-vertical .wwads-hide:hover{background:rgb(0 0 0 /0.05)}.wwads-horizontal .wwads-hide svg,.wwads-vertical .wwads-hide svg{position:absolute;left:10px;top:10px;fill:#a6b7bf}.wwads-horizontal .wwads-hide:hover svg,.wwads-vertical .wwads-hide:hover svg{fill:#3E4546}</style><a href='https://wwads.cn/page/whitelist-wwads' class='wwads-img' target='_blank' rel='nofollow'><img src='https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/blog/wwads.2a3pidhlh4ys.webp' width='130'></a><div class='wwads-content'><a href='https://wwads.cn/page/whitelist-wwads' class='wwads-text' target='_blank' rel='nofollow'>为了本站的长期运营,请将我们的网站加入广告拦截器的白名单,感谢您的支持!<span style='color: #11a8cd'>如何添加白名单?</span></a><a href='https://wwads.cn/page/end-user-privacy' class='wwads-poweredby' title='万维广告 ~ 让广告更优雅,且有用' target='_blank'><span>广告</span></a></div><a class='wwads-hide' onclick='parentNode.remove()' title='隐藏广告'><svg xmlns='http://www.w3.org/2000/svg' width='6' height='7'><path d='M.879.672L3 2.793 5.121.672a.5.5 0 11.707.707L3.708 3.5l2.12 2.121a.5.5 0 11-.707.707l-2.12-2.12-2.122 2.12a.5.5 0 11-.707-.707l2.121-2.12L.172 1.378A.5.5 0 01.879.672z'></path></svg></a>";
46+
const wwadsEl = document.getElementsByClassName("wwads-cn");
47+
const wwadsContentEl = document.querySelector('.wwads-content');
48+
if (wwadsEl[0] && !wwadsContentEl) {
49+
wwadsEl[0].innerHTML = h;
50+
}
51+
};
52+
53+
//check document ready
54+
function docReady(t) {
55+
"complete" === document.readyState ||
56+
"interactive" === document.readyState
57+
? setTimeout(t, 1)
58+
: document.addEventListener("DOMContentLoaded", t);
959
}

package.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "java-tutorial",
2+
"name": "db-tutorial",
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
66
"clean": "rimraf docs/.temp",
7-
"start": "vuepress dev docs",
8-
"build": "vuepress build docs",
7+
"start": "node --max_old_space_size=4096 ./node_modules/vuepress/cli.js dev docs",
8+
"build": "node --max_old_space_size=4096 ./node_modules/vuepress/cli.js build docs",
99
"deploy": "bash scripts/deploy.sh",
1010
"updateTheme": "yarn remove vuepress-theme-vdoing && rm -rf node_modules && yarn && yarn add vuepress-theme-vdoing -D",
1111
"editFm": "node utils/editFrontmatter.js",
@@ -15,19 +15,23 @@
1515
"view-info": "vuepress view-info ./ --temp docs/.temp"
1616
},
1717
"devDependencies": {
18-
"dayjs": "^1.9.7",
19-
"inquirer": "^7.1.0",
18+
"dayjs": "^1.11.7",
19+
"inquirer": "^9.1.4",
2020
"json2yaml": "^1.1.0",
21-
"vuepress": "1.9.2",
21+
"markdownlint-cli": "^0.33.0",
22+
"markdownlint-rule-emphasis-style": "^1.0.1",
23+
"rimraf": "^4.1.2",
24+
"vue-toasted": "^1.1.25",
25+
"vuepress": "1.9.9",
2226
"vuepress-plugin-baidu-tongji": "^1.0.1",
2327
"vuepress-plugin-comment": "^0.7.3",
2428
"vuepress-plugin-demo-block": "^0.7.2",
29+
"vuepress-plugin-flowchart": "^1.4.2",
2530
"vuepress-plugin-fulltext-search": "^2.2.1",
2631
"vuepress-plugin-one-click-copy": "^1.0.2",
2732
"vuepress-plugin-thirdparty-search": "^1.0.2",
2833
"vuepress-plugin-zooming": "^1.1.7",
29-
"vuepress-plugin-flowchart": "^1.4.2",
30-
"vuepress-theme-vdoing": "^1.10.3",
34+
"vuepress-theme-vdoing": "^1.12.9",
3135
"yamljs": "^0.3.0",
3236
"markdownlint-cli": "^0.25.0",
3337
"markdownlint-rule-emphasis-style": "^1.0.1",

prettier.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @see https://prettier.io/docs/en/options.html
3+
* @see https://prettier.io/docs/en/configuration.html
4+
*/
5+
module.exports = {
6+
tabWidth: 2,
7+
semi: false,
8+
singleQuote: true,
9+
trailingComma: 'none'
10+
}

scripts/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# ------------------------------------------------------------------------------
44
# gh-pages 部署脚本
5-
# @author Zhang Peng
5+
# @author <a href="mailto:forbreak@163.com">Zhang Peng</a>
66
# @since 2020/2/10
77
# ------------------------------------------------------------------------------
88

utils/config.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
#批量添加和修改、删除front matter配置文件
1+
# 批量添加和修改、删除front matter配置文件
22

3-
# 需要批量处理的路径,docs文件夹内的文件夹 (数组映射路径:docs/arr[0]/arr[1] ... )
3+
# 需要批量处理的路径,docs文件夹内的文件夹 (数组映射路径:path[0]/path[1]/path[2] ... )
44
path:
55
- docs # 第一个成员必须是docs
66

77
# 要删除的字段 (数组)
8-
delete:
9-
# - test
8+
delete:
109
# - tags
1110

12-
# 要添加、修改front matter的数据 (front matter中没有的数据则添加,已有的数据则覆盖)
11+
# 要添加、修改front matter的数据 (front matter中没有的数据则添加,已有的数据则覆盖)
1312
data:
14-
article: false
13+
# author:
14+
# name: xugaoyi
15+
# link: https://github.com/xugaoyi

utils/editFrontmatter.js

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
/**
22
* 批量添加和修改front matter ,需要配置 ./config.yml 文件。
33
*/
4-
const fs = require('fs'); // 文件模块
5-
const path = require('path'); // 路径模块
6-
const matter = require('gray-matter'); // front matter解析器 https://github.com/jonschlinkert/gray-matter
4+
const fs = require('fs') // 文件模块
5+
const path = require('path') // 路径模块
6+
const matter = require('gray-matter') // front matter解析器 https://github.com/jonschlinkert/gray-matter
77
const jsonToYaml = require('json2yaml')
88
const yamlToJs = require('yamljs')
99
const inquirer = require('inquirer') // 命令行操作
1010
const chalk = require('chalk') // 命令行打印美化
11-
const readFileList = require('./modules/readFileList');
12-
const { type, repairDate} = require('./modules/fn');
11+
const readFileList = require('./modules/readFileList')
12+
const { type, repairDate } = require('./modules/fn')
1313
const log = console.log
1414

1515
const configPath = path.join(__dirname, 'config.yml') // 配置文件的路径
1616

17-
main();
17+
main()
1818

1919
/**
2020
* 主体函数
2121
*/
2222
async function main() {
23+
const promptList = [
24+
{
25+
type: 'confirm',
26+
message: chalk.yellow('批量操作frontmatter有修改数据的风险,确定要继续吗?'),
27+
name: 'edit'
28+
}
29+
]
30+
let edit = true
2331

24-
const promptList = [{
25-
type: "confirm",
26-
message: chalk.yellow('批量操作frontmatter有修改数据的风险,确定要继续吗?'),
27-
name: "edit",
28-
}];
29-
let edit = true;
30-
31-
await inquirer.prompt(promptList).then(answers => {
32+
await inquirer.prompt(promptList).then((answers) => {
3233
edit = answers.edit
3334
})
3435

35-
if(!edit) { // 退出操作
36+
if (!edit) {
37+
// 退出操作
3638
return
3739
}
38-
40+
3941
const config = yamlToJs.load(configPath) // 解析配置文件的数据转为js对象
4042

4143
if (type(config.path) !== 'array') {
@@ -48,27 +50,26 @@ async function main() {
4850
return
4951
}
5052

51-
const filePath = path.join(__dirname, '..', ...config.path); // 要批量修改的文件路径
52-
const files = readFileList(filePath); // 读取所有md文件数据
53+
const filePath = path.join(__dirname, '..', ...config.path) // 要批量修改的文件路径
54+
const files = readFileList(filePath) // 读取所有md文件数据
5355

54-
files.forEach(file => {
55-
let dataStr = fs.readFileSync(file.filePath, 'utf8');// 读取每个md文件的内容
56+
files.forEach((file) => {
57+
let dataStr = fs.readFileSync(file.filePath, 'utf8') // 读取每个md文件的内容
5658
const fileMatterObj = matter(dataStr) // 解析md文件的front Matter。 fileMatterObj => {content:'剔除frontmatter后的文件内容字符串', data:{<frontmatter对象>}, ...}
57-
let matterData = fileMatterObj.data; // 得到md文件的front Matter
58-
59+
let matterData = fileMatterObj.data // 得到md文件的front Matter
60+
5961
let mark = false
6062
// 删除操作
6163
if (config.delete) {
62-
if( type(config.delete) !== 'array' ) {
64+
if (type(config.delete) !== 'array') {
6365
log(chalk.yellow('未能完成删除操作,delete字段的值应该是一个数组!'))
6466
} else {
65-
config.delete.forEach(item => {
67+
config.delete.forEach((item) => {
6668
if (matterData[item]) {
6769
delete matterData[item]
6870
mark = true
6971
}
7072
})
71-
7273
}
7374
}
7475

@@ -77,16 +78,21 @@ async function main() {
7778
Object.assign(matterData, config.data) // 将配置数据合并到front Matter对象
7879
mark = true
7980
}
80-
81+
8182
// 有操作时才继续
8283
if (mark) {
83-
if(matterData.date && type(matterData.date) === 'date') {
84+
if (matterData.date && type(matterData.date) === 'date') {
8485
matterData.date = repairDate(matterData.date) // 修复时间格式
8586
}
86-
const newData = jsonToYaml.stringify(matterData).replace(/\n\s{2}/g,"\n").replace(/"/g,"") + '---\r\n' + fileMatterObj.content;
87-
fs.writeFileSync(file.filePath, newData); // 写入
87+
const newData =
88+
jsonToYaml
89+
.stringify(matterData)
90+
.replace(/\n\s{2}/g, '\n')
91+
.replace(/"/g, '') +
92+
'---\r\n' +
93+
fileMatterObj.content
94+
fs.writeFileSync(file.filePath, newData) // 写入
8895
log(chalk.green(`update frontmatter:${file.filePath} `))
8996
}
90-
9197
})
9298
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy