fix(tags): guard generateStaticParams against empty content dir
This commit is contained in:
@@ -12,6 +12,9 @@ export const dynamic = 'force-static'
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const tags = await getAllTags()
|
||||
if (tags.length === 0) {
|
||||
return [{ tag: '__no-tags__' }]
|
||||
}
|
||||
return tags.map((tag) => ({ tag: tag.slug }))
|
||||
}
|
||||
|
||||
@@ -27,6 +30,9 @@ export async function generateMetadata({ params }: TagPageProps): Promise<Metada
|
||||
|
||||
export default async function TagPage({ params }: TagPageProps) {
|
||||
const slug = (await params).tag
|
||||
|
||||
if (slug === '__no-tags__') notFound()
|
||||
|
||||
const tags = await getAllTags()
|
||||
const tag = tags.find((item) => item.slug === slug)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user