refactor: update version of @vuepress/plugin-blog

1. The plugin was refactored after the1.0.0-alpha.49, but the theme was not updated.

2.  In this update, the plug-in version is updated, and the data acquisition method of category and tag is changed accordingly.
This commit is contained in:
reco_luan 2019-10-04 20:35:28 +08:00 committed by zsw
parent cb8db5cc7b
commit 4ae105d204
6 changed files with 28 additions and 16 deletions

View File

@ -23,7 +23,7 @@
<h6>文章</h6>
</div>
<div>
<h3>{{$tags.length}}</h3>
<h3>{{$tags.list.length}}</h3>
<h6>标签</h6>
</div>
</div>
@ -33,7 +33,7 @@
<li class="category-item" v-for="(item, index) in this.$categories.list" :key="index">
<router-link :to="item.path">
<span class="category-name">{{ item.name }}</span>
<span class="post-num">{{ item.posts.length }}</span>
<span class="post-num">{{ item.pages.length }}</span>
</router-link>
</li>
</ul>
@ -108,7 +108,7 @@ export default {
getPagesLength () {
let num = 0
this.$categories.list.map(v => {
num += v.posts.length
num += v.pages.length
})
return num
},

View File

@ -83,7 +83,6 @@ export default {
const year = dateObj.getFullYear()
const mon = dateObj.getMonth() + 1
const day = dateObj.getDate()
console.log(dateObj)
if (type == 'year') return year
else return `${mon}-${day}`
},

View File

@ -23,7 +23,23 @@ module.exports = (options, ctx) => ({
'@vuepress-reco/vuepress-plugin-screenfull',
'@vuepress/active-header-links',
['@vuepress/plugin-blog', {
permalink: '/:regular'
permalink: '/:regular',
frontmatters: [
{
id: 'tags',
keys: ['tags'],
path: '/tag/',
layout: 'Tags',
scopeLayout: 'Tag'
},
{
id: 'categories',
keys: ['categories'],
path: '/categories/',
layout: 'Categories',
scopeLayout: 'Category'
},
],
}],
'@vuepress/search',
'@vuepress/plugin-nprogress',

View File

@ -6,12 +6,12 @@
<ul class="category-wrapper">
<li
class="category-item"
:class="title.trim() == item.name ? 'active': ''"
:class="title == item.name ? 'active': ''"
v-for="(item, index) in this.$categories.list"
:key="index">
<router-link :to="item.path">
<span class="category-name">{{ item.name }}</span>
<span class="post-num">{{ item.posts.length }}</span>
<span class="post-num">{{ item.pages.length }}</span>
</router-link>
</li>
</ul>
@ -51,7 +51,7 @@ export default {
computed: {
//
posts () {
const posts = this.$category.posts
const posts = this.$currentCategories.pages
posts.sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)
})
@ -60,7 +60,7 @@ export default {
},
//
title () {
return this.$frontmatter.title.split('|')[0]
return this.$currentCategories.key
}
},

View File

@ -61,6 +61,7 @@ export default {
created () {
if (this.$tags.list.length > 0) {
const currentTag = this.$route.query.tag ? this.$route.query.tag : this.currentTag
const tags = this.$tags.list
tags.map(item => {
const color = this._tagColor()
@ -69,7 +70,7 @@ export default {
})
this.tags = [{ name: '全部', color: this._tagColor() }, ...tags]
this.getPagesByTags(this.currentTag)
this.getPagesByTags(currentTag)
}
},
@ -79,10 +80,6 @@ export default {
methods: {
initData (currentTag) {
this.getPagesByTags(currentTag)
},
async tagClick (currentTag) {
await this.getPagesByTags(currentTag)
window.scrollTo(0, 0)
@ -94,7 +91,7 @@ export default {
let posts = []
if (currentTag !== '全部') {
posts = this.$tags.map[currentTag].posts
posts = this.$tags.map[currentTag].pages
posts.sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)
})

View File

@ -29,7 +29,7 @@
"@vuepress-reco/vuepress-plugin-back-to-top": "^1.0.3",
"@vuepress-reco/vuepress-plugin-pagation": "^1.0.3",
"@vuepress-reco/vuepress-plugin-screenfull": "^1.0.0",
"@vuepress/plugin-blog": "1.0.0-alpha.49",
"@vuepress/plugin-blog": "1.3.0",
"leancloud-storage": "3.13.2",
"valine": "1.3.6",
"vue-click-outside": "1.0.7"