Raw
1 import { 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 results: MetadataRoute.Sitemap = []
7
8 for (const area of ["store", "admin"] as const) {
9 results.push({ url: getUrl(`/${area}`), lastModified: new Date() })
10
11 for (const section of apiRefIntroSections[area] ?? []) {
12 results.push({
13 url: getUrl(`/${area}/${section.slug}`),
14 lastModified: new Date(),
15 })
16 }
17
18 const tags = apiRefPaths[area]?.tags ?? {}
19 for (const tag of Object.values(tags)) {
20 results.push({ url: getUrl(tag.path), lastModified: new Date() })
21 if (tag.schemaPath) {
22 results.push({ url: getUrl(tag.schemaPath), lastModified: new Date() })
23 }
24 for (const operation of Object.values(tag.operations)) {
25 results.push({ url: getUrl(operation.path), lastModified: new Date() })
26 }
27 }
28 }
29
30 return results
31 }