From 0e1a6fd0f73bdfb6accacaba403da5aba290805d Mon Sep 17 00:00:00 2001
From: xugaoyi <894072666@qq.com>
Date: Thu, 10 Dec 2020 21:59:57 +0800
Subject: [PATCH] v1.6.0
---
package.json | 5 +-
theme-vdoing/components/ArticleInfo.vue | 16 +++++
theme-vdoing/components/Catalogue.vue | 53 +++++++++++++--
theme-vdoing/components/SidebarGroup.vue | 4 +-
theme-vdoing/node_utils/setFrontmatter.js | 80 ++++++++++++++++-------
theme-vdoing/package.json | 2 +-
6 files changed, 126 insertions(+), 34 deletions(-)
diff --git a/package.json b/package.json
index 15289ad..a43e3a9 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,8 @@
"deploy": "bash deploy.sh",
"editFm": "node utils/editFrontmatter.js",
"baiduPush": "node utils/baiduPush.js https://xugaoyi.com && bash baiduPush.sh",
- "publish": "cd theme-vdoing && npm publish && cd ../ && npm update vuepress-theme-vdoing"
+ "publish": "cd theme-vdoing && npm publish && cd ../ && npm run updateTheme",
+ "updateTheme": "npm uninstall vuepress-theme-vdoing && rm -rf node_modules && npm i && npm i vuepress-theme-vdoing"
},
"license": "MIT",
"devDependencies": {
@@ -21,7 +22,7 @@
"vuepress-plugin-one-click-copy": "^1.0.2",
"vuepress-plugin-thirdparty-search": "^1.0.2",
"vuepress-plugin-zooming": "^1.1.7",
- "vuepress-theme-vdoing": "^1.5.3",
+ "vuepress-theme-vdoing": "^1.6.0",
"yamljs": "^0.3.0"
},
"dependencies": {
diff --git a/theme-vdoing/components/ArticleInfo.vue b/theme-vdoing/components/ArticleInfo.vue
index febe5f0..185bc17 100644
--- a/theme-vdoing/components/ArticleInfo.vue
+++ b/theme-vdoing/components/ArticleInfo.vue
@@ -38,6 +38,19 @@
>{{articleInfo.classify2}}
{{articleInfo.classify2}}
+
+ {{articleInfo.classify3}}
+ {{articleInfo.classify3}}
+ {{articleInfo.classify3}}
+
1 ? classifyArr[1] : classifyArr[0] // 文章一级分类名称
const classify2 = relativePathArr.length > 2 ? relativePathArr[1].split('.')[1] : undefined// 文章二级分类名称
+ const classify3 = relativePathArr.length > 3 ? relativePathArr[2].split('.')[1] : undefined// 文章三级分类名称
const cataloguePermalink = sidebar && sidebar.catalogue ? sidebar.catalogue[classify1] : undefined// 目录页永久链接
@@ -119,6 +134,7 @@ export default {
date,
classify1,
classify2,
+ classify3,
cataloguePermalink,
author,
categories
diff --git a/theme-vdoing/components/Catalogue.vue b/theme-vdoing/components/Catalogue.vue
index 929a6ae..dcc0f0e 100644
--- a/theme-vdoing/components/Catalogue.vue
+++ b/theme-vdoing/components/Catalogue.vue
@@ -30,6 +30,7 @@
v-else-if="type(item) === 'object'"
:key="index"
>
+
- {{`${index+1}-${i+1}. ${s[1]}`}}
+
+
+
+ {{`${index+1}-${i+1}. ${c[1]}`}}
+
+
+
+
+
+ {{`${index+1}-${i+1}. ${c.title}`}}
+
+
+ {{`${index+1}-${i+1}-${ii+1}. ${cc[1]}`}}
+
+
+
@@ -88,7 +118,7 @@ export default {
if (!catalogueList) {
console.error('未获取到目录数据,请查看front matter中设置的key是否正确。')
}
-
+ console.log(catalogueList)
return catalogueList
},
type (o) { // 数据类型检查
@@ -154,4 +184,15 @@ dl, dd
width 50%
@media (max-width $MQMobileNarrow)
width 100%
+ .sub-cat-wrap
+ margin 5px 0 8px 0
+ font-size .9rem
+ .sub-title
+ margin-top -($navbarHeight)
+ padding-top $navbarHeight
+ margin-bottom 5px
+ font-size 1rem
+ &:hover
+ .header-anchor
+ opacity 1
diff --git a/theme-vdoing/components/SidebarGroup.vue b/theme-vdoing/components/SidebarGroup.vue
index 5f2b0a4..3693422 100644
--- a/theme-vdoing/components/SidebarGroup.vue
+++ b/theme-vdoing/components/SidebarGroup.vue
@@ -81,7 +81,7 @@ export default {
&.is-sub-group
padding-left 0
& > .sidebar-heading
- font-size 0.95em
+ font-size 1em
line-height 1.4
font-weight normal
padding-left 2rem
@@ -90,7 +90,7 @@ export default {
& > .sidebar-group-items
padding-left 1rem
& > li > .sidebar-link
- font-size 0.95em
+ font-size 0.98em
border-left none
&.depth-2
& > .sidebar-heading
diff --git a/theme-vdoing/node_utils/setFrontmatter.js b/theme-vdoing/node_utils/setFrontmatter.js
index fb985f5..fe94507 100644
--- a/theme-vdoing/node_utils/setFrontmatter.js
+++ b/theme-vdoing/node_utils/setFrontmatter.js
@@ -28,30 +28,60 @@ function setFrontmatter (sourceDir, themeConfig) {
// fileMatterObj => {content:'剔除frontmatter后的文件内容字符串', data:{}, ...}
const fileMatterObj = matter(dataStr);
- if (Object.keys(fileMatterObj.data).length === 0) { // 未定义FrontMatter数据
- const stat = fs.statSync(file.filePath);
- const dateStr = dateFormat(getBirthtime(stat));// 文件的创建时间
- const categories = getCategories(file, categoryText)
+ if (Object.keys(fileMatterObj.data).length === 0) {
+ // 未定义FrontMatter数据
+ const stat = fs.statSync(file.filePath)
+ const dateStr = dateFormat(
+ getBirthtime(stat)
+ ) // 文件的创建时间
+ const categories = getCategories(
+ file,
+ categoryText
+ )
- // 注意下面这些反引号字符串的格式会映射到文件
- const cateStr = isCategory === false ? '' : `
-categories:
- - ${categories[0]}${categories[1] ? '\r\n - ' + categories[1] : ''}`;
+ let cateLabelStr = ''
+ categories.forEach(((item)) => {
+ cateLabelStr += '\r\n - ' + item
+ })
- const tagsStr = isTag === false ? '' : `
+ let cateStr = ''
+ if (!(isCategory === false)) {
+ cateStr = '\r\ncategories:' + cateLabelStr
+ }
+
+ // 注意下面这些反引号字符串的格式会映射到文件
+ // const cateStr = isCategory === false ? '' : `
+ // categories:
+ // - ${categories[0]}${categories[1] ? '\r\n - ' + categories[1] : ''}`;
+
+ const tagsStr =
+ isTag === false
+ ? ''
+ : `
tags:
- - `;
+ - `
- const fmData = `---
+ const fmData = `---
title: ${file.name}
date: ${dateStr}
-permalink: ${getPermalink()}${file.filePath.indexOf('_posts') > -1 ? '\r\nsidebar: auto' : ''}${cateStr}${tagsStr}
----`;
+permalink: ${getPermalink()}${
+ file.filePath.indexOf('_posts') > -1
+ ? '\r\nsidebar: auto'
+ : ''
+ }${cateStr}${tagsStr}
+---`
- fs.writeFileSync(file.filePath, `${fmData}\r\n${fileMatterObj.content}`); // 写入
- log(chalk.blue('tip ') + chalk.green(`write frontmatter(写入frontmatter):${file.filePath} `))
-
- } else { // 已有FrontMatter
+ fs.writeFileSync(
+ file.filePath,
+ `${fmData}\r\n${fileMatterObj.content}`
+ ) // 写入
+ log(
+ chalk.blue('tip ') +
+ chalk.green(
+ `write frontmatter(写入frontmatter):${file.filePath} `
+ )
+ )
+ } else { // 已有FrontMatter
const matterData = fileMatterObj.data;
let mark = false;
@@ -106,13 +136,17 @@ permalink: ${getPermalink()}${file.filePath.indexOf('_posts') > -1 ? '\r\nsideba
function getCategories (file, categoryText) {
let categories = []
- if (file.filePath.indexOf('_posts') === -1) { // 不在_posts文件夹
- const filePathArr = file.filePath.split(path.sep) // path.sep用于兼容不同系统下的路径斜杠
- const c = filePathArr[filePathArr.length - 3].split('.').pop() // 获取分类1
- if (c !== 'docs') {
- categories.push(c)
+ if (file.filePath.indexOf('_posts') === -1) {
+ // 不在_posts文件夹
+ let filePathArr = file.filePath.split(path.sep) // path.sep用于兼容不同系统下的路径斜杠
+ filePathArr.pop()
+
+ let ind = filePathArr.indexOf('docs')
+ if (ind !== -1) {
+ while (filePathArr[++ind] !== undefined) {
+ categories.push(filePathArr[ind].split('.').pop()) // 获取分类
+ }
}
- categories.push(filePathArr[filePathArr.length - 2].split('.').pop()) // 获取分类2
} else {
categories.push(categoryText)
}
diff --git a/theme-vdoing/package.json b/theme-vdoing/package.json
index 632ed72..0fca125 100644
--- a/theme-vdoing/package.json
+++ b/theme-vdoing/package.json
@@ -1,6 +1,6 @@
{
"name": "vuepress-theme-vdoing",
- "version": "1.5.3",
+ "version": "1.6.0",
"description": "Vdoing theme for VuePress. 一个基于VuePress的知识管理兼博客主题。",
"author": {
"name": "gaoyi(Evan) Xu"