Add router-links to blog components
This commit is contained in:
parent
8d450f42b2
commit
aa66ed005c
@ -2,7 +2,7 @@
|
|||||||
<section class="blog-popular">
|
<section class="blog-popular">
|
||||||
<h3>Popular content</h3>
|
<h3>Popular content</h3>
|
||||||
<ul class="popular-items">
|
<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">
|
<span class="arrow">
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@ -19,7 +19,7 @@
|
|||||||
<polyline points="12 5 19 12 12 19"></polyline>
|
<polyline points="12 5 19 12 12 19"></polyline>
|
||||||
</svg>
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
<a class="link" href="#">
|
<a class="link" href="javascript:void(0)">
|
||||||
{{ article.title }}
|
{{ article.title }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@ -50,5 +50,17 @@ export default {
|
|||||||
this.error = ex.message;
|
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>
|
</script>
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<div class="header">
|
<div class="header">
|
||||||
<h3>Latest Articles</h3>
|
<h3>Latest Articles</h3>
|
||||||
<div class="all-articles">
|
<div class="all-articles">
|
||||||
<a href="javascript:void(0)">All articles</a>
|
<router-link :to="{ name: 'blog' }">All articles</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="list">
|
<div class="list">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user