Skip to content

Commit 26068a8

Browse files
authored
Adds Typescript and Tailwind (#18)
1 parent 52427cd commit 26068a8

39 files changed

+2178
-1051
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ yarn-error.log*
3232

3333
# vercel
3434
.vercel
35+
.vscode

components/comments/comment.tsx

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import dayjs from "../../lib/dayjs";
2+
import { GithubComment } from "../../types/github";
3+
import { Link, LinkWithAvatar } from "../link";
4+
import Markdown from "../markdown/Markdown";
5+
6+
interface CommentProps {
7+
body: string;
8+
createdAt: string;
9+
username: string;
10+
avatarURL: string;
11+
authorURL: string;
12+
commentURL: string;
13+
}
14+
15+
export default function Comment({
16+
body,
17+
createdAt,
18+
username,
19+
avatarURL,
20+
authorURL,
21+
commentURL,
22+
}: CommentProps) {
23+
return (
24+
<div className="pb-7 border-b-gray-100 dark:border-b-gray-700 border-b-2">
25+
<LinkWithAvatar
26+
href={authorURL}
27+
avatarUrl={avatarURL}
28+
alt={`@${username}`}
29+
>
30+
{username}
31+
</LinkWithAvatar>
32+
<div className="my-3">
33+
<Markdown document={body} />
34+
</div>
35+
<Link
36+
variant="subtle"
37+
href={commentURL}
38+
title={dayjs(createdAt).format("MMM D, YYYY h:mmA")}
39+
>
40+
{dayjs(createdAt).fromNow()}
41+
</Link>
42+
</div>
43+
);
44+
}

components/comments/comments.tsx

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Gist, GithubComment } from "../../types/github";
2+
import Comment from "./comment";
3+
4+
interface GistCommentsProps {
5+
gistUrl: string;
6+
commentData?: GithubComment[];
7+
}
8+
9+
export default function GistComments({
10+
gistUrl,
11+
commentData,
12+
}: GistCommentsProps) {
13+
return (
14+
<div className="mt-14">
15+
{commentData ? (
16+
<>
17+
<h2 className="text-2xl">Comments ({commentData.length})</h2>
18+
<ul className="mt-4 flex flex-col gap-7">
19+
{commentData.map((comment) => (
20+
<Comment
21+
key={comment.id}
22+
body={comment.body}
23+
createdAt={comment.created_at}
24+
username={comment.user.login}
25+
avatarURL={comment.user.avatar_url}
26+
authorURL={comment.user.html_url}
27+
// This is an undocumented way to link directly to a gist comment
28+
commentURL={`${gistUrl}#gistcomment-${comment.id}`}
29+
/>
30+
))}
31+
</ul>
32+
</>
33+
) : null}
34+
<div className="mt-10">
35+
<a
36+
href={gistUrl}
37+
target="_blank"
38+
rel="noreferrer"
39+
className="bg-gray-100 hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-100 block p-4 text-center rounded-full"
40+
>
41+
Comment on Github
42+
</a>
43+
</div>
44+
</div>
45+
);
46+
}

components/comments/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Comments } from "./comments";

components/footer.js

-14
This file was deleted.

components/footer.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Link from "next/link";
2+
import Logo from "./logo";
3+
4+
export default function Footer() {
5+
return (
6+
<div className="mx-4 my-10 flex items-center justify-center">
7+
<Link href="/">
8+
<a aria-label="Gistdoc" className="h-8 w-8">
9+
<Logo />
10+
</a>
11+
</Link>
12+
</div>
13+
);
14+
}

components/gist-document-skeleton.js

-81
This file was deleted.

components/gist-document.js

-128
This file was deleted.

0 commit comments

Comments
 (0)