Skip to content

Commit 20b0f18

Browse files
committed
Create sitemap
1 parent bde7911 commit 20b0f18

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

src/app/sitemap.ts

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1-
import type { MetadataRoute } from 'next'
2-
3-
import { BASE_URL } from '@/constants/site-metadata'
4-
5-
export default function sitemap(): MetadataRoute.Sitemap {
6-
return [
7-
{
8-
url: BASE_URL,
9-
lastModified: new Date(),
10-
changeFrequency: 'weekly',
11-
priority: 1,
12-
},
13-
]
1+
import type { MetadataRoute } from "next";
2+
3+
import { getAllRFSData } from "@/app/agents/utils/get-rfs-data";
4+
import { PATHS } from "@/constants/paths";
5+
import { BASE_URL } from "@/constants/site-metadata";
6+
7+
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
8+
const staticRoutes = getStaticRoutes();
9+
const agentRoutes = await getAgentRoutes();
10+
11+
return [...staticRoutes, ...agentRoutes];
12+
}
13+
14+
const lastModified = new Date();
15+
16+
function getStaticRoutes() {
17+
return Object.values(PATHS).map(({ path }) => ({
18+
url: `${BASE_URL}${path}`,
19+
lastModified,
20+
changeFrequency: "weekly" as const,
21+
priority: path === "/" ? 1 : 0.8,
22+
}));
23+
}
24+
25+
async function getAgentRoutes() {
26+
const allRFSData = await getAllRFSData();
27+
28+
return allRFSData.map(({ slug }) => ({
29+
url: `${BASE_URL}${PATHS.AGENTS.path}/${slug}`,
30+
lastModified,
31+
changeFrequency: "weekly" as const,
32+
priority: 0.7,
33+
}));
1434
}

0 commit comments

Comments
 (0)