@@ -3,49 +3,28 @@ const props = defineProps<{
33 name: string
44}>()
55
6- const { data : posts } = useAsyncData (` latest-news:${props .name } ` , () => queryContent (' /blog/' ).sort ({ publishedAt: - 1 }).where ({ packages: { $contains: props .name } }).limit (2 ).only ([' title' , ' description' , ' publishedAt' , ' authors' , ' _path' ]).find ())
6+ const { data : articles } = useAsyncData (` latest-news:${props .name } ` , () => queryContent (' /blog/' ).sort ({ publishedAt: - 1 }).where ({ packages: { $contains: props .name } }).limit (3 ).only ([' title' , ' description' , ' publishedAt' , ' authors' , ' _path' ]).find ())
77 </script >
88
99<template >
10- <section v-if =" posts && posts.length" >
11- <h2 text =" gray-900 2xl" font =" semibold" >
12- Latest News about {{ name }}
13- </h2 >
14- <ol m =" t-6" grid =" ~ cols-2 gap-6" >
15- <li v-for =" post in posts" :key =" post._path" >
16- <!-- TODO: create a component -->
17- <article relative flex =" ~ col gap-4" p =" 4" rounded =" xl" border =" ~ gray-300 hover:gray-400" bg =" gray-300 op-10 hover:op-15" transition =" ~ ease-in duration-150" >
18- <NuxtLink :to =" post._path" >
19- <h3 text =" gray-900 xl" font =" semibold" >
20- {{ post.title }}
21- <span absolute inset-0 />
22- </h3 >
23- </NuxtLink >
24- <p text =" gray-600" >
25- {{ post.description }}
26- </p >
27- <dl flex =" ~ row justify-between" >
28- <dt sr-only >
29- Published on
30- </dt >
31- <dd text =" gray-700 sm" >
32- <time :datetime =" toISODateString(post.publishedAt)" >
33- {{ toLocaleDateString(post.publishedAt) }}
34- </time >
35- </dd >
36- <dt sr-only >
37- Authors
38- </dt >
39- <dd >
40- <ul flex =" ~" space-x-1 >
41- <li v-for =" author in post.authors" :key =" author.name" >
42- <img :src =" author.picture" :alt =" `Picture of ${author.name}`" width =" 20" height =" 20" w-5 h-5 rounded-full >
43- </li >
44- </ul >
45- </dd >
46- </dl >
47- </article >
48- </li >
49- </ol >
10+ <section v-if =" articles && articles.length" >
11+ <div class =" prose prose-zinc dark:prose-invert max-w-none" >
12+ <h2 id =" latest-news" >
13+ <a href =" #latest-news" >
14+ Latest news
15+ </a >
16+ </h2 >
17+ </div >
18+ <AppListGrid class =" mt-8" >
19+ <AppListGridItem v-for =" item in articles" :key =" item._path" >
20+ <BlogCard
21+ :path =" item._path!"
22+ :title =" item.title"
23+ :description =" item.description"
24+ :published-at =" item.publishedAt"
25+ :authors =" item.authors"
26+ />
27+ </AppListGridItem >
28+ </AppListGrid >
5029 </section >
5130</template >
0 commit comments