feat: add sitemap.xml

closes #359
closes #438
This commit is contained in:
Mathias Schopmans
2024-03-15 13:42:26 +01:00
committed by Mathias Schopmans
parent 43513bb1ec
commit a8172e6579
5 changed files with 50 additions and 2 deletions

37
src/app/sitemap.ts Normal file
View File

@@ -0,0 +1,37 @@
import { MetadataRoute } from "next";
import { getAbsoluteUrl, getItems, getQuadrants } from "@/lib/data";
export default function sitemap(): MetadataRoute.Sitemap {
const quadrants = getQuadrants().map((quadrant) => ({
url: getAbsoluteUrl(`/${quadrant.id}/`),
lastModified: new Date(),
priority: 0.8,
}));
const items = getItems().map((item) => ({
url: getAbsoluteUrl(`/${item.quadrant}/${item.id}/`),
lastModified: new Date(),
priority: 0.5,
}));
return [
{
url: getAbsoluteUrl(),
lastModified: new Date(),
priority: 1,
},
{
url: getAbsoluteUrl("/overview/"),
lastModified: new Date(),
priority: 0.9,
},
{
url: getAbsoluteUrl("/help-and-about-tech-radar/"),
lastModified: new Date(),
priority: 0.9,
},
...quadrants,
...items,
];
}

View File

@@ -80,6 +80,10 @@ export function getImprintUrl() {
return config.imprint;
}
export function getAbsoluteUrl(path: string = "/") {
return `${config.baseUrl}${path}`;
}
export function getItem(id: string): Item | undefined {
return data.items.find((item) => item.id === id) as Item;
}