add: article view
View for blog articles
This commit is contained in:
parent
579491f216
commit
4104477533
15 changed files with 121 additions and 33 deletions
|
@ -26,7 +26,16 @@ import type { Category } from '../../components/Blog/types'
|
|||
|
||||
const route = useRoute()
|
||||
|
||||
const { data: articles } = await useAsyncData('articles', () => queryCollection('blog').order('date', 'DESC').all())
|
||||
const simpleDate = (date: Date) => {
|
||||
date.setDate(date.getDate() + 1)
|
||||
return `${date.getFullYear()}-${`${date.getMonth() + 1}`.padStart(2, '0')}-${date.getDate()}`
|
||||
}
|
||||
|
||||
const { data: articles } = await useAsyncData('articles', () => queryCollection('blog')
|
||||
.where('date', '<', simpleDate(new Date()))
|
||||
.order('date', 'DESC')
|
||||
.all(),
|
||||
)
|
||||
|
||||
const firstTen = computed(() => {
|
||||
if (route.query.category) {
|
||||
|
@ -49,13 +58,13 @@ const allCategoriesAndCount = computed(() => {
|
|||
const makeBlogCard = (article: BlogCollectionItem) => ({
|
||||
title: article.title,
|
||||
description: article.description,
|
||||
image: article.meta.image as string,
|
||||
image: article.thumbnail as string,
|
||||
date: article.date as string,
|
||||
excerpt: article.excerpt,
|
||||
excerpt: article.excerpt as any,
|
||||
link: article.path,
|
||||
tags: article.meta.tags as string[],
|
||||
category: article.meta.category as Category,
|
||||
author: article.meta.author as { name: string, image: string },
|
||||
tags: article.tags as string[],
|
||||
category: article.category as Category,
|
||||
author: article.author as { name: string, image: string },
|
||||
})
|
||||
|
||||
useHead({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue