-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathTags.js
35 lines (33 loc) · 1.03 KB
/
Tags.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Link from 'next/link'
const Tags = ({ tags, currentTag }) => {
if (!tags) return null
return (
<div className="tag-container">
<ul className="flex max-w-full mt-4 overflow-x-auto">
{Object.keys(tags).map(key => {
const selected = key === currentTag
return (
<li
key={key}
className={`mr-3 font-medium border whitespace-nowrap dark:text-gray-300 ${
selected
? 'text-white bg-black border-black dark:bg-gray-600 dark:border-gray-600'
: 'bg-gray-100 border-gray-100 text-gray-400 dark:bg-night dark:border-gray-800'
}`}
>
<Link
key={key}
href={selected ? '/search' : `/tag/${encodeURIComponent(key)}`}
>
<a className="px-4 py-2 block">
{`${key} (${tags[key]})`}
</a>
</Link>
</li>
)
})}
</ul>
</div>
)
}
export default Tags