Added full SSG/Static support

This commit is contained in:
HangerThem 2026-08-03 15:41:20 +02:00
parent b1de88f998
commit 1f6b769ea4
3 changed files with 17 additions and 1 deletions

View file

@ -1,5 +1,5 @@
import { metadata } from '@/app/metadata' import { metadata } from '@/app/metadata'
import { getCategoryBySlug, getPostsByCategory } from '@/lib/categories' import { getAllCategories, getCategoryBySlug, getPostsByCategory } from '@/lib/categories'
import type { Metadata } from 'next' import type { Metadata } from 'next'
import Link from 'next/link' import Link from 'next/link'
@ -9,6 +9,13 @@ type CategoryPageProps = {
}> }>
} }
export async function generateStaticParams() {
const categories = getAllCategories()
return Object.keys(categories).map((category) => ({
categorySlug: category,
}))
}
export async function generateMetadata({ params }: CategoryPageProps): Promise<Metadata> { export async function generateMetadata({ params }: CategoryPageProps): Promise<Metadata> {
const { categorySlug } = await params const { categorySlug } = await params
const category = getCategoryBySlug(categorySlug) const category = getCategoryBySlug(categorySlug)

View file

@ -6,6 +6,13 @@ import Link from 'next/link'
import { metadata } from '@/app/metadata' import { metadata } from '@/app/metadata'
import { dateFormatter } from '@/utils/time' import { dateFormatter } from '@/utils/time'
export async function generateStaticParams() {
const categories = getAllCategories()
return Object.keys(categories).map((category) => ({
categorySlug: category,
}))
}
export async function generateMetadata(): Promise<Metadata> { export async function generateMetadata(): Promise<Metadata> {
return { return {
title: `Categories | ${metadata.title!.toString()}`, title: `Categories | ${metadata.title!.toString()}`,

View file

@ -1,6 +1,8 @@
import { metadata } from '@/app/metadata' import { metadata } from '@/app/metadata'
import { getAllPostsMeta } from '@/lib/posts' import { getAllPostsMeta } from '@/lib/posts'
export const dynamic = "force-static"
const SITE_URL = process.env.SITE_URL || 'http://localhost:3000' const SITE_URL = process.env.SITE_URL || 'http://localhost:3000'
function escapeXml(str: string) { function escapeXml(str: string) {