78 lines
2.0 KiB
TypeScript
78 lines
2.0 KiB
TypeScript
import { fetchQuery } from "convex/nextjs"
|
|
import { ArtistView } from "@/components/artist-view"
|
|
import { LibraryLoading } from "@/components/library-loading"
|
|
import { api } from "@/convex/_generated/api"
|
|
import type { Id } from "@/convex/_generated/dataModel"
|
|
import { Metadata } from "next"
|
|
|
|
interface PageProps {
|
|
params: Promise<{ id: string }>
|
|
}
|
|
|
|
export async function generateMetadata({
|
|
params,
|
|
}: PageProps): Promise<Metadata> {
|
|
const { id } = await params
|
|
const data = await fetchQuery(api.library.browseArtistDetail, {
|
|
id: id as Id<"artists">,
|
|
})
|
|
|
|
return {
|
|
title: `${data ? `${data.artist.name} - oTunes` : "oTunes"}`,
|
|
openGraph: {
|
|
title: `${data ? `${data.artist.name} - oTunes` : "oTunes"}`,
|
|
description: "oTunes",
|
|
images: data
|
|
? {
|
|
url: `/api/artist/${data.artist.id}/cover`,
|
|
width: 512,
|
|
height: 512,
|
|
}
|
|
: [],
|
|
},
|
|
}
|
|
}
|
|
|
|
export default async function Page({ params }: PageProps) {
|
|
const { id } = await params
|
|
const data = await fetchQuery(api.library.browseArtistDetail, {
|
|
id: id as Id<"artists">,
|
|
})
|
|
|
|
if (data === undefined) {
|
|
return (
|
|
<div className="flex h-svh flex-col">
|
|
<LibraryLoading />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (data === null) {
|
|
return (
|
|
<div className="flex h-svh flex-col">
|
|
<div className="flex flex-1 items-center justify-center pb-28">
|
|
<p className="text-sm text-muted-foreground">Artist not found.</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<title>{`${data.artist.name} - oTunes`}</title>
|
|
<meta property="og:title" content={`${data.artist.name}`} />
|
|
{/*<meta property="og:description" content={`${playlist.owner.name}`} />*/}
|
|
<meta
|
|
property="og:image"
|
|
content={`/api/artist/${data.artist.id}/cover`}
|
|
/>
|
|
<ArtistView
|
|
artist={data.artist}
|
|
albums={data.albums}
|
|
recentlyAdded={data.recentlyAdded}
|
|
recentlyPlayed={data.recentlyPlayed}
|
|
/>
|
|
</>
|
|
)
|
|
}
|