Add router-links to blog components

This commit is contained in:
Daniel_I_Am 2021-09-02 00:11:57 +02:00
parent 8d450f42b2
commit aa66ed005c
2 changed files with 15 additions and 3 deletions

View File

@ -2,7 +2,7 @@
<section class="blog-popular">
<h3>Popular content</h3>
<ul class="popular-items">
<li v-for="article of articles" :key="article.id">
<li v-for="article of articles" :key="article.id" @click="onClick(article)">
<span class="arrow">
<svg
xmlns="http://www.w3.org/2000/svg"
@ -19,7 +19,7 @@
<polyline points="12 5 19 12 12 19"></polyline>
</svg>
</span>
<a class="link" href="#">
<a class="link" href="javascript:void(0)">
{{ article.title }}
</a>
</li>
@ -50,5 +50,17 @@ export default {
this.error = ex.message;
});
},
methods: {
onClick(article) {
const date = moment(article.date);
const year = date.year();
const month = date.month() + 1;
const day = date.date();
const id = article.id;
const slug = article.slug;
this.$router.push({ name: 'blog-article', params: { year, month, day, id, slug }});
},
},
};
</script>

View File

@ -3,7 +3,7 @@
<div class="header">
<h3>Latest Articles</h3>
<div class="all-articles">
<a href="javascript:void(0)">All articles</a>
<router-link :to="{ name: 'blog' }">All articles</router-link>
</div>
</div>
<div class="list">