-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInlineArticles.vue
88 lines (72 loc) · 1.55 KB
/
InlineArticles.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<template>
<section>
<div class="header">
<div class="titles">
<h2>Bytes of <span>insight</span></h2>
<h3>{{ $t('articleListDesc') }}</h3>
</div>
<router-link to="/articles" >
<button>
{{ $t('viewAll') }}
</button>
</router-link>
</div>
<div class="cardList">
<ArticleCard
v-for="article in posts"
:key="article.id"
:post="article"
/>
</div>
</section>
</template>
<style lang="scss" scoped>
@import "/assets/scss/variables.scss";
.header {
display: flex;
align-items: center;
justify-content: space-between;
}
.cardList {
overflow-x: auto;
overflow-y: hidden;
display: inline-flex;
width: 82vw;
padding: 15px 0;
}
.card:not(.highlighted) {
display: none !important;
}
@media (max-width: 768px) {
.header {
flex-direction: column;
align-items: baseline;
gap: 15px;
}
.cardList {
width: 100vw;
transform: translateX(-7.5%);
padding-top: 15px;
padding-bottom: 15px;
flex-direction: row;
display: flex;
a {
flex-shrink: 0;
width: 80%
}
a:first-child {
margin-left: 15px;
}
a:last-child {
margin-right: 15px;
}
}
}
</style>
<script setup>
import ArticleCard from "~/components/atomic/ArticleCard.vue";
import {fetchArticles} from "~/services/articles.js";
const useRouter = useNuxtApp().$router
const {data, pending, error} = await useAsyncData("all_posts", fetchArticles);
const posts = data._value.posts.filter(x => x.Highlighted)
</script>