Skip to content

Commit 07ca347

Browse files
committed
fix
1 parent 3036012 commit 07ca347

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

public/robots.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
User-agent: *
2+
Allow: /
3+
4+
Sitemap: https://koala.ai.kr/sitemap.xml

src/app/sitemap.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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

Comments
 (0)