Skip to content

Commit 75c3a57

Browse files
committed
feat(page): update homepage
1 parent 3e0a5dd commit 75c3a57

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

src/components/post/PostItem.astro

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export interface Props {
99
const { title, href } = Astro.props
1010
---
1111

12-
<a href={href}>
13-
<div class="post-item flex items-center justify-between">
12+
<a href={href} class="post-item">
13+
<div class="flex items-center justify-between">
1414
<div>
1515
<h2>{title}</h2>
1616
</div>
@@ -20,8 +20,17 @@ const { title, href } = Astro.props
2020

2121
<style lang="scss">
2222
.post-item {
23-
@apply mx-3 my-2 p-3;
24-
@apply border-2 border-solid border-style-primary;
25-
@apply hover:bg-style-primary text-style-secondary hover:text-style-primary-inverted;
23+
&:first-child {
24+
@apply mt-4;
25+
}
26+
&:last-child {
27+
@apply mb-4;
28+
}
29+
30+
& > div {
31+
@apply mx-4 p-4;
32+
@apply border-2 border-solid border-style-primary;
33+
@apply hover:bg-style-primary text-style-secondary hover:text-style-primary-inverted;
34+
}
2635
}
2736
</style>

src/components/post/PostList.astro

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@ import type { CollectionEntry } from 'astro:content'
44
import PostItem from '@/components/post/PostItem.astro'
55
66
export interface Props {
7-
posts: CollectionEntry<any>[];
7+
posts: CollectionEntry<any>[]
88
}
99
1010
const { posts = [] } = Astro.props
1111
---
1212

1313
<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-
}
14+
{posts.map((p) => <PostItem title={`${p.data.title}`} href={`/${p.slug}`} />)}
2215
</div>

src/pages/index.astro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
import { getCollection } from 'astro:content'
33
4+
import LeetCodeDifficulty from '@/components/LeetCodeDifficulty.astro'
45
import PostList from '@/components/post/PostList.astro'
56
import siteConfig from '@/configs/site'
67
import AppLayout from '@/layouts/AppLayout.astro'
@@ -17,6 +18,11 @@ const posts = await getCollection('leetcode-solutions')
1718
headerCssClasses="max-w-xl px-8"
1819
>
1920
<main class="mx-auto my-4 p-4 max-w-xl text-site-header-text">
21+
<div class="grid grid-flow-col auto-cols-max gap-2 m-4 justify-center">
22+
<LeetCodeDifficulty difficulty="Easy" />
23+
<LeetCodeDifficulty difficulty="Medium" />
24+
<LeetCodeDifficulty difficulty="Hard" />
25+
</div>
2026
<PostList posts={posts} />
2127
</main>
2228
</AppLayout>

0 commit comments

Comments
 (0)