diff --git a/astro.config.mjs b/astro.config.mjs index 966c2b1..f9f5b3d 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -51,7 +51,6 @@ export default defineConfig({ '/en/[...params]': '/[...params]', '/anim/[id]': { status: 307, destination: '/maintenance' }, '/game/[slug]': { status: 307, destination: '/maintenance' }, - '/platform/list': { status: 307, destination: '/maintenance' }, '/platform/[id]': { status: 307, destination: '/maintenance' }, '/profile': { status: 307, destination: '/maintenance' }, '/profile/[username]': { status: 307, destination: '/maintenance' }, diff --git a/src/components/Header.astro b/src/components/Header.astro index ef148ec..2e4d5c5 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -62,7 +62,7 @@ const { session } = Astro.locals {m.gamelist()} {m.series()} {m.publishers()} - {m.platforms()} + {m.platforms()} diff --git a/src/components/letterList/PlatformList.astro b/src/components/letterList/PlatformList.astro new file mode 100644 index 0000000..ff89a2b --- /dev/null +++ b/src/components/letterList/PlatformList.astro @@ -0,0 +1,21 @@ +--- +import prismaClient from 'utils/prisma-client' + +interface Props { + letter: string +} + +const { letter } = Astro.props +const games = await prismaClient.platform.findMany({ + where: { name: { startsWith: letter } }, + select: { id: true, name: true } +}) +--- + +{ + games.map((a) => ( + + {a.name} + + )) +} diff --git a/src/pages/platform/list/index.astro b/src/pages/platform/list/index.astro new file mode 100644 index 0000000..6a5f297 --- /dev/null +++ b/src/pages/platform/list/index.astro @@ -0,0 +1,36 @@ +--- +import prismaClient from 'utils/prisma-client' + +import LetterList from 'layouts/LetterList.astro' +import GameList from 'components/letterList/GameList.astro' +import PublisherList from 'components/letterList/PublisherList.astro' +import PlatformList from 'components/letterList/PlatformList.astro' + +const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRaw` + SELECT DISTINCT UPPER(LEFT(platform.name, 1)) AS letter, COUNT(*) AS count + FROM Album_Platform, albums, platform + WHERE Album_Platform.albumId = albums.id + AND Album_Platform.platformId = platform.id + GROUP BY letter + ORDER BY letter; +` +--- + + + { + letters.map((l) => ( +
+
{l.letter}
+
+ + + {Array.from({ length: Number(l.count) }).map(() => ( +
+ ))} + + +
+
+ )) + } +