Skip to content

Commit 6702736

Browse files
committed
Update BlockEntry props to use fields from PostEntry
1 parent 33db16d commit 6702736

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

app/(subpages)/leetcode-meditations/page.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,13 @@ export default function Page() {
1616
: -1;
1717
})
1818
.map((post) => {
19-
const date = new Date(post.date).toLocaleDateString('en-US', {
20-
month: 'numeric',
21-
day: 'numeric',
22-
year: 'numeric',
23-
});
24-
2519
return (
2620
<BlockEntry
2721
key={`post-item-${post.slug}`}
2822
href={`/blog/${post.slug}`}
2923
title={post.title}
30-
date={new Date(date)}
24+
date={post.date}
25+
isThirdParty={false}
3126
/>
3227
);
3328
})}

app/components/block-entry/index.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@ import Link from '@components/link';
22
import styles from './block-entry.module.css';
33
import { convertMDWithInlineCodeToHTML } from '@lib/utils';
44
import { ExternalLink } from '@components/icons';
5+
import { PostEntry } from '@lib/types';
56

6-
type Props = {
7-
title: string;
8-
href: string;
9-
date?: Date;
7+
// type Props = {
8+
// title: string;
9+
// href: string;
10+
// date?: Date;
11+
// dateInfo?: string;
12+
// isThirdParty?: boolean;
13+
// };
14+
15+
type BlockEntryProps = Pick<PostEntry, 'title' | 'date' | 'isThirdParty'> & {
1016
dateInfo?: string;
11-
thirdPartyPost?: boolean;
17+
href: string;
1218
};
1319

14-
export default function BlockEntry(props: Props) {
15-
const { title, href, date, dateInfo, thirdPartyPost } = props;
20+
export default function BlockEntry(props: BlockEntryProps) {
21+
const { title, date, dateInfo, isThirdParty, href } = props;
1622

1723
return (
1824
<li className={styles.item}>
@@ -21,15 +27,15 @@ export default function BlockEntry(props: Props) {
2127
title={title}
2228
className={styles.link}
2329
underline={false}
24-
external={thirdPartyPost}
30+
external={isThirdParty}
2531
>
2632
{/* {type && <div className={styles.type}>{type}</div>} */}
2733
{date && (
2834
<div className={styles.wrapper}>
2935
{date && (
3036
<span className={styles.date}>
31-
{dateInfo && dateInfo} {' '}
32-
{date.toLocaleDateString('en-US', {
37+
{dateInfo && dateInfo}{' '}
38+
{new Date(date).toLocaleDateString('en-US', {
3339
month: 'short',
3440
day: 'numeric',
3541
year: 'numeric',
@@ -45,7 +51,7 @@ export default function BlockEntry(props: Props) {
4551
__html: convertMDWithInlineCodeToHTML(title),
4652
}}
4753
></h4>
48-
{thirdPartyPost && <ExternalLink />}
54+
{isThirdParty && <ExternalLink />}
4955
</div>
5056
{/* {description && <p className={styles.description}>{description}</p>} */}
5157
</Link>

app/page.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import styles from './page.module.css';
33
import BlockEntry from '@components/block-entry';
44
import { selectedPosts } from '@lib/constants';
55

6-
76
export default async function HomePage() {
87
return (
98
<>
@@ -42,9 +41,14 @@ export default async function HomePage() {
4241
return (
4342
<BlockEntry
4443
key={`post-item-${post.slug}`}
45-
href={`/blog/${post.slug}`}
4644
title={post.title}
47-
date={new Date(post.date)}
45+
date={post.date}
46+
isThirdParty={post.isThirdParty}
47+
href={
48+
!post.isThirdParty
49+
? `/blog/${post.slug}`
50+
: post.thirdPartyPostHref
51+
}
4852
/>
4953
);
5054
})}

0 commit comments

Comments
 (0)