From 4969bc36bfd7a2ab8b2405f4f0c97adb7400d19c Mon Sep 17 00:00:00 2001 From: ikaruga Date: Wed, 13 May 2020 02:40:54 +0900 Subject: [PATCH 1/4] wip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 記事一覧をpostsに移す top はアイコンだけ アイコンは中央揃え --- docs/.vuepress/config.js | 2 +- docs/.vuepress/theme/layouts/Post.vue | 66 ++++++++++++++++++++++++++ docs/.vuepress/theme/styles/index.styl | 12 ++++- docs/README.md | 2 + 4 files changed, 80 insertions(+), 2 deletions(-) diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 387232f..58ceefe 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -39,7 +39,7 @@ module.exports = { { id: 'post', dirname: '_posts', - path: '/', + path: '/posts/', layout: 'PostList', itemLayout: 'Post', pagination: { diff --git a/docs/.vuepress/theme/layouts/Post.vue b/docs/.vuepress/theme/layouts/Post.vue index 1822931..fe59763 100644 --- a/docs/.vuepress/theme/layouts/Post.vue +++ b/docs/.vuepress/theme/layouts/Post.vue @@ -14,6 +14,16 @@
+
+ {{ prevPost.title }} | + {{ nextPost.title }} + {{prevPost.title}} - + {{currentPost.title}} - + {{nextPost.title}} +
+
+ {{index }} - {{ post.title }} +
@@ -24,5 +34,61 @@ export default { 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() { + // console.log(this.posts()) + // console.log(this.posts().findIndex(post => post.key === this.$page.key)) + console.log("prev",this.posts()[this.posts().findIndex(post => post.key === this.$page.key)-1]) + + return this.posts()[this.posts().findIndex(post => post.key === this.$page.key)-1] + }, + nextPost() { +// console.log(this.posts()) +// console.log(this.posts().findIndex(post => post.key === this.$page.key)) + console.log("next",this.posts()[this.posts().findIndex(post => post.key === this.$page.key)+1]) + + return this.posts()[this.posts().findIndex(post => post.key === this.$page.key)+1] + }, + currentPost(){ + console.log("current",this.posts()[this.posts().findIndex(post => post.key === this.$page.key)]) + + return this.posts()[this.posts().findIndex(post => post.key === this.$page.key)] + } + }, + mounted: function(){ + console.log(this.posts()) + document.addEventListener('keydown', this.transitionPage, false); + }, + beforeDestroy: function() { + document.removeEventListener('keydown', this.transitionPa, false); + }, + methods: { + posts() { + const postReg = /^_posts\// + return this.$site.pages.filter( (page) => { + return /^_posts/.test(page.relativePath) + }) + }, + transitionPage(e){ + if (e.code === "ArrowRight") { + this.transitionNextPost() + }else if(e.code === "ArrowLeft") { + this.transitionPrevPost() + } + }, + transitionNextPost() { + this.$router.push( {path: this.nextPost.link }) + }, + transitionPrevPost() { + this.$router.push( {path: this.prevPost.link }).catch(err => {}) + } + } + } diff --git a/docs/.vuepress/theme/styles/index.styl b/docs/.vuepress/theme/styles/index.styl index 99e9cf4..503c8c1 100644 --- a/docs/.vuepress/theme/styles/index.styl +++ b/docs/.vuepress/theme/styles/index.styl @@ -58,7 +58,6 @@ img, video, canvas, iframe - max-width 100% // // Shared @@ -120,6 +119,11 @@ iframe background-size 100% vertical-align sub +.icon + display block + margin-left auto + margin-right auto + // // List View // ----------------------------------------- @@ -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 diff --git a/docs/README.md b/docs/README.md index e69de29..af0aace 100644 --- a/docs/README.md +++ b/docs/README.md @@ -0,0 +1,2 @@ + + From 26c5c1b0fdf55d6feb82600a46d761cc9abd4f0a Mon Sep 17 00:00:00 2001 From: ikaruga Date: Mon, 31 Aug 2020 21:33:20 +0900 Subject: [PATCH 2/4] wip --- docs/.vuepress/theme/layouts/Post.vue | 44 ++++++++++++++++++--------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/docs/.vuepress/theme/layouts/Post.vue b/docs/.vuepress/theme/layouts/Post.vue index fe59763..7655b6d 100644 --- a/docs/.vuepress/theme/layouts/Post.vue +++ b/docs/.vuepress/theme/layouts/Post.vue @@ -15,14 +15,11 @@
- {{ prevPost.title }} | - {{ nextPost.title }} - {{prevPost.title}} - - {{currentPost.title}} - - {{nextPost.title}} + {{ prevPost.title }} | + {{ nextPost.title }}
- {{index }} - {{ post.title }} + {{ index }} - {{ post.title }}
@@ -31,26 +28,26 @@ import TimeAgo from '../components/TimeAgo'; export default { + name: "post", components: { TimeAgo }, computed: { hasPrev() { + console.log('hasprev:' , this.posts().findIndex(post => post.key === this.$page.key) > 0) return this.posts().findIndex(post => post.key === this.$page.key) > 0 }, hasNext() { + console.log('hasnext:' , this.posts().findIndex(post => post.key === this.$page.key) < this.posts().length - 1) + return this.posts().findIndex(post => post.key === this.$page.key) < this.posts().length - 1 }, prevPost() { - // console.log(this.posts()) - // console.log(this.posts().findIndex(post => post.key === this.$page.key)) console.log("prev",this.posts()[this.posts().findIndex(post => post.key === this.$page.key)-1]) return this.posts()[this.posts().findIndex(post => post.key === this.$page.key)-1] }, nextPost() { -// console.log(this.posts()) -// console.log(this.posts().findIndex(post => post.key === this.$page.key)) console.log("next",this.posts()[this.posts().findIndex(post => post.key === this.$page.key)+1]) return this.posts()[this.posts().findIndex(post => post.key === this.$page.key)+1] @@ -71,22 +68,39 @@ export default { methods: { posts() { const postReg = /^_posts\// - return this.$site.pages.filter( (page) => { + 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") { - this.transitionNextPost() + if (this.hasNext) { + this.transitionNextPost() + } }else if(e.code === "ArrowLeft") { - this.transitionPrevPost() + if (this.hasPrev) { + this.transitionPrevPost() + } } }, transitionNextPost() { - this.$router.push( {path: this.nextPost.link }) + this.$router.push( {path: this.nextPost.path }) }, transitionPrevPost() { - this.$router.push( {path: this.prevPost.link }).catch(err => {}) + this.$router.push( {path: this.prevPost.path }).catch(err => {}) } } From 54f1cff6fad2ae2cc76e65788c2da4a34054607c Mon Sep 17 00:00:00 2001 From: ikaruga Date: Thu, 4 Feb 2021 09:19:24 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E5=85=A5=E3=82=8C=E6=9B=BF=E3=81=88?= =?UTF-8?q?=E3=81=A8=E3=81=8D=E3=81=9F=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vuepress/theme/layouts/Post.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/.vuepress/theme/layouts/Post.vue b/docs/.vuepress/theme/layouts/Post.vue index 7655b6d..1cedf40 100644 --- a/docs/.vuepress/theme/layouts/Post.vue +++ b/docs/.vuepress/theme/layouts/Post.vue @@ -11,9 +11,6 @@ -
- -
{{ prevPost.title }} | {{ nextPost.title }} @@ -21,6 +18,9 @@
{{ index }} - {{ post.title }}
+
+ +
From 7ba05f64d5763528ca8b6dbae6fc70c04e63a58c Mon Sep 17 00:00:00 2001 From: ikaruga Date: Thu, 4 Feb 2021 09:21:32 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E3=83=87=E3=83=90=E3=83=83=E3=82=B0?= =?UTF-8?q?=E7=94=A8=E3=81=AE=E3=83=AD=E3=82=B0=E8=A1=A8=E7=A4=BA=E3=82=92?= =?UTF-8?q?=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vuepress/theme/layouts/Post.vue | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/docs/.vuepress/theme/layouts/Post.vue b/docs/.vuepress/theme/layouts/Post.vue index 1cedf40..ae387cd 100644 --- a/docs/.vuepress/theme/layouts/Post.vue +++ b/docs/.vuepress/theme/layouts/Post.vue @@ -15,9 +15,6 @@ {{ prevPost.title }} | {{ nextPost.title }}
-
- {{ index }} - {{ post.title }} -
@@ -34,32 +31,22 @@ export default { }, computed: { hasPrev() { - console.log('hasprev:' , this.posts().findIndex(post => post.key === this.$page.key) > 0) return this.posts().findIndex(post => post.key === this.$page.key) > 0 }, hasNext() { - console.log('hasnext:' , this.posts().findIndex(post => post.key === this.$page.key) < this.posts().length - 1) - return this.posts().findIndex(post => post.key === this.$page.key) < this.posts().length - 1 }, prevPost() { - console.log("prev",this.posts()[this.posts().findIndex(post => post.key === this.$page.key)-1]) - return this.posts()[this.posts().findIndex(post => post.key === this.$page.key)-1] }, nextPost() { - console.log("next",this.posts()[this.posts().findIndex(post => post.key === this.$page.key)+1]) - return this.posts()[this.posts().findIndex(post => post.key === this.$page.key)+1] }, currentPost(){ - console.log("current",this.posts()[this.posts().findIndex(post => post.key === this.$page.key)]) - return this.posts()[this.posts().findIndex(post => post.key === this.$page.key)] } }, mounted: function(){ - console.log(this.posts()) document.addEventListener('keydown', this.transitionPage, false); }, beforeDestroy: function() {