From 5c2f3d5e3ec2fe0e24d12642f8e5358ac3c82289 Mon Sep 17 00:00:00 2001 From: Henrik Larsson Date: Fri, 7 Jul 2023 12:56:33 +0200 Subject: [PATCH] Locale switcher updates --- app/[locale]/[[...slug]]/page.tsx | 51 +++++++++++------ app/[locale]/layout.tsx | 18 +----- components/layout/header/header.tsx | 57 ++++++++++--------- .../ui/locale-switcher/locale-switcher.tsx | 38 +++++++++---- lib/sanity/queries.tsx | 2 +- 5 files changed, 92 insertions(+), 74 deletions(-) diff --git a/app/[locale]/[[...slug]]/page.tsx b/app/[locale]/[[...slug]]/page.tsx index 2c8276360..0ab67b638 100644 --- a/app/[locale]/[[...slug]]/page.tsx +++ b/app/[locale]/[[...slug]]/page.tsx @@ -15,6 +15,9 @@ import ProductPage from './product-page'; import ProductPagePreview from './product-page-preview'; import SinglePage from './single-page'; import SinglePagePreview from './single-page-preview'; +// Chrome +import Footer from 'components/layout/footer'; +import Header from 'components/layout/header'; /** * Render pages depending on type. @@ -30,24 +33,40 @@ export default async function Page({ params }: { params: { slug: string[]; local const data = filterDataToSingleItem(pageData, isEnabled); - if (isEnabled) { - return ( - - {docType === 'home' && } - {docType === 'page' && } - {docType === 'product' && } - {docType === 'category' && } - - ); - } + const localeData = { + type: data._type, + locale: data.locale, + translations: data.translations + }; return ( - <> - {docType === 'home' && } - {docType === 'product' && } - {docType === 'category' && } - {docType === 'page' && } - +
+
+
+
+ {isEnabled ? ( + + {docType === 'home' && } + {docType === 'page' && } + {docType === 'product' && ( + + )} + {docType === 'category' && ( + + )} + + ) : ( + <> + {docType === 'home' && } + {docType === 'product' && } + {docType === 'category' && } + {docType === 'page' && } + + )} +
+
+
+
); } diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index 817770125..3d2a7833c 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -1,5 +1,3 @@ -import Footer from 'components/layout/footer'; -import Header from 'components/layout/header'; import { NextIntlClientProvider } from 'next-intl'; import { Inter } from 'next/font/google'; import { notFound } from 'next/navigation'; @@ -10,8 +8,6 @@ const SITE_NAME = 'KM Storefront'; const SITE_DESCRIPTION = 'Webb och digitalbyrå från Göteborg'; const TWITTER_CREATOR = '@kodamera.se'; const TWITTER_SITE = 'https://kodamera.se'; -const OG_IMAGE_URL = '/og-image.jpg'; -const OG_IMAGE_ALT = 'Kodamera'; export const metadata = { title: { @@ -19,16 +15,6 @@ export const metadata = { template: `%s | ${SITE_NAME}` }, description: SITE_DESCRIPTION, - openGraph: { - images: [ - { - url: OG_IMAGE_URL, - width: 1200, - height: 630, - alt: OG_IMAGE_ALT - } - ] - }, robots: { follow: true, index: true @@ -73,9 +59,7 @@ export default async function LocaleLayout({ children, params: { locale } }: Loc -
-
{children}
-