Skip to content

Commit

Permalink
feat: add sitemap.xml
Browse files Browse the repository at this point in the history
closes #359
closes #438
  • Loading branch information
mathiasschopmans committed Mar 25, 2024
1 parent 43513bb commit a8172e6
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
1 change: 1 addition & 0 deletions data/config.default.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"basePath": "/techradar",
"baseUrl": "",
"editUrl": "https://github.dev/AOEpeople/techradar/blob/main/radar/{release}/{id}.md",
"toggles": {
"showChart": true,
Expand Down
37 changes: 37 additions & 0 deletions src/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -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,
];
}
4 changes: 4 additions & 0 deletions src/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 7 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}

0 comments on commit a8172e6

Please sign in to comment.