diff --git a/astro.config.mjs b/astro.config.mjs index 5063d8f..12d7e74 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -50,9 +50,7 @@ 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' }, - '/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/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/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/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/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/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/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(() => ( +
+ ))} + + +
+
+ )) + } + 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;