Skip to content

Commit e68b3b7

Browse files
fixed post count logic
1 parent c3e7b40 commit e68b3b7

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/pages/index.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getCollection } from 'astro:content';
77
88
const posts = (await getCollection('blog'))
99
.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf())
10-
.slice(0, 3);
10+
const postsSlice = posts.slice(0, 3);
1111
1212
const projects = (await getCollection('projects'))
1313
.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
@@ -42,8 +42,8 @@ const projectsSlice = projects.slice(0, 4);
4242
</div>
4343

4444
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
45-
{posts.length > 0 ? (
46-
posts.map((post) => (
45+
{postsSlice.length > 0 ? (
46+
postsSlice.map((post) => (
4747
<PostCard post={post} />
4848
))
4949
) : (

0 commit comments

Comments
 (0)