From c17d1523a97831742276a21833b5c0d4b43e00e0 Mon Sep 17 00:00:00 2001 From: Jorge Vargas Date: Sun, 16 Feb 2025 12:06:48 -0600 Subject: [PATCH] Reestructure Highlight component --- src/components/Sidebar.astro | 10 +++++-- src/components/sidebar/Highlight.astro | 30 +++++++++++++++---- .../sidebar/highlight/content.astro | 28 ----------------- .../sidebar/highlight/loading.astro | 11 ------- 4 files changed, 33 insertions(+), 46 deletions(-) delete mode 100644 src/components/sidebar/highlight/content.astro delete mode 100644 src/components/sidebar/highlight/loading.astro diff --git a/src/components/Sidebar.astro b/src/components/Sidebar.astro index b287ce0..355e90e 100644 --- a/src/components/Sidebar.astro +++ b/src/components/Sidebar.astro @@ -6,9 +6,10 @@ import discord from 'img/socials/discord.png' import kofi from 'img/socials/ko-fi-donate-button.png' import yt from 'img/socials/yt.png' 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 AlbumBox from './AlbumBox.astro' const listClass = 'uppercase text-3xl font-semibold w-full text-center py-3 hover:bg-dark-hover hover:text-cyan-400 hover:underline' @@ -40,6 +41,11 @@ const listClass = - + + +
{m.highlightAlbum()}
+ +
+
diff --git a/src/components/sidebar/Highlight.astro b/src/components/sidebar/Highlight.astro index 4259b0b..750aab1 100644 --- a/src/components/sidebar/Highlight.astro +++ b/src/components/sidebar/Highlight.astro @@ -1,8 +1,28 @@ --- -import Content from './highlight/content.astro' -import Loading from './highlight/loading.astro' +import prismaClient from 'utils/prisma-client' +import * as m from 'paraglide/messages.js' + +import AlbumBox from 'components/AlbumBox.astro' +import SidebarSection from './SidebarSection.astro' + +const highlightConfig = await prismaClient.config.findUnique({ + where: { name: 'highlight' }, + select: { value: true } +}) + +const album = highlightConfig?.value + ? await prismaClient.albums.findUnique({ + where: { id: parseInt(highlightConfig.value) }, + select: { title: true, id: true } + }) + : null --- - - - +{ + album ? ( + +
{m.highlightAlbum()}
+ +
+ ) : null +} diff --git a/src/components/sidebar/highlight/content.astro b/src/components/sidebar/highlight/content.astro deleted file mode 100644 index 82779b9..0000000 --- a/src/components/sidebar/highlight/content.astro +++ /dev/null @@ -1,28 +0,0 @@ ---- -import prismaClient from 'utils/prisma-client' -import * as m from 'paraglide/messages.js' - -import AlbumBox from 'components/AlbumBox.astro' -import SidebarSection from '../SidebarSection.astro' - -const highlightConfig = await prismaClient.config.findUnique({ - where: { name: 'highlight' }, - select: { value: true } -}) - -const album = highlightConfig?.value - ? await prismaClient.albums.findUnique({ - where: { id: parseInt(highlightConfig.value) }, - select: { title: true, id: true } - }) - : null ---- - -{ - album ? ( - -
{m.highlightAlbum()}
- -
- ) : null -} diff --git a/src/components/sidebar/highlight/loading.astro b/src/components/sidebar/highlight/loading.astro deleted file mode 100644 index ba24a00..0000000 --- a/src/components/sidebar/highlight/loading.astro +++ /dev/null @@ -1,11 +0,0 @@ ---- -import * as m from 'paraglide/messages.js' - -import AlbumBox from 'components/AlbumBox.astro' -import SidebarSection from '../SidebarSection.astro' ---- - - -
{m.highlightAlbum()}
- -