mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Ported sanity studio to Next js app
This commit is contained in:
38
app/(site)/[locale]/page.tsx
Normal file
38
app/(site)/[locale]/page.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import DynamicContentManager from 'components/layout/dynamic-content-manager/dynamic-content-manager';
|
||||
import { homePageQuery } from 'lib/sanity/queries';
|
||||
import { clientFetch } from 'lib/sanity/sanity.client';
|
||||
import { Metadata } from 'next';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
export const runtime = 'edge';
|
||||
|
||||
export async function generateMetadata({
|
||||
params
|
||||
}: {
|
||||
params: { slug: string; locale: string };
|
||||
}): Promise<Metadata> {
|
||||
const homePage = await clientFetch(homePageQuery, params);
|
||||
|
||||
if (!homePage) return notFound();
|
||||
|
||||
return {
|
||||
title: homePage.seo.title || homePage.title,
|
||||
description: homePage.seo.description || homePage.description
|
||||
};
|
||||
}
|
||||
|
||||
interface HomePageParams {
|
||||
params: {
|
||||
locale: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default async function HomePage({ params }: HomePageParams) {
|
||||
const data = await clientFetch(homePageQuery, params);
|
||||
|
||||
return (
|
||||
<>
|
||||
<DynamicContentManager content={data?.content} />
|
||||
</>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user