Skip to content

Commit

Permalink
sort imports. link to author.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregrickaby committed Feb 14, 2024
1 parent 13b9217 commit 4db9561
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions components/Posts.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
'use client'

import Media from '@/components/Media'
import {getTimeAgo} from '@/lib/functions'
import {formatNumber, getTimeAgo} from '@/lib/functions'
import {RedditPostResponse} from '@/lib/types'
import {IconArrowUp, IconClock, IconMessage} from '@tabler/icons-react'
import {
IconArrowUp,
IconClock,
IconMessage,
IconUser
} from '@tabler/icons-react'
import {decode} from 'html-entities'
import Masonry from 'react-masonry-css'

/**
Expand All @@ -23,8 +29,10 @@ export default function Posts({data}: RedditPostResponse) {
>
<header className="flex gap-4 text-left">
<div className="flex flex-col items-center gap-0">
<IconArrowUp height={16} width={16} />
<span className="font-bold">{data.score}</span>
<IconArrowUp height={18} width={18} />
<span className="text-base font-bold">
{formatNumber(data.score)}
</span>
</div>

<div className="flex flex-col gap-1">
Expand All @@ -33,21 +41,29 @@ export default function Posts({data}: RedditPostResponse) {
href={`https://www.reddit.com${data.permalink}`}
rel="noopener noreferrer"
>
{data.title}
{decode(data.title)}
</a>
<div className="flex gap-2 text-xs">
<time className="flex items-center gap-1">
<IconClock height={16} width={16} />
{getTimeAgo(data.created_utc)}
</time>
<a
className="flex items-center gap-1"
href={`https://www.reddit.com/u/${decode(data.author)}`}
rel="noopener noreferrer"
>
<IconUser height={16} width={16} />
u/{decode(data.author)}
</a>
<a
className="flex items-center gap-1"
href={`https://www.reddit.com${data.permalink}`}
rel="noopener noreferrer"
>
<IconMessage height={16} width={16} />
{data.num_comments}
{formatNumber(data.num_comments)}
</a>
<time className="flex items-center gap-1">
<IconClock height={16} width={16} />
{getTimeAgo(data.created_utc)}
</time>
</div>
</div>
</header>
Expand Down

0 comments on commit 4db9561

Please sign in to comment.