From ec8e97a82f0879faf98b1dcc49003c277ffb923e Mon Sep 17 00:00:00 2001 From: Jorge Vargas Date: Mon, 24 Mar 2025 18:15:53 -0600 Subject: [PATCH] qqwqdqwd --- astro.config.mjs | 2 - .../AlbumLetterSection.astro} | 4 +- .../listPage/GameLetterSection.astro | 23 +++++++ src/layouts/ListLayout.astro | 35 +++++++++++ src/pages/album/list/index.astro | 62 ++++++------------- src/pages/anim/list/index.astro | 32 ++++++++++ src/pages/game/list/index.astro | 32 ++++++++++ 7 files changed, 143 insertions(+), 47 deletions(-) rename src/components/{albumList/letterSection.astro => listPage/AlbumLetterSection.astro} (91%) create mode 100644 src/components/listPage/GameLetterSection.astro create mode 100644 src/layouts/ListLayout.astro create mode 100644 src/pages/anim/list/index.astro create mode 100644 src/pages/game/list/index.astro diff --git a/astro.config.mjs b/astro.config.mjs index 2d35aa0..14e541b 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -49,9 +49,7 @@ export default defineConfig({ adapter: node({ mode: 'standalone' }), redirects: { '/anim/[id]': { status: 307, destination: '/maintenance' }, - '/anim/list': { status: 307, destination: '/maintenance' }, '/game/[slug]': { status: 307, destination: '/maintenance' }, - '/game/list': { status: 307, destination: '/maintenance' }, '/platform/list': { status: 307, destination: '/maintenance' }, '/platform/[id]': { status: 307, destination: '/maintenance' }, '/profile': { status: 307, destination: '/maintenance' }, diff --git a/src/components/albumList/letterSection.astro b/src/components/listPage/AlbumLetterSection.astro similarity index 91% rename from src/components/albumList/letterSection.astro rename to src/components/listPage/AlbumLetterSection.astro index 23c6b49..91e5420 100644 --- a/src/components/albumList/letterSection.astro +++ b/src/components/listPage/AlbumLetterSection.astro @@ -13,7 +13,7 @@ const albums = await prismaClient.albums.findMany({ }) --- -
+ { albums.map((a) => ( @@ -21,4 +21,4 @@ const albums = await prismaClient.albums.findMany({ )) } -
+ diff --git a/src/components/listPage/GameLetterSection.astro b/src/components/listPage/GameLetterSection.astro new file mode 100644 index 0000000..dc81547 --- /dev/null +++ b/src/components/listPage/GameLetterSection.astro @@ -0,0 +1,23 @@ +--- +import prismaClient from 'utils/prisma-client' + +interface Props { + letter: string +} + +const { letter } = Astro.props +const games = await prismaClient.game.findMany({ + where: { name: { startsWith: letter } }, + select: { slug: true, name: true } +}) +--- + + + { + games.map((g) => ( + + {g.name} + + )) + } + diff --git a/src/layouts/ListLayout.astro b/src/layouts/ListLayout.astro new file mode 100644 index 0000000..2d1982e --- /dev/null +++ b/src/layouts/ListLayout.astro @@ -0,0 +1,35 @@ +--- +interface Props { + letters: { letter: string; count: BigInt }[] +} + +import Sidebar from 'components/Sidebar.astro' +import Base from './base.astro' + +const { letters } = Astro.props +--- + + +
+
+
+ { + letters.map((l) => ( + + )) + } +
+
+ +
+
+ +
+ diff --git a/src/pages/album/list/index.astro b/src/pages/album/list/index.astro index 53274cc..f0d366a 100644 --- a/src/pages/album/list/index.astro +++ b/src/pages/album/list/index.astro @@ -1,9 +1,8 @@ --- import prismaClient from 'utils/prisma-client' -import BaseLayout from 'layouts/base.astro' -import Sidebar from 'components/Sidebar.astro' -import LetterSection from 'components/albumList/letterSection.astro' +import ListLayout from 'layouts/ListLayout.astro' +import AlbumLetterSection from 'components/listPage/AlbumLetterSection.astro' const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRaw` SELECT DISTINCT UPPER(LEFT(title, 1)) AS letter, COUNT(*) AS count @@ -14,44 +13,21 @@ const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRa ` --- - -
-
-
- { - letters.map((l) => ( - - )) - } + + { + letters.map((l) => ( +
+
{l.letter}
+
+ + + {Array.from({ length: Number(l.count) }).map(() => ( +
+ ))} + + +
-
- { - letters.map((l) => ( -
-
{l.letter}
-
- - -
- {Array.from({ length: Number(l.count) }).map(() => ( -
- ))} -
- - -
-
- )) - } -
-
- -
- + )) + } +
diff --git a/src/pages/anim/list/index.astro b/src/pages/anim/list/index.astro new file mode 100644 index 0000000..789ce20 --- /dev/null +++ b/src/pages/anim/list/index.astro @@ -0,0 +1,32 @@ +--- +import prismaClient from 'utils/prisma-client' + +import ListLayout from 'layouts/ListLayout.astro' +import GameLetterSection from 'components/listPage/GameLetterSection.astro' + +const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRaw` + SELECT DISTINCT UPPER(LEFT(name, 1)) AS letter, COUNT(*) AS count + FROM game + GROUP BY letter + ORDER BY letter; + ` +--- + + + { + letters.map((l) => ( +
+
{l.letter}
+
+ + + {Array.from({ length: Number(l.count) }).map(() => ( +
+ ))} + + +
+
+ )) + } + diff --git a/src/pages/game/list/index.astro b/src/pages/game/list/index.astro new file mode 100644 index 0000000..789ce20 --- /dev/null +++ b/src/pages/game/list/index.astro @@ -0,0 +1,32 @@ +--- +import prismaClient from 'utils/prisma-client' + +import ListLayout from 'layouts/ListLayout.astro' +import GameLetterSection from 'components/listPage/GameLetterSection.astro' + +const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRaw` + SELECT DISTINCT UPPER(LEFT(name, 1)) AS letter, COUNT(*) AS count + FROM game + GROUP BY letter + ORDER BY letter; + ` +--- + + + { + letters.map((l) => ( +
+
{l.letter}
+
+ + + {Array.from({ length: Number(l.count) }).map(() => ( +
+ ))} + + +
+
+ )) + } +