|
| 1 | +import type { MetadataRoute } from "next"; |
| 2 | +import { getAllPosts } from "@/lib/posts"; |
| 3 | + |
| 4 | +const BASE = process.env.NEXT_PUBLIC_SITE_URL ?? "https://koala.ai.kr"; |
| 5 | + |
| 6 | +export default async function sitemap(): Promise<MetadataRoute.Sitemap> { |
| 7 | + const posts = await getAllPosts(); |
| 8 | + |
| 9 | + const postEntries: MetadataRoute.Sitemap = posts.map((post) => ({ |
| 10 | + url: `${BASE}/posts/${post.slug}`, |
| 11 | + lastModified: new Date(post.date), |
| 12 | + changeFrequency: "monthly", |
| 13 | + priority: 0.8, |
| 14 | + })); |
| 15 | + |
| 16 | + const staticPages: MetadataRoute.Sitemap = [ |
| 17 | + { url: BASE, lastModified: new Date(), changeFrequency: "weekly", priority: 1.0 }, |
| 18 | + { url: `${BASE}/posts`, lastModified: new Date(), changeFrequency: "daily", priority: 0.9 }, |
| 19 | + { url: `${BASE}/about`, lastModified: new Date(), changeFrequency: "monthly", priority: 0.5 }, |
| 20 | + { url: `${BASE}/game`, lastModified: new Date(), changeFrequency: "monthly", priority: 0.4 }, |
| 21 | + { url: `${BASE}/stats`, lastModified: new Date(), changeFrequency: "daily", priority: 0.4 }, |
| 22 | + ]; |
| 23 | + |
| 24 | + return [...staticPages, ...postEntries]; |
| 25 | +} |
0 commit comments