feat: Shop list working

This commit is contained in:
Sol Irvine
2023-08-17 16:47:47 +09:00
parent c1d06e90bb
commit 31ee315cfc
13 changed files with 153 additions and 28 deletions

View File

@@ -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<Metadata> {
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 (
<>
<div className="text-white">
<h1 className="mb-8 text-5xl font-bold">{page.title}</h1>
<Prose className="mb-8" html={page.body as string} />
<p className="text-sm italic">
@@ -44,6 +49,6 @@ export default async function Page({ params }: { params: { page: string } }) {
day: 'numeric'
}).format(new Date(page.updatedAt))}.`}
</p>
</>
</div>
);
}