- Replace mobile placeholder with Expo Router app (tabs, playback, auth, library) - Move Convex backend to @otunes/convex for web and mobile reuse - Update web app imports and API routes to use shared package
72 lines
1.9 KiB
TypeScript
72 lines
1.9 KiB
TypeScript
import { AlbumView } from "@/components/album-view"
|
|
import { LibraryLoading } from "@/components/library-loading"
|
|
import { api } from "@otunes/convex/_generated/api"
|
|
import { fetchQuery } from "convex/nextjs"
|
|
import type { Id } from "@otunes/convex/_generated/dataModel"
|
|
import { Metadata } from "next"
|
|
|
|
interface PageProps {
|
|
params: Promise<{ id: string }>
|
|
searchParams: Promise<{ s?: string }>
|
|
}
|
|
|
|
export async function generateMetadata({
|
|
params,
|
|
searchParams,
|
|
}: PageProps): Promise<Metadata> {
|
|
const { id } = await params
|
|
const { s: songId } = await searchParams
|
|
const album = await fetchQuery(api.library.browseAlbumDetail, {
|
|
id: id as Id<"albums">,
|
|
})
|
|
|
|
const sharedTrack =
|
|
album && songId
|
|
? album.tracks.find((track) => track.id === songId)
|
|
: undefined
|
|
const pageTitle = sharedTrack
|
|
? `${sharedTrack.title} - ${album!.title}`
|
|
: album
|
|
? album.title
|
|
: null
|
|
|
|
return {
|
|
title: `${album ? `${album.title}` : "oTunes"}`,
|
|
openGraph: {
|
|
title: `${pageTitle ? `${pageTitle}` : "oTunes"}`,
|
|
description: `${album ? album.artist.name : null}`,
|
|
images: album
|
|
? { url: `/api/album/${album.id}/cover`, width: 512, height: 512 }
|
|
: [],
|
|
},
|
|
}
|
|
}
|
|
|
|
export default async function Page({ params, searchParams }: PageProps) {
|
|
const { id } = await params
|
|
const { s: highlightedSongId } = await searchParams
|
|
const album = await fetchQuery(api.library.browseAlbumDetail, {
|
|
id: id as Id<"albums">,
|
|
})
|
|
|
|
if (album === undefined) {
|
|
return (
|
|
<div className="flex h-svh flex-col">
|
|
<LibraryLoading />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (album === 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">Album not found.</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return <AlbumView album={album} highlightedSongId={highlightedSongId} />
|
|
}
|