From 1f577c2317368146f07062428669b515b91a18a5 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Fri, 27 Dec 2024 13:16:51 -0600 Subject: [PATCH] feat: i18n paths --- .../[...locale]/auth/[provider]/index.astro | 7 ++++++- .../pages/[...locale]/tools/charts/index.astro | 2 ++ .../pages/[...locale]/tools/compare/index.astro | 2 ++ .../[...locale]/tools/embed/[embed]/index.astro | 16 +++++++++++++--- .../pages/[...locale]/tools/embed/index.astro | 2 ++ .../pages/[...locale]/tools/gallery/index.astro | 2 ++ .../[...locale]/tools/performance/index.astro | 2 ++ .../pages/[...locale]/tools/session/index.astro | 2 ++ .../tools/tankopedia/[id]/index.astro | 12 +++++++++--- .../[...locale]/tools/tankopedia/index.astro | 2 ++ .../[...locale]/tools/tier-list/index.astro | 2 ++ 11 files changed, 44 insertions(+), 7 deletions(-) diff --git a/packages/website/src/pages/[...locale]/auth/[provider]/index.astro b/packages/website/src/pages/[...locale]/auth/[provider]/index.astro index 71779a58f..dde72c3fd 100644 --- a/packages/website/src/pages/[...locale]/auth/[provider]/index.astro +++ b/packages/website/src/pages/[...locale]/auth/[provider]/index.astro @@ -3,10 +3,15 @@ import { Flex, Heading, Text } from '@radix-ui/themes'; import type { GetStaticPaths } from 'astro'; import { PageWrapper } from '../../../../components/PageWrapper'; import BaseLayout from '../../../../layouts/BaseLayout.astro'; +import { getStaticPaths as parentGetStaticPaths } from '../../index.astro'; import { AUTH_PROVIDERS, AUTH_PROVIDER_NAMES, Authorize } from './_index'; export const getStaticPaths = (() => { - return AUTH_PROVIDERS.map((provider) => ({ params: { provider } })); + const parentPaths = parentGetStaticPaths(); + + return AUTH_PROVIDERS.map((provider) => + parentPaths.map((parent) => ({ params: { ...parent.params, provider } })), + ).flat(); }) satisfies GetStaticPaths; const { provider } = Astro.params; diff --git a/packages/website/src/pages/[...locale]/tools/charts/index.astro b/packages/website/src/pages/[...locale]/tools/charts/index.astro index 3656de25d..d04592c03 100644 --- a/packages/website/src/pages/[...locale]/tools/charts/index.astro +++ b/packages/website/src/pages/[...locale]/tools/charts/index.astro @@ -2,6 +2,8 @@ import { chartsTool } from '../../../../constants/tools'; import ToolLayout from '../../../../layouts/ToolLayout.astro'; import { Page } from './_index'; + +export { getStaticPaths } from '../../index.astro'; --- diff --git a/packages/website/src/pages/[...locale]/tools/compare/index.astro b/packages/website/src/pages/[...locale]/tools/compare/index.astro index 38b677cc3..8c28f897f 100644 --- a/packages/website/src/pages/[...locale]/tools/compare/index.astro +++ b/packages/website/src/pages/[...locale]/tools/compare/index.astro @@ -3,6 +3,8 @@ import ToolOpenGraph from '../../../../components/ToolOpenGraph.astro'; import { compareTool } from '../../../../constants/tools'; import BaseLayout from '../../../../layouts/BaseLayout.astro'; import { Page } from './_index'; + +export { getStaticPaths } from '../../index.astro'; --- diff --git a/packages/website/src/pages/[...locale]/tools/embed/[embed]/index.astro b/packages/website/src/pages/[...locale]/tools/embed/[embed]/index.astro index 3c6dd563c..72313bcc9 100644 --- a/packages/website/src/pages/[...locale]/tools/embed/[embed]/index.astro +++ b/packages/website/src/pages/[...locale]/tools/embed/[embed]/index.astro @@ -3,12 +3,22 @@ import type { GetStaticPaths } from 'astro'; import { capitalize } from 'lodash-es'; import { embedConfigurations } from '../../../../../constants/embeds'; import BaseLayout from '../../../../../layouts/BaseLayout.astro'; +import { getStaticPaths as parentGetStaticPaths } from '../index.astro'; import { Page } from './_index'; export const getStaticPaths = (() => { - return Object.keys(embedConfigurations).map((embed) => ({ - params: { embed: embed as keyof typeof embedConfigurations }, - })); + const parentPaths = parentGetStaticPaths(); + + return Object.keys(embedConfigurations) + .map((embed) => + parentPaths.map((parent) => ({ + params: { + ...parent.params, + embed: embed as keyof typeof embedConfigurations, + }, + })), + ) + .flat(); }) satisfies GetStaticPaths; --- diff --git a/packages/website/src/pages/[...locale]/tools/embed/index.astro b/packages/website/src/pages/[...locale]/tools/embed/index.astro index 68bb9fcb7..96c841177 100644 --- a/packages/website/src/pages/[...locale]/tools/embed/index.astro +++ b/packages/website/src/pages/[...locale]/tools/embed/index.astro @@ -2,6 +2,8 @@ import { embedTool } from '../../../../constants/tools'; import ToolLayout from '../../../../layouts/ToolLayout.astro'; import { Page } from './_index'; + +export { getStaticPaths } from '../../index.astro'; --- diff --git a/packages/website/src/pages/[...locale]/tools/gallery/index.astro b/packages/website/src/pages/[...locale]/tools/gallery/index.astro index 017440b20..b9d649d2a 100644 --- a/packages/website/src/pages/[...locale]/tools/gallery/index.astro +++ b/packages/website/src/pages/[...locale]/tools/gallery/index.astro @@ -5,6 +5,8 @@ import { fetchGlossary } from '../../../../core/blitz/fetchGlossary'; import ToolLayout from '../../../../layouts/ToolLayout.astro'; import { Page } from './_index'; +export { getStaticPaths } from '../../index.astro'; + const glossary = await fetchGlossary(); const avatars = Object.entries(glossary) .filter( diff --git a/packages/website/src/pages/[...locale]/tools/performance/index.astro b/packages/website/src/pages/[...locale]/tools/performance/index.astro index 8b8d90988..ed283ae41 100644 --- a/packages/website/src/pages/[...locale]/tools/performance/index.astro +++ b/packages/website/src/pages/[...locale]/tools/performance/index.astro @@ -3,6 +3,8 @@ import ToolOpenGraph from '../../../../components/ToolOpenGraph.astro'; import { performanceTool } from '../../../../constants/tools'; import BaseLayout from '../../../../layouts/BaseLayout.astro'; import { Page } from './_index'; + +export { getStaticPaths } from '../../index.astro'; --- diff --git a/packages/website/src/pages/[...locale]/tools/session/index.astro b/packages/website/src/pages/[...locale]/tools/session/index.astro index 322d8abb4..1042965fd 100644 --- a/packages/website/src/pages/[...locale]/tools/session/index.astro +++ b/packages/website/src/pages/[...locale]/tools/session/index.astro @@ -2,6 +2,8 @@ import { sessionTool } from '../../../../constants/tools'; import ToolLayout from '../../../../layouts/ToolLayout.astro'; import { Page } from './_index'; + +export { getStaticPaths } from '../../index.astro'; --- diff --git a/packages/website/src/pages/[...locale]/tools/tankopedia/[id]/index.astro b/packages/website/src/pages/[...locale]/tools/tankopedia/[id]/index.astro index 4f3934cfd..ad70470e6 100644 --- a/packages/website/src/pages/[...locale]/tools/tankopedia/[id]/index.astro +++ b/packages/website/src/pages/[...locale]/tools/tankopedia/[id]/index.astro @@ -15,14 +15,20 @@ import type { GetStaticPaths } from 'astro'; import { tankCharacteristics } from '../../../../../core/blitzkit/tankCharacteristics'; import BaseLayout from '../../../../../layouts/BaseLayout.astro'; import { genericDefaultEquipmentMatrix } from '../../../../../stores/duel/constants'; +import { getStaticPaths as parentGetStaticPaths } from '../index.astro'; import { Page } from './_index'; export const getStaticPaths = (async () => { const tankDefinitions = await fetchTankDefinitions(); + const parentPaths = parentGetStaticPaths(); - return Object.values(tankDefinitions.tanks).map((tank) => ({ - params: { id: tank.id }, - })); + return Object.values(tankDefinitions.tanks) + .map((tank) => + parentPaths.map((parent) => ({ + params: { ...parent.params, id: tank.id }, + })), + ) + .flat(); }) satisfies GetStaticPaths; const { id } = Astro.params; diff --git a/packages/website/src/pages/[...locale]/tools/tankopedia/index.astro b/packages/website/src/pages/[...locale]/tools/tankopedia/index.astro index 6362de006..0efb66a9a 100644 --- a/packages/website/src/pages/[...locale]/tools/tankopedia/index.astro +++ b/packages/website/src/pages/[...locale]/tools/tankopedia/index.astro @@ -2,6 +2,8 @@ import { tankopediaTool } from '../../../../constants/tools'; import ToolLayout from '../../../../layouts/ToolLayout.astro'; import { Page } from './_index'; + +export { getStaticPaths } from '../../index.astro'; --- diff --git a/packages/website/src/pages/[...locale]/tools/tier-list/index.astro b/packages/website/src/pages/[...locale]/tools/tier-list/index.astro index 624d33036..fd889bcc8 100644 --- a/packages/website/src/pages/[...locale]/tools/tier-list/index.astro +++ b/packages/website/src/pages/[...locale]/tools/tier-list/index.astro @@ -2,6 +2,8 @@ import { tierListTool } from '../../../../constants/tools'; import ToolLayout from '../../../../layouts/ToolLayout.astro'; import { Page } from './_index'; + +export { getStaticPaths } from '../../index.astro'; ---