diff --git a/astro.config.mjs b/astro.config.mjs index c336deb..97d55b2 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -49,11 +49,8 @@ export default defineConfig({ adapter: node({ mode: 'standalone' }), redirects: { '/en/[...params]': '/[...params]', - '/platform/[id]': { status: 307, destination: '/maintenance' }, '/profile': { status: 307, destination: '/maintenance' }, '/profile/[username]': { status: 307, destination: '/maintenance' }, - '/series/[slug]': { status: 307, destination: '/maintenance' }, - '/studio/[slug]': { status: 307, destination: '/maintenance' }, '/request': { status: 307, destination: '/maintenance' } }, security: { diff --git a/messages/en.json b/messages/en.json index 336f621..38d19b1 100644 --- a/messages/en.json +++ b/messages/en.json @@ -84,5 +84,8 @@ "holy12_5": "Silksong is hidden behind one of these", "latestGameReleases": "Latest game releases", "latestAnimReleases": " Latest animation releases", - "latestReleases": "Latest releases" + "latestReleases": "Latest releases", + "firstRelease": "First Release", + "newestRelease": "Newest Release", + "variousGames": "Various Games" } diff --git a/src/components/AlbumBox.astro b/src/components/AlbumBox.astro index 4e5d440..0b56c11 100644 --- a/src/components/AlbumBox.astro +++ b/src/components/AlbumBox.astro @@ -12,8 +12,8 @@ const { title, href, image, loading = false, class: className } = props diff --git a/src/components/ReleaseDate.astro b/src/components/ReleaseDate.astro new file mode 100644 index 0000000..b6fbcb3 --- /dev/null +++ b/src/components/ReleaseDate.astro @@ -0,0 +1,9 @@ +--- +interface Props { + date: Date +} +const { props, currentLocale: locale } = Astro +const { date } = props +--- + +{new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(date)} diff --git a/src/components/letterList/PlatformGameList.astro b/src/components/letterList/PlatformGameList.astro new file mode 100644 index 0000000..593a433 --- /dev/null +++ b/src/components/letterList/PlatformGameList.astro @@ -0,0 +1,23 @@ +--- +import { AlbumStatus } from '@prisma/client' +import prismaClient from 'utils/prisma-client' + +interface Props { + letter: string + platformId: number +} + +const { letter, platformId } = Astro.props +const albums = await prismaClient.game.findMany({ + where: { name: { startsWith: letter }, platforms: { some: { platformId } } }, + select: { slug: true, name: true } +}) +--- + +{ + albums.map((a) => ( + + {a.name} + + )) +} diff --git a/src/components/search/AlbumSearch.astro b/src/components/search/AlbumSearch.astro index 291533a..c2dc899 100644 --- a/src/components/search/AlbumSearch.astro +++ b/src/components/search/AlbumSearch.astro @@ -44,7 +44,10 @@ const [count, search] = await Promise.all([
Albums ({count}) { count > take ? ( - / Showing {page === 1 ? `first ${take}` : `${(page - 1) * take}-${Math.min(page * take, count)}`} results + + {' '} + / Showing {page === 1 ? `first ${take}` : `${(page - 1) * take}-${Math.min(page * take, count)}`} results + ) : null }
@@ -56,7 +59,7 @@ const [count, search] = await Promise.all([ } -
+
{ search.map((album) => ( diff --git a/src/pages/album/[id].astro b/src/pages/album/[id].astro index 687f974..4f335b8 100644 --- a/src/pages/album/[id].astro +++ b/src/pages/album/[id].astro @@ -9,13 +9,13 @@ import BaseLayout from 'layouts/base.astro' import TrackList from 'components/albumPage/TrackList' import DownloadBtn from 'components/albumPage/DownloadBtn.astro' import AlbumBox from 'components/AlbumBox.astro' -import releaseDate from 'utils/releaseDate' import kofi from 'img/socials/ko-fi-donate-button.png' import discord from 'img/socials/discord.png' import vgmdbLogo from 'img/assets/vgmdb-logo.png' import flyIcon from 'img/assets/fly-icon.png' import ouoIcon from 'img/assets/ouo-icon.png' +import ReleaseDate from 'components/ReleaseDate.astro' const { id } = Astro.params const { permissions } = Astro.locals @@ -131,7 +131,7 @@ const coverImage = await getImage({ {m.releaseDate()} - {releaseDate(album?.releaseDate)} + ) : null diff --git a/src/pages/anim/[id].astro b/src/pages/anim/[id].astro index 1182a8c..afa82bf 100644 --- a/src/pages/anim/[id].astro +++ b/src/pages/anim/[id].astro @@ -7,7 +7,7 @@ import { Image } from 'astro:assets' import BaseLayout from 'layouts/base.astro' import AlbumBox from 'components/AlbumBox.astro' -import releaseDate from 'utils/releaseDate' +import ReleaseDate from 'components/ReleaseDate.astro' const { id } = Astro.params @@ -87,7 +87,9 @@ const { currentLocale } = Astro anim.releaseDate ? (
{m.releaseDate()}
-
{releaseDate(anim.releaseDate)}
+
+ +
) : null } diff --git a/src/pages/anim/list/index.astro b/src/pages/anim/list/index.astro index 2fe4333..b217185 100644 --- a/src/pages/anim/list/index.astro +++ b/src/pages/anim/list/index.astro @@ -20,7 +20,7 @@ const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRa letters.map((l) => (
{l.letter}
-
+
{Array.from({ length: Number(l.count) }).map(() => ( diff --git a/src/pages/game/[slug].astro b/src/pages/game/[slug].astro index 09ae69e..2a1fa69 100644 --- a/src/pages/game/[slug].astro +++ b/src/pages/game/[slug].astro @@ -7,7 +7,7 @@ import { SEO } from 'astro-seo' import BaseLayout from 'layouts/base.astro' import AlbumBox from 'components/AlbumBox.astro' -import releaseDate from 'utils/releaseDate' +import ReleaseDate from 'components/ReleaseDate.astro' const { slug } = Astro.params if (!slug) return Astro.redirect('/404') @@ -62,29 +62,31 @@ const coverImage = await getImage({
-
+
-
- + />
{game.name}
- +
{ game.releaseDate ? ( - + ) : null } @@ -134,7 +136,7 @@ const coverImage = await getImage({
-
+
{ game.albums.map((a) => ( diff --git a/src/pages/game/list/index.astro b/src/pages/game/list/index.astro index 5f344e5..49ac9ed 100644 --- a/src/pages/game/list/index.astro +++ b/src/pages/game/list/index.astro @@ -20,7 +20,7 @@ const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRa letters.map((l) => (
{l.letter}
-
+
{Array.from({ length: Number(l.count) }).map(() => ( diff --git a/src/pages/platform/[id].astro b/src/pages/platform/[id].astro new file mode 100644 index 0000000..e7ccdf7 --- /dev/null +++ b/src/pages/platform/[id].astro @@ -0,0 +1,45 @@ +--- +import prismaClient from 'utils/prisma-client' + +import LetterList from 'layouts/LetterList.astro' +import PlatformGameList from 'components/letterList/PlatformGameList.astro' +import { AlbumStatus } from '@prisma/client' + +const { id } = Astro.params + +if (!id) return Astro.redirect('/404') +const platformId = parseInt(id) +if (!platformId) return Astro.redirect('/404') + +const platform = await prismaClient.platform.findUnique({ where: { id: platformId }, select: { name: true } }) +if (!platform) return Astro.redirect('/404') + +const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRaw` + SELECT DISTINCT UPPER(LEFT(game.name, 1)) AS letter, COUNT(*) AS count + FROM game, platform, Game_Platform + WHERE game.slug = Game_Platform.gameSlug + AND platform.id = Game_Platform.platformId + AND platform.id = ${platformId} + GROUP BY letter + ORDER BY letter; +` +--- + + + { + letters.map((l) => ( +
+
{l.letter}
+
+ + + {Array.from({ length: Number(l.count) }).map(() => ( +
+ ))} + + +
+
+ )) + } + diff --git a/src/pages/platform/list/index.astro b/src/pages/platform/list/index.astro index 6a5f297..a3f879d 100644 --- a/src/pages/platform/list/index.astro +++ b/src/pages/platform/list/index.astro @@ -21,7 +21,7 @@ const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRa letters.map((l) => (
{l.letter}
-
+
{Array.from({ length: Number(l.count) }).map(() => ( diff --git a/src/pages/publisher/list/index.astro b/src/pages/publisher/list/index.astro index f02c82c..b48887a 100644 --- a/src/pages/publisher/list/index.astro +++ b/src/pages/publisher/list/index.astro @@ -20,7 +20,7 @@ const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRa letters.map((l) => (
{l.letter}
-
+
{Array.from({ length: Number(l.count) }).map(() => ( diff --git a/src/pages/series/[slug].astro b/src/pages/series/[slug].astro new file mode 100644 index 0000000..7d2b459 --- /dev/null +++ b/src/pages/series/[slug].astro @@ -0,0 +1,188 @@ +--- +import prismaClient from 'utils/prisma-client' +import * as m from 'paraglide/messages' +import { getImage, Image } from 'astro:assets' +import { SEO } from 'astro-seo' + +import BaseLayout from 'layouts/base.astro' +import AlbumBox from 'components/AlbumBox.astro' +import ReleaseDate from 'components/ReleaseDate.astro' + +const { slug } = Astro.params +if (!slug) return Astro.redirect('/404') + +const series = await prismaClient.series.findUnique({ + where: { slug }, + select: { + name: true, + headerColor: true, + games: { + select: { + game: { + select: { + slug: true, + releaseDate: true, + name: true, + albums: { + select: { + album: { select: { id: true, title: true, games: { select: { gameSlug: true, game: true } } } } + } + } + } + } + }, + orderBy: { game: { releaseDate: 'asc' } } + } + } +}) + +if (!series) return Astro.redirect('/404') + +const variousAlbums: { id: number; title: string | null }[] = [] +const singleAlbumsObj: { + [key: string]: { + albums: { id: number; title: string | null }[] + game: { + slug: string + name: string | null + createdAt: Date + updatedAt: Date + placeholder: string | null + headerColor: string | null + releaseDate: Date | null + } + } +} = {} +const checkedAlbums = new Set() + +series.games.forEach((g) => { + g.game.albums.forEach(({ album }) => { + if (checkedAlbums.has(album.id)) return + else checkedAlbums.add(album.id) + + if (album.games.length > 1) { + variousAlbums.push(album) + } else { + const game = album.games[0] + if (!singleAlbumsObj[game.gameSlug]) { + singleAlbumsObj[game.gameSlug] = { albums: [], game: game.game } + } + singleAlbumsObj[game.gameSlug].albums.push(album) + } + }) +}) + +const singleAlbums = Object.values(singleAlbumsObj).sort((a, b) => { + if (!a.game.releaseDate || !b.game.releaseDate) return 0 + return b.game.releaseDate.getTime() - a.game.releaseDate.getTime() +}) +const firstGame = series.games[0]?.game +const lastGame = series.games[series.games.length - 1]?.game +const coverImage = await getImage({ + src: `https://cdn.sittingonclouds.net/game/${slug}.png`, + height: 150, + width: 150 +}) +--- + + + + +
+
+
+
+ +
+
+
+
+
{series.name}
+
{m.releaseDate()}:{releaseDate(game.releaseDate)} + +
+ + { + firstGame.releaseDate ? ( + + + + + ) : null + } + { + lastGame.releaseDate ? ( + + + + + ) : null + } + +
{m.firstRelease()}: + -{' '} + {firstGame.name} +
{m.newestRelease()}: + + - + {lastGame.name} +
+
+
+
+
+
+
+
{m.variousGames()}
+
+ { + variousAlbums.map((album) => ( + + )) + } +
+
+
+ { + singleAlbums.map((s) => ( +
+
+ {s.game.releaseDate?.getFullYear()} + {s.game.name} +
+
+ {s.albums.map((album) => ( + + ))} +
+
+ )) + } +
+
+
+ diff --git a/src/pages/studio/[slug].astro b/src/pages/studio/[slug].astro new file mode 100644 index 0000000..00484e9 --- /dev/null +++ b/src/pages/studio/[slug].astro @@ -0,0 +1,58 @@ +--- +import prismaClient from 'utils/prisma-client' + +import DefaultSEO from 'components/DefaultSEO.astro' +import BaseLayout from 'layouts/base.astro' +import Sidebar from 'components/Sidebar.astro' +import AlbumBox from 'components/AlbumBox.astro' + +const { slug } = Astro.params +if (!slug) return Astro.redirect('/404') + +const studio = await prismaClient.studio.findUnique({ + where: { slug }, + select: { + name: true, + animations: { + select: { + animation: { + select: { + albums: { + select: { albumId: true, album: { select: { title: true, publishedAt: true } } } + } + } + } + } + } + } +}) + +if (!studio) return Astro.redirect('/404') + +const albumsMap = new Map() +studio.animations.forEach((a) => { + a.animation.albums.forEach(({ albumId, album }) => { + albumsMap.set(albumId, album) + }) +}) + +const albums = Array.from(albumsMap.entries()) + .map(([id, data]) => ({ id, ...data })) + .sort((a, b) => a.publishedAt.getTime() - b.publishedAt.getTime()) + .reverse() +--- + + + +
+
+
+ {studio.name} +
+
+ {albums.map((a) => )} +
+
+ +
+
diff --git a/src/pages/studio/list/index.astro b/src/pages/studio/list/index.astro index 8cb35d4..6fec597 100644 --- a/src/pages/studio/list/index.astro +++ b/src/pages/studio/list/index.astro @@ -20,7 +20,7 @@ const letters: { letter: string; count: BigInt }[] = await prismaClient.$queryRa letters.map((l) => (
{l.letter}
-
+
{Array.from({ length: Number(l.count) }).map(() => ( diff --git a/src/utils/releaseDate.ts b/src/utils/releaseDate.ts deleted file mode 100644 index e134eb6..0000000 --- a/src/utils/releaseDate.ts +++ /dev/null @@ -1,6 +0,0 @@ -const locale = - navigator && navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.language - -const releaseDate = (date: Date) => new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(date) - -export default releaseDate