|
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 | + })); |
14 | 34 | } |
0 commit comments