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;