feat: replace the starring page with a person page
A credit now opens /person/{id}: portrait, name, department, life dates and
birthplace, the biography, and the full filmography ranked by vote count.
One request carries all of it — combined_credits rides along on the person
call — so the discover based starring query and its with_people filter go.
The biography fills whatever height the portrait leaves and fades where it
is cut, with the whole text in a tooltip on hover; a phone has no height to
respect there, so it simply runs on.
Route level and query level skeletons stand in while it loads, built from
the shadcn primitive.
Development server side fetches go over the loopback rather than SITE_URL,
which is a LAN address meant for other devices: once that address moves the
fetch hangs until undici times out, ten seconds per navigation.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6fc41c0901
commit
3dc2ebfe53
22 files changed
+342
-108
No files matched your search
@@ -0,0 +1,5 @@
|
||||
import PersonSkeleton from '@/components/Person/components/Skeleton';
|
||||
|
||||
const Loading = () => <PersonSkeleton />;
|
||||
|
||||
export default Loading;
|
||||
@@ -0,0 +1,53 @@
|
||||
import { FC } from 'react';
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
import { Metadata } from 'next';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import Person from '@/components/Person';
|
||||
import personQuery from '@/data/queries/person';
|
||||
import { SITE_URL, TITLE } from '@/env';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
interface Props {
|
||||
params: { id: string };
|
||||
}
|
||||
|
||||
export const generateMetadata = async ({ params: { id } }: Props): Promise<Metadata> => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
try {
|
||||
const { name, biography, photo } = await queryClient.fetchQuery(personQuery({ personId: id }));
|
||||
|
||||
const description = biography || `Movies and series starring ${name}.`;
|
||||
|
||||
return {
|
||||
title: `${name} | ${TITLE}`,
|
||||
description,
|
||||
openGraph: {
|
||||
title: name,
|
||||
description,
|
||||
images: photo ? [photo] : [],
|
||||
type: 'profile',
|
||||
url: `${SITE_URL}/person/${id}`
|
||||
}
|
||||
};
|
||||
} catch (_) {
|
||||
return { title: TITLE };
|
||||
}
|
||||
};
|
||||
|
||||
const PersonPage: FC<Props> = async ({ params: { id } }) => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
if (!id) return redirect('/');
|
||||
|
||||
await queryClient.prefetchQuery(personQuery({ personId: id }));
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<Person personId={id} />
|
||||
</HydrationBoundary>
|
||||
);
|
||||
};
|
||||
|
||||
export default PersonPage;
|
||||
@@ -1,31 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
|
||||
import List from '@/components/List';
|
||||
import NoResults from '@/components/NoResults';
|
||||
|
||||
import useStarring from './useStarring';
|
||||
|
||||
const Container = () => {
|
||||
const params = useSearchParams();
|
||||
|
||||
const title = params.get('title') as string;
|
||||
const actorId = params.get('actorId') as string;
|
||||
|
||||
const { shows, fetchNextPage, isFetched } = useStarring({ actorId });
|
||||
|
||||
return (
|
||||
<>
|
||||
{Boolean(title) && (
|
||||
<span className='mb-2 inline-flex h-10 w-full items-center justify-center rounded-md bg-muted p-1 text-muted-foreground'>
|
||||
Starring: {decodeURIComponent(title || '')}
|
||||
</span>
|
||||
)}
|
||||
<List shows={shows} fetchNextPage={fetchNextPage} />
|
||||
{isFetched && !shows.length && <NoResults />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Container;
|
||||
@@ -1,32 +0,0 @@
|
||||
import { FC } from 'react';
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
|
||||
import popularQuery from '@/data/queries/popular';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
|
||||
interface Props {
|
||||
searchParams: Record<string, string>;
|
||||
}
|
||||
|
||||
const Starring: FC<Props> = ({ searchParams }) => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
const { actorId } = searchParams || {};
|
||||
|
||||
queryClient.prefetchInfiniteQuery(
|
||||
popularQuery({
|
||||
sortBy: 'vote_average.desc',
|
||||
starring: actorId
|
||||
})
|
||||
);
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<Container />
|
||||
</HydrationBoundary>
|
||||
);
|
||||
};
|
||||
|
||||
export default Starring;
|
||||
@@ -1,9 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import popularQuery from '@/data/queries/popular';
|
||||
import useInfiniteList from '@/hooks/useInfiniteList';
|
||||
|
||||
const useStarring = ({ actorId }: { actorId?: string }) =>
|
||||
useInfiniteList(popularQuery({ sortBy: 'vote_average.desc', starring: actorId }));
|
||||
|
||||
export default useStarring;
|
||||
Reference in new issue
Block a user