Last active
October 15, 2019 01:24
-
-
Save Adam-Collier/3694229763b041327432a2bbc09ef6c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="posts" v-if="posts.length"> | |
<div class="post" v-for="post in posts"> | |
<router-link :to="post.path"> | |
<div> | |
<img v-if="post.frontmatter.image" :src="$withBase(post.frontmatter.image)" alt=""> | |
</div> | |
<h2>{{post.frontmatter.title}}</h2> | |
<p>{{post.frontmatter.description}}</p> | |
</router-link> | |
</div> | |
</div> | |
</template> | |
<script> | |
export default { | |
props: ["page"], | |
computed: { | |
posts() { | |
let currentPage = this.page ? this.page : this.$page.path; | |
let posts = this.$site.pages | |
.filter(x => { | |
return x.path.match(new RegExp(`(${currentPage})(?=.*html)`)); | |
}) | |
.sort((a, b) => { | |
return new Date(b.frontmatter.date) - new Date(a.frontmatter.date); | |
}); | |
return posts; | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment