Skip to content

Commit

Permalink
feat: add tag component
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisrick25 committed Oct 29, 2023
1 parent 37d5136 commit fa3b433
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { formatDate } from "@/lib/formatDate";
import MDXContent from "@/components/mdxContent";
import { notFound } from 'next/navigation';
import TableOfContents from '@/components/tableOfContents';
import Tag from '@/components/tag';

export async function generateStaticParams() {
return allBlogs
Expand Down Expand Up @@ -41,6 +42,7 @@ export default function Page({ params }) {
<p>{formatDate(blog?.publishedAt)}</p>
<p className='justify-self-end'>views</p>
</div>
<Tag blog={blog} />
<TableOfContents blog={blog} />
<MDXContent code={blog?.body.code}/>
</div>
Expand Down
19 changes: 19 additions & 0 deletions components/tag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ts-ignore
export default function Tag({ blog }) {
return (
<div className="text-neutral-600 dark:text-neutral-400 text-base rounded-lg mb-4 overflow-hidden overflow-y-auto ">
{//@ts-ignore
blog.tags.map((tag, index) => {
return (
<>
<a href={`#${tag}`}>
<span className="hover:underline">{`#${tag}`}</span>
</a>
{index !== blog.tags.length - 1 && ", "} {/* Add a comma after each tag except the last one */}
</>
)
})
}
</div>
)
}

0 comments on commit fa3b433

Please sign in to comment.