diff --git a/client/components/post-page/index.tsx b/client/components/post-page/index.tsx index a6b04252..ca79e581 100644 --- a/client/components/post-page/index.tsx +++ b/client/components/post-page/index.tsx @@ -6,8 +6,10 @@ import styles from './post-page.module.css' import homeStyles from '@styles/Home.module.css' import type { File, Post } from "@lib/types" -import { Page, Button, Text } from "@geist-ui/core" +import { Page, Button, Text, Badge, Tooltip, Spacer } from "@geist-ui/core" import ShiftBy from "@components/shift-by" +import { useMemo, useState } from "react" +import timeAgo from "@lib/time-ago" type Props = { post: Post @@ -29,6 +31,10 @@ const PostPage = ({ post }: Props) => { link.click() link.remove() } + const createdDate = useMemo(() => new Date(post.createdAt), [post.createdAt]) + const [time, setTimeAgo] = useState(timeAgo(createdDate)) + + const formattedTime = `${createdDate.toLocaleDateString()} ${createdDate.toLocaleTimeString()}` return ( @@ -46,9 +52,10 @@ const PostPage = ({ post }: Props) => {
{post.title} - + - + {time} +