mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Implement /studio/list
This commit is contained in:
parent
8fd7f7dece
commit
3b1cd90895
3 changed files with 56 additions and 1 deletions
|
|
@ -56,7 +56,6 @@ export default defineConfig({
|
|||
'/profile/[username]': { status: 307, destination: '/maintenance' },
|
||||
'/series/[slug]': { status: 307, destination: '/maintenance' },
|
||||
'/studio/[slug]': { status: 307, destination: '/maintenance' },
|
||||
'/studio/list': { status: 307, destination: '/maintenance' },
|
||||
'/request': { status: 307, destination: '/maintenance' }
|
||||
},
|
||||
security: {
|
||||
|
|
|
|||
21
src/components/letterList/StudioList.astro
Normal file
21
src/components/letterList/StudioList.astro
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
import prismaClient from 'utils/prisma-client'
|
||||
|
||||
interface Props {
|
||||
letter: string
|
||||
}
|
||||
|
||||
const { letter } = Astro.props
|
||||
const games = await prismaClient.studio.findMany({
|
||||
where: { name: { startsWith: letter } },
|
||||
select: { slug: true, name: true }
|
||||
})
|
||||
---
|
||||
|
||||
{
|
||||
games.map((a) => (
|
||||
<a class='text-left hover:bg-btn-gray/30 rounded-md p-2' href={`/studio/${a.slug}`}>
|
||||
{a.name}
|
||||
</a>
|
||||
))
|
||||
}
|
||||
35
src/pages/studio/list/index.astro
Normal file
35
src/pages/studio/list/index.astro
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
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'
|
||||
|
||||
const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRaw`
|
||||
SELECT DISTINCT UPPER(LEFT(studio.name, 1)) AS letter, COUNT(*) AS count
|
||||
FROM Studio_Animation, studio, animation
|
||||
WHERE Studio_Animation.animationId = animation.id
|
||||
AND Studio_Animation.studioSlug = studio.slug
|
||||
GROUP BY letter
|
||||
ORDER BY letter;
|
||||
`
|
||||
---
|
||||
|
||||
<LetterList letters={letters}>
|
||||
{
|
||||
letters.map((l) => (
|
||||
<div id={l.letter}>
|
||||
<div class='flex uppercase border-y-2 text-4xl justify-center border-white py-1.5'>{l.letter}</div>
|
||||
<div class='py-4 grid sm:grid-cols-1 md:grid-cols-4 gap-1'>
|
||||
<PublisherList letter={l.letter} server:defer>
|
||||
<Fragment slot='fallback'>
|
||||
{Array.from({ length: Number(l.count) }).map(() => (
|
||||
<div class='animate-pulse h-6 w-full bg-gray/85' />
|
||||
))}
|
||||
</Fragment>
|
||||
</PublisherList>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</LetterList>
|
||||
Loading…
Add table
Add a link
Reference in a new issue