Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/app/products/[productId]/components/UssPreloadPoster.tsx

This file was deleted.

20 changes: 20 additions & 0 deletions src/app/products/[productId]/head.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { getProductDetail } from '@/actions/productDetail';

type Props = {
params: { productId: string };
};

export default async function Head({ params }: Props) {
const product = await getProductDetail(Number(params.productId));

const posterImage =
product.image && product.image !== 'https://example.com'
? product.image
: '/images/noImage.png';

return (
<>
<link rel='preload' as='image' href={posterImage} />
</>
);
}
2 changes: 0 additions & 2 deletions src/app/products/[productId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import MetricCard from './components/MetricCard';
import ProductTriggers from './components/ProductTriggers';
import ReviewSection from './components/ReviewSection';
import ShareButton from './components/ShareButton';
import UsePreloadPoster from './components/UssPreloadPoster';

type ProductIdPageProps = {
params: Promise<{ productId: string }>;
Expand Down Expand Up @@ -45,7 +44,6 @@ const ProductIdPage = async ({ params }: ProductIdPageProps) => {

return (
<div className='mx-auto max-w-250 px-5 py-10'>
<UsePreloadPoster src={posterImage} />
<header className='flex w-full flex-col md:max-h-[350px] md:flex-row'>
<div className='relative mx-auto aspect-[5/7] w-full shrink-0 transition-normal duration-300 md:max-w-[250px]'>
<Image
Expand Down