Skip to content

Commit d0ccf16

Browse files
committed
feat(blog): made each post title a link to the blog post itself.
1 parent 07e285a commit d0ccf16

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

Diff for: components/blog/post.tsx

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
import {BlogPost} from "../../types/blogPost";
22
import Section from "./section";
33
import {toAgoTime} from "../../utils/timeUtils";
4+
import Link from "next/link";
5+
import Capsule from "../uiLibrary/capsule";
6+
import Dict = NodeJS.Dict;
7+
8+
const colourByType: Dict<string> = {
9+
'announcement': 'blue',
10+
'weekly': 'indigo',
11+
'community': 'green',
12+
}
13+
14+
const textByType: Dict<string> = {
15+
'announcement': 'Announcement',
16+
'weekly': 'Weekly Update',
17+
'community': 'Community Highlight',
18+
}
19+
420

521
const Post = (props: BlogPost) => {
6-
const {title, author, date_created, sections} = props;
22+
const {title, author, date_created, slug, type, sections} = props;
723

824
return (
925
<>
@@ -13,9 +29,11 @@ const Post = (props: BlogPost) => {
1329
<address className={'flex items-center mb-6 not-italic'}>
1430
<div className="inline-flex items-center mr-3 text-sm text-white">
1531
<div>
16-
<h1 className="mb-4 text-4xl text-center font-extrabold leading-tight lg:mb-6 text-white">
17-
{title}
18-
</h1>
32+
<Link href={`/blog/${slug}`}>
33+
<h1 className="mb-4 text-4xl text-center font-extrabold leading-tight lg:mb-6 text-white hover:underline hover:cursor-pointer">
34+
{title}
35+
</h1>
36+
</Link>
1937
<p className="text-xl font-bold text-white">by {author}</p>
2038
<p className="text-base font-light text-gray-500 dark:text-gray-400">
2139
<time dateTime={date_created?.toString()} title={date_created?.toString()}>

Diff for: components/uiLibrary/capsule.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import classNames from "classnames";
2+
interface CapsuleProps {
3+
text: string
4+
colour: string
5+
}
6+
7+
export default function Capsule(props: CapsuleProps) {
8+
const {text, colour} = props;
9+
const classes = classNames(
10+
'inline-flex items-center justify-center px-2 py-1 mr-2 text-xs font-bold leading-none rounded',
11+
{
12+
'text-indigo-100 bg-indigo-600': colour === 'indigo',
13+
'text-green-100 bg-green-600': colour === 'green',
14+
'text-blue-100 bg-blue-600': colour === 'blue',
15+
});
16+
17+
return (
18+
<span className={classes}>
19+
{text}
20+
</span>
21+
)
22+
}

0 commit comments

Comments
 (0)