Skip to content

Commit 5fc47ff

Browse files
authored
Merge pull request #19 from ansidev/feature/component-post-item
Feature: Component PostItem
2 parents 427be3a + 902e961 commit 5fc47ff

11 files changed

+116
-87
lines changed

src/components/AppFooter.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const socialNetworks: Record<string, string> = {
1717
}
1818
---
1919

20-
<footer class="my-9 text-primary">
20+
<footer class="my-9 text-style-primary">
2121
<div class="flex justify-center items-center mb-3">
2222
<a href={`mailto:${email}`} class="footer-icon">
2323
<Icon name={'bi:envelope-fill'} size={32} />
@@ -59,6 +59,6 @@ const socialNetworks: Record<string, string> = {
5959

6060
<style>
6161
a.footer-icon {
62-
@apply text-primary hover:text-secondary mx-1;
62+
@apply text-style-primary hover:text-style-secondary mx-1;
6363
}
6464
</style>

src/components/Card.astro

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/components/post/PostItem.astro

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
import Icon from '@/components/Icon.astro'
3+
4+
export interface Props {
5+
title: string
6+
href: string
7+
}
8+
9+
const { title, href } = Astro.props
10+
---
11+
12+
<a href={href}>
13+
<div class="post-item flex items-center justify-between">
14+
<div>
15+
<h2>{title}</h2>
16+
</div>
17+
<span class="px-2"><Icon name="bi:arrow-right" /></span>
18+
</div>
19+
</a>
20+
21+
<style lang="scss">
22+
.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;
26+
}
27+
</style>

src/content/leetcode-solutions/0003-longest-substring-without-repeating-characters.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
layout: "../layouts/Post.astro"
32
title: "3. Longest Substring Without Repeating Characters"
43
slug: "0003-longest-substring-without-repeating-characters"
54
keywords:

src/content/leetcode-solutions/0008-string-to-integer-atoi.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
layout: "../layouts/Post.astro"
32
title: "8. String to Integer (atoi)"
43
slug: "0008-string-to-integer-atoi"
54
keywords:

src/content/leetcode-solutions/0053-maximum-subarray.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
layout: "../layouts/Post.astro"
32
title: "53. Maximum Subarray"
43
slug: "0053-maximum-subarray"
54
keywords:

src/content/leetcode-solutions/0231-power-of-two.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
layout: "../layouts/Post.astro"
32
title: "231. Power of Two"
43
slug: "0231-power-of-two"
54
keywords:

src/content/leetcode-solutions/0628-maximum-product-of-three-numbers.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
layout: "../layouts/Post.astro"
32
title: "628. Maximum Product of Three Numbers"
43
slug: "0628-maximum-product-of-three-numbers"
54
keywords:

src/content/leetcode-solutions/2400-number-of-ways-to-reach-a-position-after-exactly-k-steps.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
layout: "../layouts/Post.astro"
32
title: "2400. Number of Ways to Reach a Position After Exactly k Steps"
43
slug: "2400-number-of-ways-to-reach-a-position-after-exactly-k-steps"
54
keywords:

src/pages/index.astro

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
---
2-
import Card from '@/components/Card.astro'
2+
import { getCollection } from 'astro:content'
3+
4+
import PostItem from '@/components/post/PostItem.astro'
35
import siteConfig from '@/configs/site'
46
import AppLayout from '@/layouts/AppLayout.astro'
57
68
const { title, description, author } = siteConfig
9+
10+
const allPosts = await getCollection('leetcode-solutions')
711
---
812

913
<AppLayout
@@ -12,28 +16,13 @@ const { title, description, author } = siteConfig
1216
author={author.name}
1317
headerCssClasses="max-w-xl px-8"
1418
>
15-
<main class="mx-auto my-4 p-4 max-w-2xl text-site-header-text">
16-
<ul role="list" class="grid grid-cols-1 md:grid-cols-2 gap-4">
17-
<Card
18-
href="https://docs.astro.build/"
19-
title="Documentation"
20-
body="Learn how Astro works and explore the official API docs."
21-
/>
22-
<Card
23-
href="https://astro.build/integrations/"
24-
title="Integrations"
25-
body="Supercharge your project with new frameworks and libraries."
26-
/>
27-
<Card
28-
href="https://astro.build/themes/"
29-
title="Themes"
30-
body="Explore a galaxy of community-built starter themes."
31-
/>
32-
<Card
33-
href="https://astro.build/chat/"
34-
title="Community"
35-
body="Come say hi to our amazing Discord community. ❤️"
36-
/>
37-
</ul>
19+
<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>
3827
</main>
3928
</AppLayout>

0 commit comments

Comments
 (0)