Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
{
id: 'post',
dirname: '_posts',
path: '/',
path: '/posts/',
layout: 'PostList',
itemLayout: 'Post',
pagination: {
Expand Down
67 changes: 67 additions & 0 deletions docs/.vuepress/theme/layouts/Post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
</div>
<Content />
<social-share :networks="['twitter', 'facebook']" is-plain/>
<div>
<router-link v-if="hasPrev" :to=prevPost.path>{{ prevPost.title }}</router-link> |
<router-link v-if="hasNext" :to=nextPost.path> {{ nextPost.title }}</router-link>
</div>
<div class="comment">
<Vssue :title="$title" />
</div>
Expand All @@ -21,8 +25,71 @@
import TimeAgo from '../components/TimeAgo';

export default {
name: "post",
components: {
TimeAgo
},
computed: {
hasPrev() {
return this.posts().findIndex(post => post.key === this.$page.key) > 0
},
hasNext() {
return this.posts().findIndex(post => post.key === this.$page.key) < this.posts().length - 1
},
prevPost() {
return this.posts()[this.posts().findIndex(post => post.key === this.$page.key)-1]
},
nextPost() {
return this.posts()[this.posts().findIndex(post => post.key === this.$page.key)+1]
},
currentPost(){
return this.posts()[this.posts().findIndex(post => post.key === this.$page.key)]
}
},
mounted: function(){
document.addEventListener('keydown', this.transitionPage, false);
},
beforeDestroy: function() {
document.removeEventListener('keydown', this.transitionPa, false);
},
methods: {
posts() {
const postReg = /^_posts\//
const posts = this.$site.pages.filter( (page) => {
return /^_posts/.test(page.relativePath)
})

const sortedPosts = posts.sort( (a,b) => {
const dateA = a.frontmatter.date;
const dateB = b.frontmatter.date;
if (dateA < dateB) {
return 1;
}
if (dateA > dateB) {
return -1;
}
return 0;
})
return sortedPosts;
},
transitionPage(e){
if (e.code === "ArrowRight") {
if (this.hasNext) {
this.transitionNextPost()
}
}else if(e.code === "ArrowLeft") {
if (this.hasPrev) {
this.transitionPrevPost()
}
}
},
transitionNextPost() {
this.$router.push( {path: this.nextPost.path })
},
transitionPrevPost() {
this.$router.push( {path: this.prevPost.path }).catch(err => {})
}
}

}
</script>
12 changes: 11 additions & 1 deletion docs/.vuepress/theme/styles/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ img,
video,
canvas,
iframe
max-width 100%

//
// Shared
Expand Down Expand Up @@ -120,6 +119,11 @@ iframe
background-size 100%
vertical-align sub

.icon
display block
margin-left auto
margin-right auto

//
// List View
// -----------------------------------------
Expand Down Expand Up @@ -226,6 +230,12 @@ iframe
.comment
padding 60px 30px 30px 30px

iframe
max-width 100%
display block
margin-left auto
margin-right auto

.post-head
position relative

Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

<img class="icon" src="icon.jpg">