Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/components/post/PostList.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
import type { CollectionEntry } from 'astro:content'

import PostItem from '@/components/post/PostItem.astro'

export interface Props {
posts: CollectionEntry<any>[];
}

const { posts = [] } = Astro.props
---

<div role="list" class="grid grid-cols-1 gap-4">
{
posts.map((p) => (
<PostItem
title={`${p.data.title}`}
href={`/${p.slug}`}
/>
))
}
</div>
12 changes: 3 additions & 9 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -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')
---

<AppLayout
Expand All @@ -17,12 +17,6 @@ const allPosts = await getCollection('leetcode-solutions')
headerCssClasses="max-w-xl px-8"
>
<main class="mx-auto my-4 p-4 max-w-xl text-site-header-text">
<div role="list" class="grid grid-cols-1 gap-4">
{
allPosts.map((p) => (
<PostItem href={`/${p.slug}`} title={p.data.title} />
))
}
</div>
<PostList posts={posts} />
</main>
</AppLayout>