diff --git a/src/components/post/PostList.astro b/src/components/post/PostList.astro new file mode 100644 index 00000000..7f69d10b --- /dev/null +++ b/src/components/post/PostList.astro @@ -0,0 +1,22 @@ +--- +import type { CollectionEntry } from 'astro:content' + +import PostItem from '@/components/post/PostItem.astro' + +export interface Props { + posts: CollectionEntry[]; +} + +const { posts = [] } = Astro.props +--- + +
+ { + posts.map((p) => ( + + )) + } +
diff --git a/src/pages/index.astro b/src/pages/index.astro index 8f4e4ebf..deea56c1 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,13 +1,13 @@ --- import { getCollection } from 'astro:content' -import PostItem from '@/components/post/PostItem.astro' +import PostList from '@/components/post/PostList.astro' import siteConfig from '@/configs/site' import AppLayout from '@/layouts/AppLayout.astro' const { title, description, author } = siteConfig -const allPosts = await getCollection('leetcode-solutions') +const posts = await getCollection('leetcode-solutions') ---
-
- { - allPosts.map((p) => ( - - )) - } -
+