add support for blog
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<template>
|
||||
<template v-if="post">
|
||||
<NuxtLink class="project-card" :to="post.path">
|
||||
<img :src="baseUrl + '/portal/f/assets/' + post.coverImage" :alt="post?.title + '’s cover image'"/>
|
||||
<div class="project-card-content">
|
||||
<h3>{{ post.title }}</h3>
|
||||
<p :title="post.description">{{ post.description }}</p>
|
||||
<p class="mt-4 text-xs" :title="useFormatDate(post.dateUpdated)">{{ useRelativeDate(post.dateUpdated) }}</p>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const config = useRuntimeConfig();
|
||||
const baseUrl = config.public.baseUrl
|
||||
import { useFormatDate } from '~/composables/formatDate';
|
||||
import { useRelativeDate } from '~/composables/relativeDate';
|
||||
import type { PostsCollectionItem } from '@nuxt/content'
|
||||
|
||||
|
||||
|
||||
defineProps<{
|
||||
post: PostsCollectionItem
|
||||
}>()
|
||||
</script>
|
||||
@@ -0,0 +1,26 @@
|
||||
<template>
|
||||
<section class="project-cards">
|
||||
<template v-for="post in posts" :key="post.id">
|
||||
<PostCard :post="post" />
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const route = useRoute();
|
||||
const currentRoute = route.path
|
||||
const props = defineProps<{
|
||||
limit?: number | null
|
||||
}>()
|
||||
const fetchLimit = props.limit ?? undefined
|
||||
const { data: posts } = await useAsyncData(
|
||||
`${currentRoute}-blog`,
|
||||
async () => {
|
||||
let query = queryCollection('posts').order('dateUpdated', 'DESC')
|
||||
if (fetchLimit) {
|
||||
query = query.limit(fetchLimit)
|
||||
}
|
||||
return query.all()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
Reference in New Issue
Block a user