mirror of
https://github.com/vercel/commerce.git
synced 2025-05-12 20:57:51 +00:00
fix: split hero rendering
Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
This commit is contained in:
parent
7015d1caef
commit
b1782a4a28
@ -23,9 +23,7 @@ export async function generateMetadata(): Promise<Metadata> {
|
||||
export default async function HomePage() {
|
||||
return (
|
||||
<>
|
||||
<Suspense>
|
||||
<Hero />
|
||||
</Suspense>
|
||||
<div className="flex min-h-96 flex-col">
|
||||
<Suspense>
|
||||
<About />
|
||||
|
@ -8,14 +8,10 @@ import ImageDisplay from './page/image-display';
|
||||
|
||||
const { SITE_NAME } = process.env;
|
||||
|
||||
const Hero = async () => {
|
||||
const [offers, heroImage] = await Promise.all([
|
||||
getMetaobjects('usp_item'),
|
||||
getMetaobject({ handle: { type: 'hero', handle: `${kebabCase(SITE_NAME)}-hero` } })
|
||||
]);
|
||||
const Offers = async () => {
|
||||
const offers = await getMetaobjects('usp_item');
|
||||
|
||||
return (
|
||||
<div className="flex flex-col border-b border-gray-200 lg:border-0">
|
||||
<nav aria-label="Offers" className="order-last bg-white lg:order-first">
|
||||
<div className="max-w-8xl mx-auto lg:px-8">
|
||||
<ul
|
||||
@ -37,12 +33,45 @@ const Hero = async () => {
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
};
|
||||
|
||||
<div className="relative bg-gray-900">
|
||||
{/* Decorative image and overlay */}
|
||||
<div aria-hidden="true" className="absolute inset-0 overflow-hidden">
|
||||
{heroImage ? (
|
||||
<Suspense fallback={<div className="h-[626px] w-full" />}>
|
||||
const OffersPlaceholder = () => {
|
||||
return (
|
||||
<nav aria-label="Offers" className="order-last bg-white lg:order-first">
|
||||
<div className="max-w-8xl mx-auto lg:px-8">
|
||||
<ul
|
||||
role="list"
|
||||
className="grid animate-pulse grid-cols-1 divide-y divide-gray-200 py-5 lg:grid-cols-4 lg:divide-x lg:divide-y-0"
|
||||
>
|
||||
<li className="flex w-full items-center justify-start gap-2 px-4 lg:justify-center">
|
||||
<div className="size-7 rounded bg-gray-100" />
|
||||
<div className="h-7 w-1/3 rounded bg-slate-100" />
|
||||
</li>
|
||||
<li className="flex w-full items-center justify-start gap-2 px-4 lg:justify-center">
|
||||
<div className="size-7 rounded bg-gray-100" />
|
||||
<div className="h-7 w-1/3 rounded bg-slate-100" />
|
||||
</li>
|
||||
<li className="flex w-full items-center justify-start gap-2 px-4 lg:justify-center">
|
||||
<div className="size-7 rounded bg-gray-100" />
|
||||
<div className="h-7 w-1/3 rounded bg-slate-100" />
|
||||
</li>
|
||||
<li className="flex w-full items-center justify-start gap-2 px-4 lg:justify-center">
|
||||
<div className="size-7 rounded bg-gray-100" />
|
||||
<div className="h-7 w-1/3 rounded bg-slate-100" />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
};
|
||||
const HeroImage = async () => {
|
||||
const heroImage = await getMetaobject({
|
||||
handle: { type: 'hero', handle: `${kebabCase(SITE_NAME)}-hero` }
|
||||
});
|
||||
|
||||
return heroImage ? (
|
||||
<Suspense>
|
||||
<ImageDisplay
|
||||
fileId={heroImage.file as string}
|
||||
title="Hero Image"
|
||||
@ -63,7 +92,21 @@ const Hero = async () => {
|
||||
className="h-full w-full object-cover object-center"
|
||||
sizes="100vw"
|
||||
/>
|
||||
)}
|
||||
);
|
||||
};
|
||||
|
||||
const Hero = () => {
|
||||
return (
|
||||
<div className="flex flex-col border-b border-gray-200 lg:border-0">
|
||||
<Suspense fallback={<OffersPlaceholder />}>
|
||||
<Offers />
|
||||
</Suspense>
|
||||
<div className="relative">
|
||||
{/* Decorative image and overlay */}
|
||||
<div aria-hidden="true" className="absolute inset-0 overflow-hidden">
|
||||
<Suspense fallback={<div className="h-[626px] w-full" />}>
|
||||
<HeroImage />
|
||||
</Suspense>
|
||||
</div>
|
||||
<div aria-hidden="true" className="absolute inset-0 bg-dark opacity-80" />
|
||||
<div className="flex flex-col gap-10 px-6 py-20 text-center sm:pb-56 sm:pt-32 lg:px-0">
|
||||
|
Loading…
x
Reference in New Issue
Block a user