Skip to content

Commit 642b05f

Browse files
committed
feat: add latest news to each package
1 parent 70c43c9 commit 642b05f

File tree

3 files changed

+24
-43
lines changed

3 files changed

+24
-43
lines changed

components/packages/PackagesLatestNews.vue

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -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>

components/prose/ProseContent.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88
.prose :deep(:first-child) {
99
margin-top: 0;
1010
}
11+
.prose :deep(:last-child) {
12+
margin-bottom: 0;
13+
}
1114
</style>

pages/packages/[...slug].vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ defineOgImageComponent('OgImagePackage', {
163163
</ProseNavGroup> -->
164164
</template>
165165
</Prose>
166+
<PackagesLatestNews v-if="page.title" class="mt-12" :name="page.title" />
166167
</Main>
167-
168-
<!-- <PackageLatestNews class="xl:row-start-2 col-start-2" :name="page.title" /> -->
169168
</template>

0 commit comments

Comments
 (0)