mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Implement Album Count component
This commit is contained in:
parent
c17d1523a9
commit
56c56c9877
7 changed files with 83 additions and 42 deletions
|
|
@ -37,5 +37,8 @@
|
||||||
"lastAddedSidebar": "Last Added",
|
"lastAddedSidebar": "Last Added",
|
||||||
"getLucky": "Get Lucky",
|
"getLucky": "Get Lucky",
|
||||||
"randomPull": "Random Pull",
|
"randomPull": "Random Pull",
|
||||||
"highlightAlbum": "Highlight Soundtrack"
|
"highlightAlbum": "Highlight Soundtrack",
|
||||||
|
"ostCount": "Soundtrack Count",
|
||||||
|
"animOsts": "Animation Soundtracks",
|
||||||
|
"gameOsts": "Game Soundtracks"
|
||||||
}
|
}
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run dev",
|
"start": "npm run dev",
|
||||||
"dev": "astro dev",
|
"dev": "astro dev",
|
||||||
"build": "npm run paraglide:compile && prisma generate && astro build",
|
"build": "npm run paraglide:compile && prisma generate --sql && astro build",
|
||||||
"preview": "astro preview",
|
"preview": "astro preview",
|
||||||
"paraglide:compile": "paraglide-js compile --project ./project.inlang --outdir ./src\\paraglide"
|
"paraglide:compile": "paraglide-js compile --project ./project.inlang --outdir ./src\\paraglide"
|
||||||
},
|
},
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
"@astrojs/rss": "4.0.11",
|
"@astrojs/rss": "4.0.11",
|
||||||
"@astrojs/tailwind": "^6.0.0",
|
"@astrojs/tailwind": "^6.0.0",
|
||||||
"@inlang/paraglide-astro": "^0.2.2",
|
"@inlang/paraglide-astro": "^0.2.2",
|
||||||
"@prisma/client": "^6.2.1",
|
"@prisma/client": "^6.3.1",
|
||||||
"@types/react": "^18.3.12",
|
"@types/react": "^18.3.12",
|
||||||
"@types/react-dom": "^18.3.1",
|
"@types/react-dom": "^18.3.1",
|
||||||
"astro": "5.1.5",
|
"astro": "5.1.5",
|
||||||
|
|
@ -46,6 +46,6 @@
|
||||||
"neostandard": "^0.11.6",
|
"neostandard": "^0.11.6",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"prettier-config-standard": "^7.0.0",
|
"prettier-config-standard": "^7.0.0",
|
||||||
"prisma": "^6.2.1"
|
"prisma": "^6.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client-js"
|
||||||
|
previewFeatures = ["typedSql"]
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
|
|
|
||||||
5
prisma/sql/getAlbumCount.sql
Normal file
5
prisma/sql/getAlbumCount.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
SELECT `categoryName`, COUNT(*) as "count"
|
||||||
|
FROM `Album_Category`, `albums`
|
||||||
|
WHERE `Album_Category`.`albumId` = `albums`.`id`
|
||||||
|
AND `albums`.`status` = "show"
|
||||||
|
GROUP BY `categoryName`;
|
||||||
|
|
@ -10,6 +10,7 @@ import twitter from 'img/socials/twitter.png'
|
||||||
import SidebarSection from './sidebar/SidebarSection.astro'
|
import SidebarSection from './sidebar/SidebarSection.astro'
|
||||||
import Highlight from './sidebar/Highlight.astro'
|
import Highlight from './sidebar/Highlight.astro'
|
||||||
import AlbumBox from './AlbumBox.astro'
|
import AlbumBox from './AlbumBox.astro'
|
||||||
|
import AlbumCount from './sidebar/AlbumCount.astro'
|
||||||
|
|
||||||
const listClass =
|
const listClass =
|
||||||
'uppercase text-3xl font-semibold w-full text-center py-3 hover:bg-dark-hover hover:text-cyan-400 hover:underline'
|
'uppercase text-3xl font-semibold w-full text-center py-3 hover:bg-dark-hover hover:text-cyan-400 hover:underline'
|
||||||
|
|
@ -47,5 +48,8 @@ const listClass =
|
||||||
<AlbumBox loading />
|
<AlbumBox loading />
|
||||||
</SidebarSection>
|
</SidebarSection>
|
||||||
</Highlight>
|
</Highlight>
|
||||||
|
<AlbumCount server:defer>
|
||||||
|
<SidebarSection slot='fallback' class='h-32 animate-pulse' />
|
||||||
|
</AlbumCount>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
28
src/components/sidebar/AlbumCount.astro
Normal file
28
src/components/sidebar/AlbumCount.astro
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
import prismaClient from 'utils/prisma-client'
|
||||||
|
import * as m from 'paraglide/messages.js'
|
||||||
|
|
||||||
|
import SidebarSection from './SidebarSection.astro'
|
||||||
|
|
||||||
|
import { getAlbumCount } from '@prisma/client/sql'
|
||||||
|
|
||||||
|
const albumCount = await prismaClient.albums.count({ where: { status: 'show' } })
|
||||||
|
const categoryRows = await prismaClient.$queryRawTyped(getAlbumCount())
|
||||||
|
|
||||||
|
const categories = categoryRows.reduce(
|
||||||
|
(acc, currentValue) => {
|
||||||
|
// @ts-ignore
|
||||||
|
acc[currentValue.categoryName] = currentValue.count
|
||||||
|
return acc
|
||||||
|
},
|
||||||
|
{ Animation: 0, Game: 0 }
|
||||||
|
)
|
||||||
|
---
|
||||||
|
|
||||||
|
<SidebarSection>
|
||||||
|
<div class='uppercase text-center text-2xl/6 font-semibold'>{m.ostCount()}: {albumCount}</div>
|
||||||
|
<div class='mt-2'>
|
||||||
|
<div class='text-center font-light'>{m.animOsts}: {categories.Animation}</div>
|
||||||
|
<div class='text-center font-light'>{m.gameOsts}: {categories.Game}</div>
|
||||||
|
</div>
|
||||||
|
</SidebarSection>
|
||||||
74
yarn.lock
74
yarn.lock
|
|
@ -1408,46 +1408,46 @@
|
||||||
resolved "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz"
|
resolved "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz"
|
||||||
integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==
|
integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==
|
||||||
|
|
||||||
"@prisma/client@^6.2.1":
|
"@prisma/client@^6.3.1":
|
||||||
version "6.2.1"
|
version "6.3.1"
|
||||||
resolved "https://registry.npmjs.org/@prisma/client/-/client-6.2.1.tgz"
|
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-6.3.1.tgz#4e4b05b27f4541ea541a601c57a8ada10b526848"
|
||||||
integrity sha512-msKY2iRLISN8t5X0Tj7hU0UWet1u0KuxSPHWuf3IRkB4J95mCvGpyQBfQ6ufcmvKNOMQSq90O2iUmJEN2e5fiA==
|
integrity sha512-ARAJaPs+eBkemdky/XU3cvGRl+mIPHCN2lCXsl5Vlb0E2gV+R6IN7aCI8CisRGszEZondwIsW9Iz8EJkTdykyA==
|
||||||
|
|
||||||
"@prisma/debug@6.2.1":
|
"@prisma/debug@6.3.1":
|
||||||
version "6.2.1"
|
version "6.3.1"
|
||||||
resolved "https://registry.npmjs.org/@prisma/debug/-/debug-6.2.1.tgz"
|
resolved "https://registry.yarnpkg.com/@prisma/debug/-/debug-6.3.1.tgz#08730461dab4fe147efa70637952b942dc1961b5"
|
||||||
integrity sha512-0KItvt39CmQxWkEw6oW+RQMD6RZ43SJWgEUnzxN8VC9ixMysa7MzZCZf22LCK5DSooiLNf8vM3LHZm/I/Ni7bQ==
|
integrity sha512-RrEBkd+HLZx+ydfmYT0jUj7wjLiS95wfTOSQ+8FQbvb6vHh5AeKfEPt/XUQ5+Buljj8hltEfOslEW57/wQIVeA==
|
||||||
|
|
||||||
"@prisma/engines-version@6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69":
|
"@prisma/engines-version@6.3.0-17.acc0b9dd43eb689cbd20c9470515d719db10d0b0":
|
||||||
version "6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69"
|
version "6.3.0-17.acc0b9dd43eb689cbd20c9470515d719db10d0b0"
|
||||||
resolved "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69.tgz"
|
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-6.3.0-17.acc0b9dd43eb689cbd20c9470515d719db10d0b0.tgz#a9651d70ed1198dd37780a44da0e9db7c547c7dc"
|
||||||
integrity sha512-7tw1qs/9GWSX6qbZs4He09TOTg1ff3gYsB3ubaVNN0Pp1zLm9NC5C5MZShtkz7TyQjx7blhpknB7HwEhlG+PrQ==
|
integrity sha512-R/ZcMuaWZT2UBmgX3Ko6PAV3f8//ZzsjRIG1eKqp3f2rqEqVtCv+mtzuH2rBPUC9ujJ5kCb9wwpxeyCkLcHVyA==
|
||||||
|
|
||||||
"@prisma/engines@6.2.1":
|
"@prisma/engines@6.3.1":
|
||||||
version "6.2.1"
|
version "6.3.1"
|
||||||
resolved "https://registry.npmjs.org/@prisma/engines/-/engines-6.2.1.tgz"
|
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-6.3.1.tgz#9d4d10bff8af4a56f3545b3a109a1c98d1e1d0d2"
|
||||||
integrity sha512-lTBNLJBCxVT9iP5I7Mn6GlwqAxTpS5qMERrhebkUhtXpGVkBNd/jHnNJBZQW4kGDCKaQg/r2vlJYkzOHnAb7ZQ==
|
integrity sha512-sXdqEVLyGAJ5/iUoG/Ea5AdHMN71m6PzMBWRQnLmhhOejzqAaEr8rUd623ql6OJpED4s/U4vIn4dg1qkF7vGag==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@prisma/debug" "6.2.1"
|
"@prisma/debug" "6.3.1"
|
||||||
"@prisma/engines-version" "6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69"
|
"@prisma/engines-version" "6.3.0-17.acc0b9dd43eb689cbd20c9470515d719db10d0b0"
|
||||||
"@prisma/fetch-engine" "6.2.1"
|
"@prisma/fetch-engine" "6.3.1"
|
||||||
"@prisma/get-platform" "6.2.1"
|
"@prisma/get-platform" "6.3.1"
|
||||||
|
|
||||||
"@prisma/fetch-engine@6.2.1":
|
"@prisma/fetch-engine@6.3.1":
|
||||||
version "6.2.1"
|
version "6.3.1"
|
||||||
resolved "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.2.1.tgz"
|
resolved "https://registry.yarnpkg.com/@prisma/fetch-engine/-/fetch-engine-6.3.1.tgz#104a1b919890ef5d6f69a1705d4f986e039ef206"
|
||||||
integrity sha512-OO7O9d6Mrx2F9i+Gu1LW+DGXXyUFkP7OE5aj9iBfA/2jjDXEJjqa9X0ZmM9NZNo8Uo7ql6zKm6yjDcbAcRrw1A==
|
integrity sha512-HOf/0umOgt+/S2xtZze+FHKoxpVg4YpVxROr6g2YG09VsI3Ipyb+rGvD6QGbCqkq5NTWAAZoOGNL+oy7t+IhaQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@prisma/debug" "6.2.1"
|
"@prisma/debug" "6.3.1"
|
||||||
"@prisma/engines-version" "6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69"
|
"@prisma/engines-version" "6.3.0-17.acc0b9dd43eb689cbd20c9470515d719db10d0b0"
|
||||||
"@prisma/get-platform" "6.2.1"
|
"@prisma/get-platform" "6.3.1"
|
||||||
|
|
||||||
"@prisma/get-platform@6.2.1":
|
"@prisma/get-platform@6.3.1":
|
||||||
version "6.2.1"
|
version "6.3.1"
|
||||||
resolved "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.2.1.tgz"
|
resolved "https://registry.yarnpkg.com/@prisma/get-platform/-/get-platform-6.3.1.tgz#2fbf7c5a59b42a5df488bdc6d683303c08b02d34"
|
||||||
integrity sha512-zp53yvroPl5m5/gXYLz7tGCNG33bhG+JYCm74ohxOq1pPnrL47VQYFfF3RbTZ7TzGWCrR3EtoiYMywUBw7UK6Q==
|
integrity sha512-AYLq6Hk9xG73JdLWJ3Ip9Wg/vlP7xPvftGBalsPzKDOHr/ImhwJ09eS8xC2vNT12DlzGxhfk8BkL0ve2OriNhQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@prisma/debug" "6.2.1"
|
"@prisma/debug" "6.3.1"
|
||||||
|
|
||||||
"@rollup/pluginutils@^5.1.3":
|
"@rollup/pluginutils@^5.1.3":
|
||||||
version "5.1.4"
|
version "5.1.4"
|
||||||
|
|
@ -5752,12 +5752,12 @@ prettier@^3.3.3:
|
||||||
resolved "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz"
|
resolved "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz"
|
||||||
integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==
|
integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==
|
||||||
|
|
||||||
prisma@^6.2.1:
|
prisma@^6.3.1:
|
||||||
version "6.2.1"
|
version "6.3.1"
|
||||||
resolved "https://registry.npmjs.org/prisma/-/prisma-6.2.1.tgz"
|
resolved "https://registry.yarnpkg.com/prisma/-/prisma-6.3.1.tgz#c97f3ad3be6aacd90dde437857ca347abd51559e"
|
||||||
integrity sha512-hhyM0H13pQleQ+br4CkzGizS5I0oInoeTw3JfLw1BRZduBSQxPILlJLwi+46wZzj9Je7ndyQEMGw/n5cN2fknA==
|
integrity sha512-JKCZWvBC3enxk51tY4TWzS4b5iRt4sSU1uHn2I183giZTvonXaQonzVtjLzpOHE7qu9MxY510kAtFGJwryKe3Q==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@prisma/engines" "6.2.1"
|
"@prisma/engines" "6.3.1"
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
fsevents "2.3.3"
|
fsevents "2.3.3"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue