import Link from 'next/link' import { SongCard } from '@/components/SongCard' import { GenreBadge } from '@/components/GenreBadge' import { SectionHeader } from '@/components/SectionHeader' import { prisma } from '@/lib/prisma' async function getTrendingSongs() { try { const songs = await prisma.song.findMany({ where: { isPublic: true, }, include: { artist: { select: { id: true, name: true, slug: true, avatarUrl: true, verified: true, }, }, album: { select: { id: true, title: true, slug: true, coverUrl: true, }, }, }, orderBy: { playCount: 'desc', }, take: 8, }) return songs } catch (error) { console.error('Error fetching trending songs:', error) return [] } } async function getNewReleases() { try { const songs = await prisma.song.findMany({ where: { isPublic: true, }, include: { artist: { select: { id: true, name: true, slug: true, avatarUrl: true, verified: true, }, }, album: { select: { id: true, title: true, slug: true, coverUrl: true, }, }, }, orderBy: { createdAt: 'desc', }, take: 8, }) return songs } catch (error) { console.error('Error fetching new releases:', error) return [] } } async function getGenres() { try { const genres = await prisma.genre.findMany({ orderBy: { name: 'asc', }, }) return genres } catch (error) { console.error('Error fetching genres:', error) return [] } } export default async function HomePage() { const [trendingSongs, newReleases, genres] = await Promise.all([ getTrendingSongs(), getNewReleases(), getGenres(), ]) return (
{/* Hero Section */}

Discover Music

Explore trending tracks, new releases, and your favorite genres

{/* Trending Section */}
{trendingSongs.map((song: any) => ( ))}
{/* New Releases Section */}
{newReleases.map((song: any) => ( ))}
{/* Genres Section */}
{genres.map((genre: any) => ( ))}
) }