-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: list post per tags & directory
- Loading branch information
1 parent
ffb7158
commit 102783b
Showing
5 changed files
with
210 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { getAllTags, getPostGroupByYear } from "@/lib/api"; | ||
import BaseLayout from "@/app/_components/layout/BaseLayout"; | ||
import Link from "next/link"; | ||
import dayjs from "dayjs"; | ||
import "@/app/posts/style.scss"; | ||
import { Metadata } from "next"; | ||
|
||
type Props = { | ||
params: { | ||
tag: string; | ||
}; | ||
}; | ||
|
||
export default function Tag({ params }: Props) { | ||
var postGroups = getPostGroupByYear(params.tag); | ||
|
||
return ( | ||
<BaseLayout logoText={`ls $POSTS_DIR | grep ${params.tag}`}> | ||
<main className="post"> | ||
<h1 className="text-5xl font-bold my-6">{params.tag}</h1> | ||
{postGroups.map((postGroup) => ( | ||
<div key={postGroup.year} className="posts-group"> | ||
<div className="post-year">{postGroup.year}</div> | ||
<ul className="posts-list"> | ||
{postGroup.data.map((post) => ( | ||
<li key={post.slug} className="post-item"> | ||
<Link | ||
href={`/posts/${post.slug}`} | ||
className="post-item-inner" | ||
> | ||
<span className="post-title">{post.title}</span> | ||
<span className="post-day"> | ||
{dayjs(post.date).format("MMM DD")} | ||
</span> | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
))} | ||
</main> | ||
</BaseLayout> | ||
); | ||
} | ||
export function generateMetadata({ params }: Props): Metadata { | ||
const title = `#${params.tag} :: Ridho Azhar`; | ||
|
||
return { | ||
title, | ||
robots: { follow: true, index: true }, | ||
}; | ||
} | ||
export function generateStaticParams() { | ||
const tags = getAllTags(); | ||
return tags.map((tag) => ({ | ||
tag, | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters