Skip to content

Commit 5310681

Browse files
committed
Add link to author
1 parent a32d296 commit 5310681

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/layouts/Post.astro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
import Layout from './Layout.astro';
33
import { format } from '../lib/date';
4+
import { links } from '@lib/links';
45
56
interface Frontmatter {
67
title: string;
@@ -19,6 +20,8 @@ const { frontmatter } = Astro.props;
1920
2021
const { title, author, toy, dateCreated, dateUpdated } = frontmatter;
2122
23+
const linkToAuthor = author ? links[author] : undefined;
24+
2225
const dates = [format(dateCreated), format(dateUpdated)].filter((d) => !!d);
2326
2427
const prefixes = {
@@ -39,7 +42,8 @@ const formattedDate = dates.map((date, idx) => `${prefixes[idx]} ${date}`).join(
3942
<small class="text-slate">
4043
{author && (
4144
<span>
42-
<span class="text-stone">written by</span> {author}
45+
<span class="text-stone">written by</span>{' '}
46+
{linkToAuthor ? <a href={linkToAuthor}>{author}</a> : author}
4347
</span>
4448
)}
4549
{formattedDate && <span class="text-stone">{formattedDate}</span>}

src/lib/links.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const links: { [key: string]: string } = {
2+
'Heechul Ryu': 'https://github.com/ryuheechul',
3+
};

0 commit comments

Comments
 (0)