Skip to content

Commit 77e0bc2

Browse files
related tags
1 parent a5bc0c8 commit 77e0bc2

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

components/ArticleCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="border-2 rounded-lg border-primary">
2+
<div class="my-4 border-2 rounded-lg border-primary">
33
<nuxt-link :to="{ name: 'blog-slug', params: { slug: article.slug } }">
44
<div
55
class="cover-img"

components/ArticleTag.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<template>
2-
<span :class="tag">{{ tag }}</span>
2+
<nuxt-link :class="tag" :to="{ name: 'index', query: { tag } }">{{
3+
tag
4+
}}</nuxt-link>
35
</template>
46

57
<script>
@@ -14,12 +16,20 @@ export default {
1416
</script>
1517

1618
<style scoped>
17-
span {
19+
a {
1820
@apply p-1 m-1 border-2 rounded-lg border-current font-mono;
1921
}
20-
span::before {
22+
a::before {
2123
content: '#';
2224
}
25+
.vue {
26+
color: #35495e;
27+
background-color: #41b883;
28+
}
29+
.github {
30+
color: black;
31+
background-color: white;
32+
}
2333
.react {
2434
color: #61dafb;
2535
background-color: #282c34;

pages/index.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import ArticleCard from '@/components/ArticleCard'
1313
1414
export default {
1515
components: { ArticleCard },
16-
async asyncData({ $content, params }) {
17-
const articles = await $content('articles', params.slug)
16+
watchQuery: ['tag'],
17+
async asyncData({ $content, params, query }) {
18+
const articles = await $content('articles')
1819
.only(['title', 'description', 'img', 'slug', 'tags', 'cover_image'])
20+
.where({ tags: { $contains: query.tag || '' } })
1921
.sortBy('createdAt', 'asc')
2022
.fetch()
2123

0 commit comments

Comments
 (0)