From 31ee315cfce4f712763ffa7558a87b5e2b20dd53 Mon Sep 17 00:00:00 2001 From: Sol Irvine Date: Thu, 17 Aug 2023 16:47:47 +0900 Subject: [PATCH] feat: Shop list working --- app/[locale]/[page]/page.tsx | 17 ++++--- app/[locale]/page.tsx | 4 +- app/[locale]/shops/[page]/ShopsTitle.tsx | 22 +++++++++ app/[locale]/shops/[page]/layout.tsx | 15 ++++++ app/[locale]/shops/[page]/opengraph-image.tsx | 11 +++++ app/[locale]/shops/[page]/page.tsx | 49 +++++++++++++++++++ components/grid/three-items.tsx | 6 +-- components/layout/menu/modal.tsx | 4 +- components/layout/navbar/language-control.tsx | 30 ++++++++---- components/layout/shoplist.tsx | 6 ++- components/prose.tsx | 11 ++++- messages/en.json | 4 +- messages/ja.json | 2 + 13 files changed, 153 insertions(+), 28 deletions(-) create mode 100644 app/[locale]/shops/[page]/ShopsTitle.tsx create mode 100644 app/[locale]/shops/[page]/layout.tsx create mode 100644 app/[locale]/shops/[page]/opengraph-image.tsx create mode 100644 app/[locale]/shops/[page]/page.tsx diff --git a/app/[locale]/[page]/page.tsx b/app/[locale]/[page]/page.tsx index f9f3d1196..28ae490b2 100644 --- a/app/[locale]/[page]/page.tsx +++ b/app/[locale]/[page]/page.tsx @@ -1,5 +1,6 @@ import type { Metadata } from 'next'; +import { SupportedLocale } from 'components/layout/navbar/language-control'; import Prose from 'components/prose'; import { getPage } from 'lib/shopify'; import { notFound } from 'next/navigation'; @@ -11,9 +12,9 @@ export const revalidate = 43200; // 12 hours in seconds export async function generateMetadata({ params }: { - params: { page: string }; + params: { page: string; locale: SupportedLocale }; }): Promise { - const page = await getPage({ handle: params.page }); + const page = await getPage({ handle: params.page, language: params?.locale?.toUpperCase() }); if (!page) return notFound(); @@ -28,13 +29,17 @@ export async function generateMetadata({ }; } -export default async function Page({ params }: { params: { page: string } }) { - const page = await getPage({ handle: params.page }); +export default async function Page({ + params +}: { + params: { page: string; locale: SupportedLocale }; +}) { + const page = await getPage({ handle: params.page, language: params?.locale?.toUpperCase() }); if (!page) return notFound(); return ( - <> +

{page.title}

@@ -44,6 +49,6 @@ export default async function Page({ params }: { params: { page: string } }) { day: 'numeric' }).format(new Date(page.updatedAt))}.`}

- +
); } diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx index 7cb6abba0..d30156ede 100644 --- a/app/[locale]/page.tsx +++ b/app/[locale]/page.tsx @@ -1,7 +1,7 @@ import { Carousel } from 'components/carousel'; import { ThreeItemGrid } from 'components/grid/three-items'; import Footer from 'components/layout/footer'; -import { LanguageControl, SupportedLocales } from 'components/layout/navbar/language-control'; +import { LanguageControl, SupportedLocale } from 'components/layout/navbar/language-control'; import clsx from 'clsx'; import LogoNamemark from 'components/icons/namemark'; @@ -25,7 +25,7 @@ export const metadata = { export default async function HomePage({ params: { locale } }: { - params: { locale: SupportedLocales }; + params: { locale: SupportedLocale }; }) { return ( <> diff --git a/app/[locale]/shops/[page]/ShopsTitle.tsx b/app/[locale]/shops/[page]/ShopsTitle.tsx new file mode 100644 index 000000000..252ed7807 --- /dev/null +++ b/app/[locale]/shops/[page]/ShopsTitle.tsx @@ -0,0 +1,22 @@ +'use client'; + +import { useTranslations } from 'next-intl'; +import Link from 'next/link'; + +export default function ShopsTitle() { + const t = useTranslations('Index'); + return ( +
+
+ + + + {t('shops.all')} + + +
|
+
{t('shops.title')}
+
+
+ ); +} diff --git a/app/[locale]/shops/[page]/layout.tsx b/app/[locale]/shops/[page]/layout.tsx new file mode 100644 index 000000000..6ddde54b1 --- /dev/null +++ b/app/[locale]/shops/[page]/layout.tsx @@ -0,0 +1,15 @@ +import Footer from 'components/layout/footer'; +import { Suspense } from 'react'; + +export default function Layout({ children }: { children: React.ReactNode }) { + return ( + +
+
+ {children} +
+
+