1 import type { MetadataRoute } from "next"
2 import getUrl from "../utils/get-url"
3 import { apiRefIntroSections, apiRefPaths } from "@/utils/api-ref-paths"
4
5 export default function sitemap(): MetadataRoute.Sitemap {
6 const items: MetadataRoute.Sitemap = []
7
8 for (const area of ["store", "admin"] as const) {
9 // area introduction page
10 items.push({
11 url: getUrl(`/${area}`),
12 lastModified: new Date(),
13 changeFrequency: "weekly",
14 })
15
16 // intro-section pages
17 for (const section of apiRefIntroSections[area] ?? []) {
18 items.push({
19 url: getUrl(`/${area}/${section.slug}`),
20 lastModified: new Date(),
21 changeFrequency: "weekly",
22 })
23 }
24
25 // tag, schema, and operation pages
26 const tags = apiRefPaths[area]?.tags ?? {}
27 for (const tag of Object.values(tags)) {
28 items.push({
29 url: getUrl(tag.path),
30 lastModified: new Date(),
31 changeFrequency: "weekly",
32 })
33 if (tag.schemaPath) {
34 items.push({
35 url: getUrl(tag.schemaPath),
36 lastModified: new Date(),
37 changeFrequency: "weekly",
38 })
39 }
40 for (const operation of Object.values(tag.operations)) {
41 items.push({
42 url: getUrl(operation.path),
43 lastModified: new Date(),
44 changeFrequency: "weekly",
45 })
46 }
47 }
48 }
49
50 return items
51 }