feat: render CMS SEO metadata and refresh published page caches
This commit is contained in:
@@ -4,6 +4,8 @@ import { getProductBySlug } from "@/services/product.service";
|
||||
import { getPreviewOrFallback } from "@/services/preview.service";
|
||||
import { BlockRenderer } from "@/blocks/BlockRenderer";
|
||||
import type { ProductPageDetail } from "@/types/wagtail";
|
||||
import { createPageMetadata, getPageSEO } from "@/services/seo.service";
|
||||
import PageSEO from "@/components/layout/PageSEO";
|
||||
|
||||
interface ProductDetailPageProps {
|
||||
params: Promise<{ slug: string }>;
|
||||
@@ -13,8 +15,7 @@ export async function generateMetadata({
|
||||
params,
|
||||
}: ProductDetailPageProps): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
const product = await getProductBySlug(slug).catch(() => null);
|
||||
return { title: product?.title ?? "产品未找到" };
|
||||
return createPageMetadata(await getPageSEO("products.ProductPage", slug).catch(() => null), "产品未找到");
|
||||
}
|
||||
|
||||
export default async function ProductDetailPage({
|
||||
@@ -33,6 +34,7 @@ export default async function ProductDetailPage({
|
||||
|
||||
return (
|
||||
<article className="mx-auto max-w-3xl px-6 py-24">
|
||||
<PageSEO type="products.ProductPage" slug={slug} />
|
||||
<h1 className="mb-4 text-4xl font-bold text-slate-900">
|
||||
{product.title}
|
||||
</h1>
|
||||
|
||||
Reference in New Issue
Block a user