Tried some updates

This commit is contained in:
Henrik Larsson
2023-08-13 14:40:19 +02:00
parent 4e9323a1e0
commit d00eff7694
7 changed files with 0 additions and 12 deletions

View 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>
);
}

View 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>
);
}

View 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={[]} />;
</>
);
}

View 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>
);
}