feat: add tag page

This commit is contained in:
kmacoders 2021-07-08 14:30:45 +07:00
parent b5706dfb42
commit b0f2e5dbb2
3 changed files with 7 additions and 12 deletions

View File

@ -17,13 +17,13 @@ import getSiteMeta from '@/utils/getSiteMeta'
.fetch() .fetch()
const [blogDetail] = findedBlog const [blogDetail] = findedBlog
const [prev, next] = await $content('blog') const [prev, next] = await $content('blog', { deep: true })
.only(['title', 'slug', 'published']) .only(['title', 'slug', 'published'])
.sortBy('published', 'desc') .sortBy('published', 'desc')
.surround(params.slug) .surround(params.slug)
.fetch() .fetch()
const allBlogs = await $content('blog') const allBlogs = await $content('blog', { deep: true })
.only(['title', 'description', 'image', 'slug', 'published', 'tags']) .only(['title', 'description', 'image', 'slug', 'published', 'tags'])
.sortBy('published', 'desc') .sortBy('published', 'desc')
.fetch() .fetch()

View File

@ -1,12 +1,6 @@
<template> <template>
<div> <section>
<div class="flex justify-center"> <h1>All tag</h1>
<h2
class="text-center text-3xl mb-4 uppercase bg-black text-white inline-block mx-auto px-2"
>
All Tags
</h2>
</div>
<ul> <ul>
<li v-for="tag in tags" :key="tag" class="text-center mb-2"> <li v-for="tag in tags" :key="tag" class="text-center mb-2">
<nuxt-link <nuxt-link
@ -17,7 +11,7 @@
</nuxt-link> </nuxt-link>
</li> </li>
</ul> </ul>
</div> </section>
</template> </template>
<script lang="ts"> <script lang="ts">
@ -30,7 +24,8 @@ import { Vue, Component } from 'nuxt-property-decorator'
function onlyUnique (value: string, index: number, self: string[]) { function onlyUnique (value: string, index: number, self: string[]) {
return self.indexOf(value) === index return self.indexOf(value) === index
} }
const blog: IContentDocument[] = await $content('blog')
const blog: IContentDocument[] = await $content('blog', { deep: true })
.only(['tags']) .only(['tags'])
.fetch<IContentDocument[]>() .fetch<IContentDocument[]>()