I'm rebuilding my WordPress blog using Vue. I'm trying to display my 3 most recent posts which I'm doing here:
<template>
<section>
<h4>Recent Posts</h4>
<div class="posts-recent">
<div v-for="(post, index) in posts.slice(0, 3)" :key="post.id" class="post">
<div :key="index">
<nuxt-link :to="`/blog/${post.slug}`" class="post-image" :style="{ backgroundImage: 'url(' + post.fimg_url + ')' }"></nuxt-link>
<div class="post-text">
<nuxt-link :to="`/blog/${post.slug}`" class="post-title" v-html="post.title.rendered"></nuxt-link>
</div>
</div>
</div>
</div>
</section>
</template>
<script>
import { mapState, mapActions } from 'vuex';
export default {
name: 'Recent',
created() {
this.getPosts();
},
props: {
slug: String
},
computed: {
...mapState(['posts']),
},
methods: {
...mapActions(['getPosts']),
}
};
</script>
This works just fine, but what I would like is to exclude the current post if that post is one of the 3 most recent (while still showing 3 posts).