Skip to content

Commit 9b4a99d

Browse files
committed
feat(component): add component PostHeader
1 parent b0425c1 commit 9b4a99d

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
import type { CollectionEntry } from 'astro:content'
3+
import kebabCase from 'lodash.kebabcase'
4+
5+
import LeetCodeDifficulty from '@/components/LeetCodeDifficulty.astro'
6+
import siteConfig from '@/configs/site'
7+
import { formatDate } from '@/utils/date'
8+
9+
type Props = CollectionEntry<'leetcode-solutions'>['data']
10+
11+
const { author: siteAuthor } = siteConfig
12+
const { title, author, pubDate, tags = [], difficulty } = Astro.props
13+
14+
const formattedDate = formatDate(pubDate)
15+
---
16+
17+
<div class="post-header">
18+
<h1 class="text-2xl mb-3">{title}</h1>
19+
<div class="flex justify-center items-center mb-3">
20+
<LeetCodeDifficulty difficulty={difficulty} />
21+
</div>
22+
<div class="flex flex-row flex-wrap justify-center items-center mb-3">
23+
{
24+
tags.map((tag) => (
25+
<a href={`/tags/${kebabCase(tag)}`} class="mx-1 my-3">
26+
<span class="p-2 bg-style-secondary text-style-primary-inverted hover:bg-style-secondary-inverted hover:text-style-primary">
27+
{tag}
28+
</span>
29+
</a>
30+
))
31+
}
32+
</div>
33+
<div class="flex justify-center m-3 text-start">
34+
<img
35+
src={siteAuthor.avatar}
36+
alt="Author's avatar"
37+
style="margin-bottom: 0 !important;"
38+
width="64"
39+
height="64"
40+
/>
41+
<div class="flex flex-col justify-center ml-3">
42+
<span class="mb-1">{author}</span>
43+
<span class="mb-1">Posted on {formattedDate}</span>
44+
</div>
45+
</div>
46+
</div>
47+
48+
<style>
49+
.post-header {
50+
@apply p-3 mb-3 bg-style-primary text-center text-style-primary-inverted;
51+
}
52+
</style>

0 commit comments

Comments
 (0)