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" > - + diff --git a/src/pages/index.astro b/src/pages/index.astro index 9e09778..f0f09e8 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,4 +1,5 @@ --- +import PostList from '../components/PostList.astro'; import { SITE_DESCRIPTION } from '../consts'; import BaseLayout from '../layouts/BaseLayout.astro'; --- @@ -23,22 +24,10 @@ import BaseLayout from '../layouts/BaseLayout.astro'; workings of my applications. Check out the latest posts below:

- +
-

Enjoy my work?

+

Like my work?

If so, make sure to follow me on