mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Tried some updates
This commit is contained in:
34
app/[locale]/[...slug]/pages/category-page.tsx
Normal file
34
app/[locale]/[...slug]/pages/category-page.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import Search from '@/components/search/search';
|
||||
import SearchResult from '@/components/search/search-result';
|
||||
import Text from '@/components/ui/text/text';
|
||||
import { clientFetch } from '@/lib/sanity/sanity.client';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
interface CategoryPageParams {
|
||||
query: string;
|
||||
queryParams: {
|
||||
slug: string;
|
||||
locale: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default async function CategoryPage({ query, queryParams }: CategoryPageParams) {
|
||||
const category = await clientFetch(query, queryParams);
|
||||
|
||||
if (!category) return notFound();
|
||||
|
||||
const { title } = category;
|
||||
|
||||
return (
|
||||
<div className="my-8 flex w-full flex-col px-4 lg:my-12 lg:px-8 2xl:px-16">
|
||||
{title && (
|
||||
<Text className="mb-8 lg:mb-12" variant="pageHeading">
|
||||
{title}
|
||||
</Text>
|
||||
)}
|
||||
<Search isCategory placeholder={title.toLowerCase()}>
|
||||
<SearchResult />
|
||||
</Search>
|
||||
</div>
|
||||
);
|
||||
}
|
23
app/[locale]/[...slug]/pages/home-page.tsx
Normal file
23
app/[locale]/[...slug]/pages/home-page.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import DynamicContentManager from '@/components/layout/dynamic-content-manager/dynamic-content-manager';
|
||||
import { clientFetch } from '@/lib/sanity/sanity.client';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
interface HomePageParams {
|
||||
query: string;
|
||||
queryParams: {
|
||||
slug: string;
|
||||
locale: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default async function HomePage({ query = '', queryParams }: HomePageParams) {
|
||||
const homePage = await clientFetch(query, queryParams);
|
||||
|
||||
if (!homePage) return notFound();
|
||||
|
||||
return (
|
||||
<div>
|
||||
<DynamicContentManager content={homePage?.content} />;
|
||||
</div>
|
||||
);
|
||||
}
|
37
app/[locale]/[...slug]/pages/product-page.tsx
Normal file
37
app/[locale]/[...slug]/pages/product-page.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import ProductView from '@/components/product/product-view';
|
||||
import { clientFetch } from '@/lib/sanity/sanity.client';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
interface ProductPageParams {
|
||||
query: string;
|
||||
queryParams: {
|
||||
slug: string;
|
||||
locale: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default async function ProductPage({ query, queryParams }: ProductPageParams) {
|
||||
const product = await clientFetch(query, queryParams);
|
||||
|
||||
if (!product) return notFound();
|
||||
|
||||
const productJsonLd = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'Product',
|
||||
name: product.name,
|
||||
description: product.description,
|
||||
image: product.images[0].asset.url
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<script
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: JSON.stringify(productJsonLd)
|
||||
}}
|
||||
/>
|
||||
<ProductView product={product} relatedProducts={[]} />;
|
||||
</>
|
||||
);
|
||||
}
|
23
app/[locale]/[...slug]/pages/single-page.tsx
Normal file
23
app/[locale]/[...slug]/pages/single-page.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import DynamicContentManager from '@/components/layout/dynamic-content-manager/dynamic-content-manager';
|
||||
import { clientFetch } from '@/lib/sanity/sanity.client';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
interface SinglePageParams {
|
||||
query: string;
|
||||
queryParams: {
|
||||
slug: string;
|
||||
locale: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default async function SinglePage({ query = '', queryParams }: SinglePageParams) {
|
||||
const page = await clientFetch(query, queryParams);
|
||||
|
||||
if (!page) return notFound();
|
||||
|
||||
return (
|
||||
<div>
|
||||
<DynamicContentManager content={page?.content} />;
|
||||
</div>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user