diff --git a/src/components/PostList.astro b/src/components/PostList.astro
index 0c0f979..eaaced6 100644
--- a/src/components/PostList.astro
+++ b/src/components/PostList.astro
@@ -3,17 +3,21 @@ import { CollectionEntry, getCollection } from 'astro:content';
export interface Props {
filterFn?: (entry: CollectionEntry<'blog'>) => unknown;
+ limit?: number;
}
-const defaultFilterFn = (entry: CollectionEntry<'blog'>) => true;
-const { filterFn = defaultFilterFn } = Astro.props;
+const defaultFilterFn = (_entry: CollectionEntry<'blog'>) => true;
+
+const { filterFn = defaultFilterFn, limit } = Astro.props;
const posts = (
await getCollection(
'blog',
(entry) => filterFn(entry) && (import.meta.env.DEV || !entry.data.draft)
)
-).sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
+)
+ .sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf())
+ .slice(0, limit);
---
{
diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro
index bea0945..637bff1 100644
--- a/src/pages/blog/index.astro
+++ b/src/pages/blog/index.astro
@@ -7,5 +7,5 @@ import PostList from '../../components/PostList.astro';
title="blog"
description="blog about the making of maciej's projects and more"
>
-