From c80cc79d16773dfbceb196ab6d5c428956658803 Mon Sep 17 00:00:00 2001 From: Jorge Vargas Date: Sat, 26 Apr 2025 22:38:10 -0600 Subject: [PATCH 1/2] Implement /game/list --- astro.config.mjs | 1 - .../AlbumList.astro} | 16 ++-- src/components/letterList/GameList.astro | 21 +++++ src/layouts/LetterList.astro | 37 +++++++++ src/pages/album/list/index.astro | 76 ++++++------------- src/pages/game/list/index.astro | 35 +++++++++ 6 files changed, 125 insertions(+), 61 deletions(-) rename src/components/{albumList/letterSection.astro => letterList/AlbumList.astro} (67%) create mode 100644 src/components/letterList/GameList.astro create mode 100644 src/layouts/LetterList.astro create mode 100644 src/pages/game/list/index.astro diff --git a/astro.config.mjs b/astro.config.mjs index 5063d8f..ae87b2a 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -52,7 +52,6 @@ export default defineConfig({ '/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/letterList/AlbumList.astro similarity index 67% rename from src/components/albumList/letterSection.astro rename to src/components/letterList/AlbumList.astro index 23c6b49..fe5dc90 100644 --- a/src/components/albumList/letterSection.astro +++ b/src/components/letterList/AlbumList.astro @@ -13,12 +13,10 @@ const albums = await prismaClient.albums.findMany({ }) --- -
- { - albums.map((a) => ( - - {a.title} - - )) - } -
+{ + albums.map((a) => ( + + {a.title} + + )) +} diff --git a/src/components/letterList/GameList.astro b/src/components/letterList/GameList.astro new file mode 100644 index 0000000..34bd1fe --- /dev/null +++ b/src/components/letterList/GameList.astro @@ -0,0 +1,21 @@ +--- +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((a) => ( + + {a.name} + + )) +} diff --git a/src/layouts/LetterList.astro b/src/layouts/LetterList.astro new file mode 100644 index 0000000..da29477 --- /dev/null +++ b/src/layouts/LetterList.astro @@ -0,0 +1,37 @@ +--- +interface Props { + letters: { letter: string; count: BigInt }[] +} + +import BaseLayout from 'layouts/base.astro' +import Sidebar from 'components/Sidebar.astro' +import DefaultSEO from 'components/DefaultSEO.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 eeecc0c..6f42914 100644 --- a/src/pages/album/list/index.astro +++ b/src/pages/album/list/index.astro @@ -1,59 +1,33 @@ --- 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 DefaultSEO from 'components/DefaultSEO.astro' +import LetterList from 'layouts/LetterList.astro' +import AlbumList from 'components/letterList/AlbumList.astro' const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRaw` - SELECT DISTINCT UPPER(LEFT(title, 1)) AS letter, COUNT(*) AS count - FROM albums - WHERE status = 'SHOW' - GROUP BY letter - ORDER BY letter; - ` + SELECT DISTINCT UPPER(LEFT(title, 1)) AS letter, COUNT(*) AS count + FROM albums + WHERE status = 'SHOW' + GROUP BY letter + ORDER BY letter; +` --- - - -
-
-
- { - 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/game/list/index.astro b/src/pages/game/list/index.astro new file mode 100644 index 0000000..5f344e5 --- /dev/null +++ b/src/pages/game/list/index.astro @@ -0,0 +1,35 @@ +--- +import prismaClient from 'utils/prisma-client' + +import LetterList from 'layouts/LetterList.astro' +import GameList from 'components/letterList/GameList.astro' + +const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRaw` + SELECT DISTINCT UPPER(LEFT(name, 1)) AS letter, COUNT(*) AS count + FROM Album_Game, albums, game + WHERE Album_Game.albumId = albums.id + AND Album_Game.gameSlug = game.slug + AND albums.status = "Show" + GROUP BY letter + ORDER BY letter; +` +--- + + + { + letters.map((l) => ( +
+
{l.letter}
+
+ + + {Array.from({ length: Number(l.count) }).map(() => ( +
+ ))} + + +
+
+ )) + } + From 88408eab330f19d30c9ea95b3a5b3ffde6a18e54 Mon Sep 17 00:00:00 2001 From: Jorge Vargas Date: Sat, 26 Apr 2025 23:04:26 -0600 Subject: [PATCH 2/2] Implement /anim/list --- astro.config.mjs | 1 - src/components/AlbumBox.astro | 16 +++++++---- src/components/letterList/AnimList.astro | 20 ++++++++++++++ src/pages/anim/list/index.astro | 35 ++++++++++++++++++++++++ src/styles/global.css | 1 + 5 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 src/components/letterList/AnimList.astro create mode 100644 src/pages/anim/list/index.astro diff --git a/astro.config.mjs b/astro.config.mjs index ae87b2a..12d7e74 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -50,7 +50,6 @@ export default defineConfig({ redirects: { '/en/[...params]': '/[...params]', '/anim/[id]': { status: 307, destination: '/maintenance' }, - '/anim/list': { status: 307, destination: '/maintenance' }, '/game/[slug]': { status: 307, destination: '/maintenance' }, '/platform/list': { status: 307, destination: '/maintenance' }, '/platform/[id]': { status: 307, destination: '/maintenance' }, diff --git a/src/components/AlbumBox.astro b/src/components/AlbumBox.astro index dd9c565..4e5d440 100644 --- a/src/components/AlbumBox.astro +++ b/src/components/AlbumBox.astro @@ -2,16 +2,20 @@ import { Image } from 'astro:assets' type Props = - | { title?: string | null; href: string; image: string; loading?: false } - | { title?: string; href?: string; image?: string; loading: true } + | { title?: string | null; href: string; image: string; loading?: false; class?: string } + | { title?: string; href?: string; image?: string; loading: true; class?: string } const { props } = Astro -const { title, href, image, loading = false } = props +const { title, href, image, loading = false, class: className } = props --- { loading ? ( @@ -39,7 +43,9 @@ const { title, href, image, loading = false } = props
) : ( - + ) } diff --git a/src/components/letterList/AnimList.astro b/src/components/letterList/AnimList.astro new file mode 100644 index 0000000..81435a9 --- /dev/null +++ b/src/components/letterList/AnimList.astro @@ -0,0 +1,20 @@ +--- +import AlbumBox from 'components/AlbumBox.astro' +import prismaClient from 'utils/prisma-client' + +interface Props { + letter: string +} + +const { letter } = Astro.props +const anims = await prismaClient.animation.findMany({ + where: { title: { startsWith: letter } }, + select: { id: true, title: true } +}) +--- + +{ + anims.map((a) => ( + + )) +} diff --git a/src/pages/anim/list/index.astro b/src/pages/anim/list/index.astro new file mode 100644 index 0000000..2fe4333 --- /dev/null +++ b/src/pages/anim/list/index.astro @@ -0,0 +1,35 @@ +--- +import prismaClient from 'utils/prisma-client' + +import LetterList from 'layouts/LetterList.astro' +import AnimList from 'components/letterList/AnimList.astro' + +const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRaw` + SELECT DISTINCT UPPER(LEFT(animation.title, 1)) AS letter, COUNT(*) AS count + FROM Album_Animation, albums, animation + WHERE Album_Animation.albumId = albums.id + AND Album_Animation.animationId = animation.id + AND albums.status = "Show" + GROUP BY letter + ORDER BY letter; +` +--- + + + { + letters.map((l) => ( +
+
{l.letter}
+
+ + + {Array.from({ length: Number(l.count) }).map(() => ( +
+ ))} + + +
+
+ )) + } + diff --git a/src/styles/global.css b/src/styles/global.css index f625126..f6f516f 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -7,6 +7,7 @@ --color-dark: #212529; --color-dark-hover: #2b3035; --color-gold: #ffdb37; + --color-btn-dark: #121212; --color-btn-gray: #6c757d; --color-btn-disabled: rgba(108, 117, 125, 0.65); --color-gray: #3f3f3f;