Skip to content

Commit

Permalink
v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
xugaoyi committed Aug 8, 2020
1 parent 23454cf commit 39197d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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.4.0",
"vuepress-theme-vdoing": "^1.4.1",
"yamljs": "^0.3.0"
},
"dependencies": {
Expand Down
14 changes: 9 additions & 5 deletions theme-vdoing/node_utils/setFrontmatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const PREFIX = '/pages/'


/**
* 给.md文件设置frontmatter(标题、日期、永久链接)
* 给.md文件设置frontmatter(标题、日期、永久链接等数据)
*/
function setFrontmatter(sourceDir, themeConfig) {

Expand All @@ -30,9 +30,7 @@ function setFrontmatter(sourceDir, themeConfig) {

if (Object.keys(fileMatterObj.data).length === 0) { // 未定义FrontMatter数据
const stat = fs.statSync(file.filePath);
const dateStr = dateFormat(stat.birthtime);// 文件的创建时间


const dateStr = dateFormat(getBirthtime(stat));// 文件的创建时间
const categories = getCategories(file, categoryText)

// 注意下面这些反引号字符串的格式会映射到文件
Expand Down Expand Up @@ -65,7 +63,7 @@ permalink: ${getPermalink()}${file.filePath.indexOf('_posts') > -1 ? '\r\nsideba

if (!matterData.hasOwnProperty('date')) { // 日期
const stat = fs.statSync(file.filePath);
matterData.date = dateFormat(stat.birthtime);
matterData.date = dateFormat(getBirthtime(stat));
mark = true;
}

Expand Down Expand Up @@ -121,6 +119,12 @@ function getCategories(file, categoryText) {
return categories
}

// 获取文件创建时间
function getBirthtime(stat){
// 在一些系统下无法获取birthtime属性的正确时间,使用atime代替
return stat.birthtime.getFullYear() != 1970 ? stat.birthtime : stat.atime
}

// 定义永久链接数据
function getPermalink() {
return `${PREFIX + (Math.random() + Math.random()).toString(16).slice(2, 8)}/`
Expand Down
2 changes: 1 addition & 1 deletion theme-vdoing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vuepress-theme-vdoing",
"version": "1.4.0",
"version": "1.4.1",
"description": "Vdoing theme for VuePress. 一个基于VuePress的知识管理兼博客主题。",
"author": {
"name": "gaoyi(Evan) Xu"
Expand Down

0 comments on commit 39197d8

Please sign in to comment.