- Run the web app and Convex backend in one container with generated per-install keys - Derive Convex URLs from the server address and update self-hosting docs
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { fetchQuery } from "convex/nextjs"
|
|
import { convexServerOptions } from "@/lib/convex-server"
|
|
import { ArtistsView } from "@/components/artists-view"
|
|
import { api } from "@otunes/convex/_generated/api"
|
|
import { Metadata } from "next"
|
|
import { cache } from "react"
|
|
|
|
interface PageProps {
|
|
params: Promise<{ id: string }>
|
|
}
|
|
|
|
const fetchArtists = cache(() =>
|
|
fetchQuery(api.library.browseArtists, {}, convexServerOptions())
|
|
)
|
|
|
|
export async function generateMetadata({
|
|
params,
|
|
}: PageProps): Promise<Metadata> {
|
|
const { id } = await params
|
|
const artists = await fetchArtists()
|
|
const selectedArtist = artists.find((artist) => artist.id === id)
|
|
|
|
return {
|
|
title: `${selectedArtist ? `${selectedArtist.name}` : "oTunes"}`,
|
|
openGraph: {
|
|
title: `${selectedArtist ? `${selectedArtist.name}` : "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, albums] = await Promise.all([
|
|
fetchArtists(),
|
|
fetchQuery(api.library.browseAlbums, {}, convexServerOptions()),
|
|
])
|
|
|
|
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>
|
|
)
|
|
}
|