From 31182faa4542391af6561d47db8cf0383051800f Mon Sep 17 00:00:00 2001 From: vhaudiquet Date: Mon, 2 Dec 2024 19:35:49 +0100 Subject: [PATCH] Dynamic sitemap generation :) --- frontend/nuxt.config.ts | 5 +++++ frontend/server/api/routemap.ts | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 frontend/server/api/routemap.ts diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index 8bdd9d9..7c224ea 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -15,6 +15,11 @@ export default defineNuxtConfig({ description: 'BuildPath: a tool for League of Legends champions runes and build paths.', defaultLocale: 'en', // not needed if you have @nuxtjs/i18n installed }, + sitemap: { + sources: [ + '/api/routemap' + ] + }, app: { head: { diff --git a/frontend/server/api/routemap.ts b/frontend/server/api/routemap.ts new file mode 100644 index 0000000..17decd3 --- /dev/null +++ b/frontend/server/api/routemap.ts @@ -0,0 +1,17 @@ +import { CDRAGON_BASE } from "~/utils/cdragon"; + +async function championRoutes() { + const championsData : Array = await + (await fetch(CDRAGON_BASE + "plugins/rcp-be-lol-game-data/global/default/v1/champion-summary.json")).json() + + let routes : Array = [] + for(let champion of championsData) { + routes.push("/champion/" + champion.alias.toLowerCase()) + } + return routes +} + +export default defineEventHandler(async (_) => { + const data = await championRoutes(); + return data +})