File tree Expand file tree Collapse file tree 2 files changed +25
-9
lines changed
Expand file tree Collapse file tree 2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ import type { CollectionEntry } from ' astro:content'
3+
4+ import PostItem from ' @/components/post/PostItem.astro'
5+
6+ export interface Props {
7+ posts: CollectionEntry <any >[];
8+ }
9+
10+ const { posts = [] } = Astro .props
11+ ---
12+
13+ <div role =" list" class =" grid grid-cols-1 gap-4" >
14+ {
15+ posts .map ((p ) => (
16+ <PostItem
17+ title = { ` ${p .data .title } ` }
18+ href = { ` /${p .slug } ` }
19+ />
20+ ))
21+ }
22+ </div >
Original file line number Diff line number Diff line change 11---
22import { getCollection } from ' astro:content'
33
4- import PostItem from ' @/components/post/PostItem .astro'
4+ import PostList from ' @/components/post/PostList .astro'
55import siteConfig from ' @/configs/site'
66import AppLayout from ' @/layouts/AppLayout.astro'
77
88const { title, description, author } = siteConfig
99
10- const allPosts = await getCollection (' leetcode-solutions' )
10+ const posts = await getCollection (' leetcode-solutions' )
1111---
1212
1313<AppLayout
@@ -17,12 +17,6 @@ const allPosts = await getCollection('leetcode-solutions')
1717 headerCssClasses =" max-w-xl px-8"
1818>
1919 <main class =" mx-auto my-4 p-4 max-w-xl text-site-header-text" >
20- <div role =" list" class =" grid grid-cols-1 gap-4" >
21- {
22- allPosts .map ((p ) => (
23- <PostItem href = { ` /${p .slug } ` } title = { p .data .title } />
24- ))
25- }
26- </div >
20+ <PostList posts ={ posts } />
2721 </main >
2822</AppLayout >
You can’t perform that action at this time.
0 commit comments