feat(seo): crawlable show links, intercepted preview modal, real 404s

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
nerandClaude Fable 5 committed 2026-08-07 16:33:59 +03:00
1 parent 919dcf9a42
commit 25a5d535a4
21 files changed
+231 -127

No files matched your search

@@ -84,7 +84,7 @@ export const showSearchModal = create(({ onResolve }) => {
shows={shows}
customScrollParent={scrollRef.current}
fetchNextPage={fetchNextPage}
onPreviewClose={onResolve}
onNavigate={onResolve}
/>
</TabsContent>
))}
@@ -96,7 +96,7 @@ export const showSearchModal = create(({ onResolve }) => {
shows={shows}
customScrollParent={scrollRef.current}
fetchNextPage={fetchNextPage}
onPreviewClose={onResolve}
onNavigate={onResolve}
/>
))
)}
+15 -7
View File
@@ -1,33 +1,41 @@
'use client';
import { FC } from 'react';
import { VirtuosoGrid, VirtuosoGridProps } from 'react-virtuoso';
import { useSetAtom } from 'jotai';
import Poster from '@/components/Poster';
import { showPreviewModal } from '@/components/Preview';
import { previewSeedAtom } from '@/components/Preview/seed';
interface Props {
shows: Show[];
customScrollParent?: HTMLElement;
fetchNextPage?: () => void;
onPreviewClose?: () => void;
onNavigate?: () => void;
}
const components: VirtuosoGridProps<Movie, { shows: Show[]; onClick: (show: Show) => void }>['components'] = {
const components: VirtuosoGridProps<Movie, { shows: Show[]; onNavigate: (show: Show) => void }>['components'] = {
Item: ({ context, 'data-index': index }) => {
const { shows, onClick } = context!;
const { shows, onNavigate } = context!;
const show = shows?.[index];
if (!show) return null;
return <Poster show={show} onClick={() => onClick?.(show)} />;
return <Poster show={show} href={`/${show.type}/${show.id}`} onClick={() => onNavigate(show)} />;
}
};
const List: FC<Props> = ({ shows, fetchNextPage, onPreviewClose, customScrollParent }) => {
const List: FC<Props> = ({ shows, fetchNextPage, onNavigate, customScrollParent }) => {
const setPreviewSeed = useSetAtom(previewSeedAtom);
if (!shows.length) return null;
const context = {
shows,
onClick: (show: Show) => showPreviewModal({ show, onClose: onPreviewClose })
onNavigate: (show: Show) => {
setPreviewSeed(show);
onNavigate?.();
}
};
const handleFetchMore = () => fetchNextPage?.();
@@ -1,24 +1,28 @@
'use client';
import { FC } from 'react';
import Link from 'next/link';
import { useMutateShowState } from '@/hooks/useShowState';
interface Props {
show: Show;
href?: string;
onClick?: () => void;
}
const Handlers: FC<Props> = ({ onClick, show }) => {
const Handlers: FC<Props> = ({ href, onClick, show }) => {
const { mutate } = useMutateShowState(show);
return (
<div
onClick={onClick}
onDoubleClick={() => mutate({ list: 'favorite', value: true })}
className='absolute left-0 top-0 size-full'
/>
);
const handlers = {
onClick,
onDoubleClick: () => mutate({ list: 'favorite', value: true }),
className: 'absolute left-0 top-0 size-full'
};
if (!href) return <div {...handlers} />;
return <Link {...handlers} href={href} prefetch={false} aria-label={show.title} />;
};
export default Handlers;
+3 -2
View File
@@ -6,6 +6,7 @@ import Handlers from './components/Handlers';
interface Props {
show: Show;
href?: string;
onClick?: () => void;
className?: string;
lazy?: boolean;
@@ -14,7 +15,7 @@ interface Props {
type FetchPriorityProps = ImgHTMLAttributes<HTMLImageElement> & { fetchPriority?: 'high' | 'low' | 'auto' };
const Poster: FC<Props> = ({ show, onClick, className, lazy = true, priority = false }) => {
const Poster: FC<Props> = ({ show, href, onClick, className, lazy = true, priority = false }) => {
const fetchPriorityProps: FetchPriorityProps = priority ? { fetchPriority: 'high' } : {};
return (
@@ -38,7 +39,7 @@ const Poster: FC<Props> = ({ show, onClick, className, lazy = true, priority = f
{...fetchPriorityProps}
/>
</picture>
<Handlers show={show} onClick={onClick} />
<Handlers show={show} href={href} onClick={onClick} />
</div>
);
};
+4 -19
View File
@@ -1,12 +1,10 @@
'use client';
import { FC, ReactNode } from 'react';
import { create, InstanceProps } from 'react-modal-promise';
import Poster from '@/components/Poster';
import Credits from '@/components/Preview/components/Credits';
import useDetails from '@/components/Preview/useDetails';
import { Modal } from '@/components/ui/dialog';
import { cn } from '@/lib/utils';
import Actions from './components/Actions';
@@ -19,7 +17,7 @@ interface Props {
showId?: Show['id'];
className?: string;
posterClassName?: string;
onClose?: () => void;
modal?: boolean;
poster?: ReactNode;
externalLink?: boolean;
}
@@ -30,7 +28,7 @@ const Preview: FC<Props> = ({
showId,
className,
posterClassName,
onClose,
modal,
poster,
externalLink = true
}) => {
@@ -40,7 +38,7 @@ const Preview: FC<Props> = ({
const show: Show & Partial<Details> = (detailedShow || baseShow)!;
const isModal = Boolean(onClose);
const isModal = Boolean(modal);
return (
<div
@@ -76,24 +74,11 @@ const Preview: FC<Props> = ({
{show.overview}
</p>
<div className='order-5 mt-5 grid grid-cols-1 rounded-lg md:order-5 md:mt-auto'>
<Credits showType={show.type} showId={show.id} onClick={onClose} />
<Credits showType={show.type} showId={show.id} />
</div>
</div>
</div>
);
};
export const showPreviewModal = create(({ onResolve, onClose, show }: Props & InstanceProps<void>) => (
<Modal className='block bg-background p-0 md:bg-black' onClose={onResolve}>
<Preview
show={show}
onClose={() => {
onClose?.();
onResolve();
window.scrollTo({ top: 0, behavior: 'smooth' });
}}
/>
</Modal>
));
export default Preview;
+3
View File
@@ -0,0 +1,3 @@
import { atom } from 'jotai';
export const previewSeedAtom = atom<Show | null>(null);
@@ -1,36 +1,42 @@
'use client';
import { FC } from 'react';
import { useSetAtom } from 'jotai';
import Poster from '@/components/Poster';
import { showPreviewModal } from '@/components/Preview';
import { previewSeedAtom } from '@/components/Preview/seed';
import ScrollNavigation from '@/components/ScrollNavigation';
interface Props {
shows: Show[];
}
const Gallery: FC<Props> = ({ shows }) => (
<ScrollNavigation<HTMLUListElement>>
{({ setScrollElement }) => (
<ul
ref={setScrollElement}
className='no-scrollbar flex animate-fade-aside-slide-in snap-x snap-mandatory gap-2 overflow-auto rounded-lg opacity-0'
>
{shows
.filter((show) => show.poster['1x'])
.map((show) => (
<li key={show.id} className='snap-start'>
<Poster
className='!h-[350px] !w-[230px] text-sm'
show={show}
onClick={() => showPreviewModal({ show })}
/>
</li>
))}
</ul>
)}
</ScrollNavigation>
);
const Gallery: FC<Props> = ({ shows }) => {
const setPreviewSeed = useSetAtom(previewSeedAtom);
return (
<ScrollNavigation<HTMLUListElement>>
{({ setScrollElement }) => (
<ul
ref={setScrollElement}
className='no-scrollbar flex animate-fade-aside-slide-in snap-x snap-mandatory gap-2 overflow-auto rounded-lg opacity-0'
>
{shows
.filter((show) => show.poster['1x'])
.map((show) => (
<li key={show.id} className='snap-start'>
<Poster
className='!h-[350px] !w-[230px] text-sm'
show={show}
href={`/${show.type}/${show.id}`}
onClick={() => setPreviewSeed(show)}
/>
</li>
))}
</ul>
)}
</ScrollNavigation>
);
};
export default Gallery;