47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { fetchQuery } from "convex/nextjs"
|
|
import { ArtistsView } from "@/components/artists-view"
|
|
import { api } from "@/convex/_generated/api"
|
|
import { Metadata } from "next"
|
|
|
|
interface PageProps {
|
|
params: Promise<{ id: string }>
|
|
}
|
|
|
|
export async function generateMetadata({
|
|
params,
|
|
}: PageProps): Promise<Metadata> {
|
|
const { id } = await params
|
|
const artists = await fetchQuery(api.library.browseArtists)
|
|
const selectedArtist = artists.find((artist) => artist.id === id)
|
|
|
|
return {
|
|
title: `${selectedArtist ? `${selectedArtist.name} - oTunes` : "oTunes"}`,
|
|
openGraph: {
|
|
title: `${selectedArtist ? `${selectedArtist.name} - oTunes` : "oTunes"}`,
|
|
description: "oTunes",
|
|
images: selectedArtist
|
|
? {
|
|
url: `/api/artist/${selectedArtist.id}/cover`,
|
|
width: 512,
|
|
height: 512,
|
|
}
|
|
: [],
|
|
},
|
|
}
|
|
}
|
|
|
|
export default async function Page({ params }: PageProps) {
|
|
const { id } = await params
|
|
const artists = await fetchQuery(api.library.browseArtists)
|
|
const albums = await fetchQuery(api.library.browseAlbums)
|
|
|
|
return (
|
|
<div className="flex h-svh flex-col">
|
|
<header className="flex items-center gap-2 border-b px-4 py-3">
|
|
<h1 className="text-lg font-semibold">Artists</h1>
|
|
</header>
|
|
<ArtistsView artists={artists} albums={albums} artistId={id} />
|
|
</div>
|
|
)
|
|
}
|