39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { getContactPage } from "@/services/page.service";
|
|
import { getPreviewOrFallback } from "@/services/preview.service";
|
|
import { BlockRenderer } from "@/blocks/BlockRenderer";
|
|
import type { ContactPageDetail } from "@/types/wagtail";
|
|
import { createPageMetadata, getPageSEO } from "@/services/seo.service";
|
|
import PageSEO from "@/components/layout/PageSEO";
|
|
|
|
export async function generateMetadata(): Promise<Metadata> {
|
|
return createPageMetadata(await getPageSEO("core.ContactPage", "contact").catch(() => null), "联系我们");
|
|
}
|
|
|
|
export default async function ContactPage() {
|
|
const contactPage = await getPreviewOrFallback<ContactPageDetail>(
|
|
"core.contactpage",
|
|
"body,seo_title_override,seo_description_override",
|
|
() =>
|
|
getContactPage().catch((err) => {
|
|
console.error("getContactPage failed:", err);
|
|
return null;
|
|
}),
|
|
);
|
|
|
|
if (!contactPage) {
|
|
return (
|
|
<div className="mx-auto max-w-3xl px-6 py-32 text-center">
|
|
<h1 className="mb-4 text-3xl font-semibold text-slate-900">
|
|
联系我们
|
|
</h1>
|
|
<p className="text-slate-600">
|
|
页面内容尚未配置,请稍后再试,或通过其他渠道联系我们。
|
|
</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return <><PageSEO type="core.ContactPage" slug="contact" /><BlockRenderer blocks={contactPage.body} /></>;
|
|
}
|