diff --git a/src/app/(frontend)/tags/[slug]/page.tsx b/src/app/(frontend)/tags/[slug]/page.tsx new file mode 100644 index 0000000..0cd8ebb --- /dev/null +++ b/src/app/(frontend)/tags/[slug]/page.tsx @@ -0,0 +1,22 @@ +import { notFound } from 'next/navigation' +import { listPosts, listAllTags } from '@/lib/posts' +import { PostList } from '@/components/PostList' + +export const revalidate = 60 + +export async function generateStaticParams() { + const tags = await listAllTags() + return tags.map(({ tag }) => ({ slug: tag.slug })) +} + +export default async function TagPage({ params }: { params: Promise<{ slug: string }> }) { + const { slug } = await params + const r = await listPosts({ tag: slug, limit: 0 }) + if (r.docs.length === 0) notFound() + return ( +
+

#{slug}

+ r.totalDocs - i)} /> +
+ ) +} diff --git a/src/app/(frontend)/tags/page.tsx b/src/app/(frontend)/tags/page.tsx new file mode 100644 index 0000000..caf6b74 --- /dev/null +++ b/src/app/(frontend)/tags/page.tsx @@ -0,0 +1,26 @@ +import Link from 'next/link' +import { listAllTags } from '@/lib/posts' + +export const revalidate = 60 + +export default async function TagsPage() { + const tags = await listAllTags() + tags.sort((a, b) => b.count - a.count) + return ( +
+

Tags

+ +
+ ) +}