diff --git a/README.md b/README.md index 7d9f7c50..534b192f 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ Open the `config.json` file and configure the radar to your needs. | Attribute | Description | | --------- | ------------------------------------------------------------------------------------------------------------------------------ | | basePath | Set if hosting under a sub-path, otherwise set it to `/`. Default is `/techradar` | +| baseUrl | Set to the full URL, where the radar will be hosted. Will be used for sitemap.xml. `https://www.aoe.com/techradar` | | toggles | (optional) Modify the behaviour and contents of the radar. See config below. | | sections | (optional) Modify the order of sections (`radar`, `tags`, `list`) | | colors | A map of colors for the radar. Can be any valid CSS color value | diff --git a/data/config.default.json b/data/config.default.json index c28a8eed..a757d216 100644 --- a/data/config.default.json +++ b/data/config.default.json @@ -1,5 +1,6 @@ { "basePath": "/techradar", + "baseUrl": "", "editUrl": "https://github.dev/AOEpeople/techradar/blob/main/radar/{release}/{id}.md", "toggles": { "showChart": true, diff --git a/src/app/sitemap.ts b/src/app/sitemap.ts new file mode 100644 index 00000000..5738ad67 --- /dev/null +++ b/src/app/sitemap.ts @@ -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, + ]; +} diff --git a/src/lib/data.ts b/src/lib/data.ts index f0955a85..a0bd1929 100644 --- a/src/lib/data.ts +++ b/src/lib/data.ts @@ -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; } diff --git a/tsconfig.json b/tsconfig.json index fb68dc1a..2879b0d8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,8 +14,13 @@ "incremental": true, "paths": { "@/*": ["./src/*"] - } + }, + "plugins": [ + { + "name": "next" + } + ] }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"] }