feat: connect company setup data and add about page

This commit is contained in:
2026-10-27 21:36:59 +08:00
parent f990df3023
commit 43edc632a5
8 changed files with 133 additions and 29 deletions
+29
View File
@@ -0,0 +1,29 @@
import { notFound } from "next/navigation";
import type { Metadata } from "next";
import { getSimpleContentPageBySlug } from "@/services/legal.service";
import { getPreviewOrFallback } from "@/services/preview.service";
import { createPageMetadata, getPageSEO } from "@/services/seo.service";
import PageSEO from "@/components/layout/PageSEO";
import type { SimpleContentPageDetail } from "@/types/wagtail";
export async function generateMetadata(): Promise<Metadata> {
return createPageMetadata(await getPageSEO("core.SimpleContentPage", "about").catch(() => null), "关于我们");
}
export default async function AboutPage() {
const fallback = () => getSimpleContentPageBySlug("about").catch(() => null);
const candidate = await getPreviewOrFallback<SimpleContentPageDetail>("core.simplecontentpage", "body", fallback);
const page = candidate?.meta.slug === "about" ? candidate : await fallback();
if (!page) notFound();
return (
<article className="mx-auto max-w-3xl px-6 py-24">
<PageSEO type="core.SimpleContentPage" slug="about" />
<h1 className="mb-8 text-4xl font-bold text-slate-900">{page.title}</h1>
<div
className="space-y-4 text-slate-700 [&_h2]:mt-8 [&_h2]:text-2xl [&_h2]:font-semibold [&_h2]:text-slate-900 [&_ul]:list-disc [&_ul]:pl-6 [&_li]:mt-1"
dangerouslySetInnerHTML={{ __html: page.body }}
/>
</article>
);
}
+9 -11
View File
@@ -5,21 +5,19 @@ import Header from "@/components/layout/Header";
import Footer from "@/components/layout/Footer";
import CookieConsent from "@/components/layout/CookieConsent";
import ReactQueryProvider from "@/providers/react-query-provider";
import { getSiteSettings } from "@/services/site-settings.service";
// 面向中国大陆用户,避免依赖 next/font/google(构建期需访问 Google 服务器)。
// 生产环境建议自托管思源黑体 / HarmonyOS Sans 子集,这里先用系统字体栈占位。
export const metadata: Metadata = {
title: {
default: "企业官网",
template: "%s | 企业官网",
},
description: "企业级 Headless CMS 驱动的现代化官网",
icons: {
icon: { url: "/brand/shiytech-icon.svg", type: "image/svg+xml" },
shortcut: "/brand/shiytech-icon.svg",
},
};
export async function generateMetadata(): Promise<Metadata> {
const settings = await getSiteSettings();
const companyName = settings?.company_name || "企业官网";
return {
title: { default: companyName, template: `%s | ${companyName}` },
description: `${companyName}的产品、解决方案与技术服务`,
};
}
export default async function RootLayout({ children }: LayoutProps<"/">) {
const { isEnabled: isPreview } = await draftMode();