Newer
Older
<div v-if="!loading" class="flex items-center">
<MiniMap class="mx-4" style="min-width: 440px" />
<div class="text-left text-xs py-1 w-80 border-l dark:border-gray-500">
<a
v-for="(cat, index) in categories"
:key="index"
class="
block
text-gray-600
hover:text-gray-700 hover:bg-hover-light
dark:text-gray-200
p-2
w-full
"
:href="`${$config.forum_url}/c/${cat.slug}/${cat.id}`"
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
target="_blank"
rel="noopener noreferrer"
>
<span
class="badge-category-bg"
:style="`background-color: #${cat.color};`"
/>
<span class="">{{ cat.name }}</span>
<span class="text-gray-400">x {{ cat.topic_count }}</span>
</a>
</div>
</div>
<div v-else class="h-80 flex items-center">
<span class="loading-state h-12 w-12 scale-150 transform mx-auto" />
</div>
</template>
<script>
import { fetchCategories } from '~/libs/api-forum'
export default {
name: 'LayoutHeaderMenuForum',
data() {
return {
categories: [],
loading: false,
}
},
async beforeMount() {
this.loading = true
this.categories = await fetchCategories()
this.loading = false
},
}
</script>
<style lang="postcss" scoped>
.badge-category-bg {
width: 9px;
height: 9px;
margin-right: 5px;
display: inline-block;
}
</style>