Merge pull request #68 from vuepress-reco/feature/reco

Feature/reco
This commit is contained in:
reco_luan 2019-10-20 22:26:34 +08:00 committed by GitHub
commit 0704f2264d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 46 additions and 42 deletions

View File

@ -32,7 +32,6 @@
<slot></slot>
<Comments :isShowComments="isComment"/>
</div>
<Footer class="footer" />
</div>
</transition>
<GA></GA>
@ -41,14 +40,13 @@
<script>
import Navbar from '@theme/components/Navbar.vue'
import Footer from '@theme/components/Footer.vue'
import Sidebar from '@theme/components/Sidebar.vue'
import { resolveSidebarItems } from '../util'
import Password from '@theme/components/Password'
import { setTimeout } from 'timers'
export default {
components: { Sidebar, Navbar, Password, Footer },
components: { Sidebar, Navbar, Password },
props: ['sidebar', 'isComment'],

View File

@ -17,7 +17,7 @@
<span v-if="$themeConfig.author || $site.title">{{ $themeConfig.author || $site.title }}</span>
</a>
</span>
<span v-show="$themeConfig.commentsSolution === 'valine'">
<span v-show="$themeConfig.valineConfig !== undefined">
<i class="iconfont reco-eye"></i>
<AccessNumber idVal="/" />
</span>

View File

@ -57,8 +57,10 @@
<script>
import TagList from '@theme/components/TagList.vue'
import NoteAbstract from '@theme/components/NoteAbstract.vue'
import mixin from '@theme/mixins/index.js'
export default {
mixins: [mixin],
components: { NoteAbstract, TagList },
data () {
return {
@ -71,13 +73,8 @@ export default {
//
posts () {
let posts = this.$site.pages
posts = posts.filter(item => {
const { home, date } = item.frontmatter
return !(home == true || date === undefined)
})
posts.sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)
})
posts = this._filterPostData(posts)
this._sortPostData(posts)
return posts
},

View File

@ -1,6 +1,6 @@
<template>
<div class="password-shadow" :class="{'is-home': !isPage}">
<Background></Background>
<Background />
<h3 class="title">{{isPage ? $frontmatter.title : $site.title}}</h3>
<p class="description" v-if="!isPage">{{$site.description}}</p>
<label class="inputBox" id="box">
@ -106,9 +106,9 @@ export default {
.password-shadow {
width 100vw;
height 100vh;
background #fff
position relative
padding-left: 20rem;
// background-image: radial-gradient(ellipse farthest-corner at center top,#497EC6 0,#000105 100%);
.title {
position: absolute;
left 0

View File

@ -36,8 +36,10 @@
<script>
import Common from '@theme/components/Common.vue'
import NoteAbstract from '@theme/components/NoteAbstract.vue'
import mixin from '@theme/mixins/index.js'
export default {
mixins: [mixin],
components: { Common, NoteAbstract },
data () {
@ -51,10 +53,9 @@ export default {
computed: {
//
posts () {
const posts = this.$currentCategories.pages
posts.sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)
})
let posts = this.$currentCategories.pages
posts = this._filterPostData(posts)
this._sortPostData(posts)
this._setPage(1)
return posts
},

View File

@ -1,7 +1,7 @@
<template>
<div>
<Common>
<component v-if="$frontmatter.home" :is="homeCom"></component>
<component v-if="$frontmatter.home" :is="homeCom"></component>
<Page
v-else
:sidebar-items="sidebarItems">
@ -12,6 +12,7 @@
name="page-bottom"
slot="bottom"/>
</Page>
<Footer v-if="$frontmatter.home" class="footer" />
</Common>
</div>
</template>
@ -20,11 +21,12 @@
import Home from '@theme/components/Home.vue'
import HomeBlog from '@theme/components/HomeBlog.vue'
import Page from '@theme/components/Page.vue'
import Footer from '@theme/components/Footer.vue'
import Common from '@theme/components/Common.vue'
import { resolveSidebarItems } from '../util'
export default {
components: { HomeBlog, Home, Page, Common },
components: { HomeBlog, Home, Page, Common, Footer },
computed: {
sidebarItems () {
@ -38,7 +40,7 @@ export default {
homeCom () {
const { type } = this.$themeConfig
if (type !== undefined) {
return type == 'blog' ? 'HomeBlog': type
return type == 'blog' ? 'HomeBlog' : type
}
return 'Home'
}

View File

@ -22,8 +22,10 @@
import Common from '@theme/components/Common.vue'
import TagList from '@theme/components/TagList.vue'
import NoteAbstract from '@theme/components/NoteAbstract.vue'
import mixin from '@theme/mixins/index.js'
export default {
mixins: [mixin],
components: { Common, NoteAbstract, TagList },
data () {
return {
@ -39,13 +41,8 @@ export default {
//
handlePosts () {
let posts = this.$site.pages
posts = posts.filter(item => {
const { home, date } = item.frontmatter
return !(home == true || date === undefined)
})
posts.sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)
})
posts = this._filterPostData(posts)
this._sortPostData(posts)
return posts
}
},
@ -75,9 +72,7 @@ export default {
let posts = []
if (currentTag !== '全部') {
posts = this.$tags.map[currentTag].pages
posts.sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)
})
this._sortPostData(posts)
} else {
posts = this.handlePosts
}
@ -101,10 +96,6 @@ export default {
_setPage (page) {
this.currentPage = page
this.$page.currentPage = page
},
//
_getTimeNum (date) {
return parseInt(new Date(date.frontmatter.date).getTime())
}
}
}

View File

@ -20,8 +20,10 @@
<script>
import Common from '@theme/components/Common.vue'
import mixin from '@theme/mixins/index.js'
export default {
mixins: [mixin],
name: 'TimeLine',
components: { Common },
data () {
@ -52,10 +54,7 @@ export default {
//
getPages (tag) {
let pages = this.$site.pages
pages = pages.filter(item => {
const { home, isTimeLine, date } = item.frontmatter
return !(home == true || isTimeLine == true || date === undefined)
})
pages = this._filterPostData(pages)
// reverse()
this.pages = pages.length == 0 ? [] : pages
for (let i = 0, length = pages.length; i < length; i++) {
@ -68,11 +67,11 @@ export default {
}
for (const key in this.formatPages) {
const data = this.formatPages[key]
this._sortPostData(data)
this.formatPagesArr.unshift({
year: key,
data: this.formatPages[key].sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)
})
data
})
}
},

View File

@ -5,6 +5,22 @@ export default {
const tagColorArr = ['#e15b64', '#f47e60', '#f8b26a', '#abbd81', '#849b87', '#e15b64', '#f47e60', '#f8b26a', '#f26d6d', '#67cc86', '#fb9b5f', '#3498db']
const index = Math.floor(Math.random() * tagColorArr.length)
return tagColorArr[index]
},
_filterPostData (posts) {
posts = posts.filter(item => {
const { home, date, publish } = item.frontmatter
return !(home == true || date === undefined || publish === false)
})
return posts
},
_sortPostData (posts) {
posts.sort((a, b) => {
return this._getTimeNum(b) - this._getTimeNum(a)
})
},
// 获取时间的数字类型
_getTimeNum (date) {
return parseInt(new Date(date.frontmatter.date).getTime())
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "vuepress-theme-reco",
"version": "1.0.9-alpha.17",
"version": "1.1.0-alpha.1",
"description": "this is a vuepress theme",
"main": "index.js",
"scripts": {