mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Implement /platform/list
This commit is contained in:
parent
7dcd39f106
commit
8fd7f7dece
4 changed files with 58 additions and 2 deletions
|
|
@ -51,7 +51,6 @@ export default defineConfig({
|
|||
'/en/[...params]': '/[...params]',
|
||||
'/anim/[id]': { status: 307, destination: '/maintenance' },
|
||||
'/game/[slug]': { status: 307, destination: '/maintenance' },
|
||||
'/platform/list': { status: 307, destination: '/maintenance' },
|
||||
'/platform/[id]': { status: 307, destination: '/maintenance' },
|
||||
'/profile': { status: 307, destination: '/maintenance' },
|
||||
'/profile/[username]': { status: 307, destination: '/maintenance' },
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ const { session } = Astro.locals
|
|||
<DropdownItem href='/game/list'>{m.gamelist()}</DropdownItem>
|
||||
<DropdownItem href='/series/list'>{m.series()}</DropdownItem>
|
||||
<DropdownItem href='/publisher/list'>{m.publishers()}</DropdownItem>
|
||||
<DropdownItem href='/platforms/list'>{m.platforms()}</DropdownItem>
|
||||
<DropdownItem href='/platform/list'>{m.platforms()}</DropdownItem>
|
||||
</Fragment>
|
||||
</Dropdown>
|
||||
|
||||
|
|
|
|||
21
src/components/letterList/PlatformList.astro
Normal file
21
src/components/letterList/PlatformList.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.platform.findMany({
|
||||
where: { name: { startsWith: letter } },
|
||||
select: { id: true, name: true }
|
||||
})
|
||||
---
|
||||
|
||||
{
|
||||
games.map((a) => (
|
||||
<a class='text-left hover:bg-btn-gray/30 rounded-md p-2' href={`/game/${a.id}`}>
|
||||
{a.name}
|
||||
</a>
|
||||
))
|
||||
}
|
||||
36
src/pages/platform/list/index.astro
Normal file
36
src/pages/platform/list/index.astro
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
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'
|
||||
import PlatformList from 'components/letterList/PlatformList.astro'
|
||||
|
||||
const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRaw`
|
||||
SELECT DISTINCT UPPER(LEFT(platform.name, 1)) AS letter, COUNT(*) AS count
|
||||
FROM Album_Platform, albums, platform
|
||||
WHERE Album_Platform.albumId = albums.id
|
||||
AND Album_Platform.platformId = platform.id
|
||||
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'>
|
||||
<PlatformList 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>
|
||||
</PlatformList>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</LetterList>
|
||||
Loading…
Add table
Add a link
Reference in a new issue