mirror of
https://github.com/vercel/commerce.git
synced 2025-05-19 16:07:01 +00:00
Add suspense to pages
This commit is contained in:
parent
21bfa76db0
commit
11ff96c729
@ -13,6 +13,7 @@ import type { Metadata } from 'next';
|
|||||||
import { LiveQuery } from 'next-sanity/preview/live-query';
|
import { LiveQuery } from 'next-sanity/preview/live-query';
|
||||||
import { draftMode } from 'next/headers';
|
import { draftMode } from 'next/headers';
|
||||||
import { notFound } from 'next/navigation';
|
import { notFound } from 'next/navigation';
|
||||||
|
import { Suspense } from 'react';
|
||||||
|
|
||||||
export async function generateMetadata({
|
export async function generateMetadata({
|
||||||
params
|
params
|
||||||
@ -107,10 +108,26 @@ export default async function Page({ params }: PageParams) {
|
|||||||
as={PagePreview}
|
as={PagePreview}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
{docType === 'page' && <SinglePage data={data} />}
|
{docType === 'page' && (
|
||||||
{docType === 'product' && <ProductPage data={data} />}
|
<Suspense fallback={<div>Loading page...</div>}>
|
||||||
{docType === 'category' && <CategoryPage data={data} />}
|
<SinglePage data={data} />
|
||||||
{docType === 'search' && <SearchPage data={data} />}
|
</Suspense>
|
||||||
|
)}
|
||||||
|
{docType === 'product' && (
|
||||||
|
<Suspense fallback={<div>Loading product...</div>}>
|
||||||
|
<ProductPage data={data} />
|
||||||
|
</Suspense>
|
||||||
|
)}
|
||||||
|
{docType === 'category' && (
|
||||||
|
<Suspense fallback={<div>Loading category...</div>}>
|
||||||
|
<CategoryPage data={data} />
|
||||||
|
</Suspense>
|
||||||
|
)}
|
||||||
|
{docType === 'search' && (
|
||||||
|
<Suspense fallback={<div>Loading search...</div>}>
|
||||||
|
<SearchPage data={data} />
|
||||||
|
</Suspense>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
</LiveQuery>
|
</LiveQuery>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user