Skip to content

Commit

Permalink
feat(ui): add top links on blog page
Browse files Browse the repository at this point in the history
* Add link to T.I.L page
* Add link to Categories page
* Add link to Tags page
  • Loading branch information
mateusfg7 committed Nov 29, 2023
1 parent ef0f4a5 commit 6186f10
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/app/blog/page.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,43 @@
import React from 'react'
import Link, { LinkProps } from 'next/link'

import { allPosts } from 'contentlayer/generated'
import {
FolderOpen,
Tag,
Notebook,
Icon as PhosphorIcon
} from '@/shared/wrappers/phosphor-icons'
import { getSortedPosts } from '@/shared/lib/get-sorted-posts'

import { PostList } from '@/shared/components/post-list'
import { Title } from '@/shared/components/title'

type TopLinkProps = {
Icon: PhosphorIcon
title: string
} & LinkProps
const TopLink = ({ Icon, title, ...rest }: TopLinkProps) => (
<Link
{...rest}
className="inline-flex items-center gap-1 rounded-lg p-2 leading-none text-neutral-700 transition-colors hover:bg-neutral-200/50 hover:text-neutral-900 dark:text-neutral-300 hover:dark:bg-neutral-900 dark:hover:text-neutral-100"
>
<Icon />
<span>{title}</span>
</Link>
)

export default function Page() {
const posts = getSortedPosts(allPosts)

return (
<div className="content-container m-auto">
<Title text="Blog" />
<div className="flex flex-wrap justify-center gap-4 py-4 md:justify-start">
<TopLink Icon={FolderOpen} href="/blog/categories" title="Categories" />
<TopLink Icon={Tag} href="/blog/tag" title="Tags" />
<TopLink Icon={Notebook} href="/blog/til" title="T.I.L" />
</div>
<PostList posts={posts} separateByYear />
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Props extends ComponentProps<'h1'> {

export function Title({ text, description, ...props }: Props) {
return (
<div className="mb-8 flex flex-col items-center md:items-start">
<div className="flex flex-col items-center md:items-start">
<h1
{...props}
className="w-fit bg-gradient-to-br from-neutral-900 via-neutral-900/90 to-neutral-900/70 bg-clip-text text-4xl font-semibold text-transparent dark:from-neutral-300 dark:via-neutral-300/90 dark:to-neutral-300/70"
Expand Down

0 comments on commit 6186f10

Please sign in to comment.