mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Links and data fetching for dynamic routes
This commit is contained in:
@@ -1,21 +1,13 @@
|
||||
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;
|
||||
};
|
||||
data: object | any;
|
||||
}
|
||||
|
||||
export default async function CategoryPage({ query, queryParams }: CategoryPageParams) {
|
||||
const category = await clientFetch(query, queryParams);
|
||||
|
||||
if (!category) return notFound();
|
||||
export default async function CategoryPage({ data }: CategoryPageParams) {
|
||||
const category = data;
|
||||
|
||||
const { title } = category;
|
||||
|
||||
|
@@ -1,19 +1,10 @@
|
||||
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;
|
||||
};
|
||||
data: object | any;
|
||||
}
|
||||
|
||||
export default async function ProductPage({ query, queryParams }: ProductPageParams) {
|
||||
const product = await clientFetch(query, queryParams);
|
||||
|
||||
if (!product) return notFound();
|
||||
export default async function ProductPage({ data }: ProductPageParams) {
|
||||
const product = data;
|
||||
|
||||
const productJsonLd = {
|
||||
'@context': 'https://schema.org',
|
||||
|
@@ -1,23 +1,13 @@
|
||||
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;
|
||||
};
|
||||
data: object | any;
|
||||
}
|
||||
|
||||
export default async function SinglePage({ query = '', queryParams }: SinglePageParams) {
|
||||
const page = await clientFetch(query, queryParams);
|
||||
|
||||
if (!page) return notFound();
|
||||
|
||||
export default async function SinglePage({ data }: SinglePageParams) {
|
||||
return (
|
||||
<div>
|
||||
<DynamicContentManager content={page?.content} />;
|
||||
</div>
|
||||
<>
|
||||
<DynamicContentManager content={data?.content} />;
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user