From df0201be2812779362c5a691e39842bc3d5517b1 Mon Sep 17 00:00:00 2001 From: m4x809 Date: Sat, 25 Oct 2025 20:58:22 +0200 Subject: [PATCH] Refactor AlbumCard and AlbumDetail components to use next/image for optimized image handling - Replaced direct imports of Image from Mantine with next/image for better performance. - Updated image properties in AlbumCard and AlbumDetail to include width and height attributes. - Adjusted layout in HomePage to use responsive column settings for SimpleGrid. - Enhanced styling for disclaimer text in HomePage for improved readability. --- src/Components/AlbumCard.tsx | 6 ++++-- src/app/album/[albumId]/page.tsx | 13 +++++-------- src/app/api/favico/route.tsx | 6 ------ src/app/page.tsx | 4 ++-- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/Components/AlbumCard.tsx b/src/Components/AlbumCard.tsx index 5e9a5cc..10df3f1 100644 --- a/src/Components/AlbumCard.tsx +++ b/src/Components/AlbumCard.tsx @@ -2,9 +2,10 @@ import { getThemeColors } from "@/lib/themes"; import type { Album } from "../lib/ListTypes"; -import { Box, Card, Image, Text, Badge, Group } from "@mantine/core"; +import { Box, Card, Text, Badge, Group } from "@mantine/core"; import { Link } from "next-view-transitions"; import { useState } from "react"; +import Image from "next/image"; export default function AlbumCard({ album }: { album: Album }) { const { label, releaseDate, image, tracks } = album; @@ -62,7 +63,8 @@ export default function AlbumCard({ album }: { album: Album }) { {label} diff --git a/src/app/album/[albumId]/page.tsx b/src/app/album/[albumId]/page.tsx index fd1892d..35bbd55 100644 --- a/src/app/album/[albumId]/page.tsx +++ b/src/app/album/[albumId]/page.tsx @@ -1,10 +1,10 @@ import { notFound } from "next/navigation"; -import { Box, Container, Title, Text, Image, Stack, Grid, GridCol } from "@mantine/core"; +import { Box, Container, Title, Text, Stack, Grid, GridCol } from "@mantine/core"; import { albums } from "../../../lib/list"; import BackButton from "../../../Components/BackButton"; import { getThemeColors } from "@/lib/themes"; import TrackCard from "@/Components/TrackCard"; - +import Image from "next/image"; export function generateStaticParams() { return albums.map((album) => ({ albumId: album.id, @@ -64,12 +64,9 @@ export default async function AlbumDetail({ params }: { params: Promise<{ albumI {album.label} diff --git a/src/app/api/favico/route.tsx b/src/app/api/favico/route.tsx index 4e7b7a7..627cc75 100644 --- a/src/app/api/favico/route.tsx +++ b/src/app/api/favico/route.tsx @@ -5,14 +5,11 @@ import { cookies } from "next/headers"; // Absolute URL redirect is required by Next.js middleware & API routes export async function GET(request: NextRequest) { const urlENV = process.env.URL; - console.log("🚀 ~ route.tsx:9 ~ GET ~ urlENV:", urlENV); const url = new URL(request.url); - console.log("🚀 ~ route.tsx:8 ~ GET ~ url:", url); const randParam = url.searchParams.get("rand"); const cookieStore = await cookies(); const lastImage = cookieStore.get("lastImage")?.value; - console.log("🚀 ~ route.tsx:12 ~ GET ~ lastImage:", lastImage); // Get all available albums, excluding the previous image const availableAlbums = lastImage ? albums.filter((album) => album.image !== lastImage) : albums; @@ -25,16 +22,13 @@ export async function GET(request: NextRequest) { randomIndex = Math.floor(Math.random() * availableAlbums.length); } const album = availableAlbums[randomIndex]; - console.log("🚀 ~ route.tsx:25 ~ GET ~ album:", album); cookieStore.set("lastImage", album.image); // Ensure image path starts with a slash const imagePath = album.image.startsWith("/") ? album.image : `/${album.image}`; - console.log("🚀 ~ route.tsx:29 ~ GET ~ imagePath:", imagePath); // Build absolute URL for the redirect const { nextUrl } = request; const absoluteUrl = urlENV ? `${urlENV}${imagePath}` : `${nextUrl.protocol}//${nextUrl.host}${imagePath}`; - console.log("🚀 ~ route.tsx:33 ~ GET ~ absoluteUrl:", absoluteUrl); return NextResponse.redirect(absoluteUrl, 307); } diff --git a/src/app/page.tsx b/src/app/page.tsx index d000ce9..26ea519 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -20,7 +20,7 @@ export default function HomePage() { - + {albums.map((album) => ( ))} @@ -29,7 +29,7 @@ export default function HomePage() {
- + Disclaimer: This website is not affiliated with Linkin Park or any of its members.
All rights reserved to the respective owners. This website is a fan-made project and is not intended to be used for commercial purposes.