2023-04-17 23:00:47 -04:00
|
|
|
import type { Metadata } from 'next';
|
|
|
|
|
|
|
|
import Prose from 'components/prose';
|
|
|
|
import { getPage } from 'lib/shopify';
|
|
|
|
import { notFound } from 'next/navigation';
|
|
|
|
|
2024-10-15 22:07:55 -05:00
|
|
|
export async function generateMetadata(props: {
|
|
|
|
params: Promise<{ page: string }>;
|
2023-04-17 23:00:47 -04:00
|
|
|
}): Promise<Metadata> {
|
2024-10-15 22:07:55 -05:00
|
|
|
const params = await props.params;
|
2023-04-17 23:00:47 -04:00
|
|
|
const page = await getPage(params.page);
|
|
|
|
|
|
|
|
if (!page) return notFound();
|
|
|
|
|
|
|
|
return {
|
|
|
|
title: page.seo?.title || page.title,
|
|
|
|
description: page.seo?.description || page.bodySummary,
|
|
|
|
openGraph: {
|
|
|
|
publishedTime: page.createdAt,
|
|
|
|
modifiedTime: page.updatedAt,
|
|
|
|
type: 'article'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-10-15 22:07:55 -05:00
|
|
|
export default async function Page(props: { params: Promise<{ page: string }> }) {
|
|
|
|
const params = await props.params;
|
2023-04-17 23:00:47 -04:00
|
|
|
const page = await getPage(params.page);
|
|
|
|
|
|
|
|
if (!page) return notFound();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<h1 className="mb-8 text-5xl font-bold">{page.title}</h1>
|
2024-10-16 12:28:58 +09:00
|
|
|
<Prose className="mb-8" html={page.body} />
|
2023-04-17 23:00:47 -04:00
|
|
|
<p className="text-sm italic">
|
|
|
|
{`This document was last updated on ${new Intl.DateTimeFormat(undefined, {
|
|
|
|
year: 'numeric',
|
|
|
|
month: 'long',
|
|
|
|
day: 'numeric'
|
|
|
|
}).format(new Date(page.updatedAt))}.`}
|
|
|
|
</p>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|