diff --git a/app/(site)/[locale]/page.tsx b/app/(site)/[locale]/page.tsx index 494659740..786bccd44 100644 --- a/app/(site)/[locale]/page.tsx +++ b/app/(site)/[locale]/page.tsx @@ -1,9 +1,9 @@ import HomePage from '@/components/pages/home-page'; import HomePagePreview from '@/components/pages/home-page-preview'; -import PreviewProvider from '@/components/preview-provider'; -import { homePageQuery } from 'lib/sanity/queries'; -import { getCachedClient } from 'lib/sanity/sanity.client'; +import { homePageQuery } from '@/lib/sanity/queries'; +import { getHomePage } from '@/lib/sanity/sanity.fetch'; import { Metadata } from 'next'; +import { LiveQuery } from 'next-sanity/preview/live-query'; import { draftMode } from 'next/headers'; import { notFound } from 'next/navigation'; @@ -13,15 +13,15 @@ export const dynamic = 'force-dynamic'; export async function generateMetadata({ params }: { - params: { slug: string; locale: string }; + params: { locale: string }; }): Promise { - const homePage = await getCachedClient()(homePageQuery, params); + const homePage = await getHomePage(params.locale); if (!homePage) return notFound(); return { - title: homePage.seo.title || homePage.title, - description: homePage.seo.description || homePage.description + title: homePage?.seo?.title || homePage.title, + description: homePage?.seo?.description }; } interface HomePageParams { @@ -31,19 +31,22 @@ interface HomePageParams { } export default async function IndexPage({ params }: HomePageParams) { - const preview = draftMode().isEnabled ? { token: process.env.SANITY_API_READ_TOKEN } : undefined; + // const preview = draftMode().isEnabled ? { token: process.env.SANITY_API_READ_TOKEN } : undefined; - const data = await getCachedClient(preview)(homePageQuery, params); + const data = await getHomePage(params.locale); - if (!data) return notFound(); - - if (preview && preview.token) { - return ( - - - - ); + if (!data && !draftMode().isEnabled) { + notFound(); } - return ; + return ( + + + + ); } diff --git a/components/layout/footer/footer.tsx b/components/layout/footer/footer.tsx index 27155e3f1..8f9a9d3b0 100644 --- a/components/layout/footer/footer.tsx +++ b/components/layout/footer/footer.tsx @@ -1,6 +1,5 @@ -import Text from '@/components/ui/text'; -import { footerMenusQuery } from '@/lib/sanity/queries'; -import { getCachedClient } from '@/lib/sanity/sanity.client'; +// import { footerMenusQuery } from '@/lib/sanity/queries'; +// import { getCachedClient } from '@/lib/sanity/sanity.client'; import LocaleSwitcher from 'components/ui/locale-switcher/locale-switcher'; import Logo from 'components/ui/logo/logo'; import Link from 'next/link'; @@ -15,7 +14,7 @@ export default async function Footer({ locale }: FooterProps) { locale: locale }; - const footerMenus = await getCachedClient()(footerMenusQuery, params); + // const footerMenus = await getCachedClient()(footerMenusQuery, params); return (