feat: render CMS SEO metadata and refresh published page caches
This commit is contained in:
@@ -4,6 +4,8 @@ import { getBlogBySlug } from "@/services/blog.service";
|
||||
import { getPreviewOrFallback } from "@/services/preview.service";
|
||||
import { BlockRenderer } from "@/blocks/BlockRenderer";
|
||||
import type { BlogPageDetail } from "@/types/wagtail";
|
||||
import { createPageMetadata, getPageSEO } from "@/services/seo.service";
|
||||
import PageSEO from "@/components/layout/PageSEO";
|
||||
|
||||
interface BlogDetailPageProps {
|
||||
params: Promise<{ slug: string }>;
|
||||
@@ -13,8 +15,7 @@ export async function generateMetadata({
|
||||
params,
|
||||
}: BlogDetailPageProps): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
const post = await getBlogBySlug(slug).catch(() => null);
|
||||
return { title: post?.title ?? "文章未找到" };
|
||||
return createPageMetadata(await getPageSEO("blog.BlogPage", slug).catch(() => null), "文章未找到");
|
||||
}
|
||||
|
||||
export default async function BlogDetailPage({ params }: BlogDetailPageProps) {
|
||||
@@ -31,6 +32,7 @@ export default async function BlogDetailPage({ params }: BlogDetailPageProps) {
|
||||
|
||||
return (
|
||||
<article className="mx-auto max-w-3xl px-6 py-24">
|
||||
<PageSEO type="blog.BlogPage" slug={slug} />
|
||||
<h1 className="mb-4 text-4xl font-bold text-slate-900">{post.title}</h1>
|
||||
{post.published_at && (
|
||||
<p className="mb-12 text-sm text-slate-500">{post.published_at}</p>
|
||||
|
||||
+6
-3
@@ -1,16 +1,19 @@
|
||||
import Link from "next/link";
|
||||
import type { Metadata } from "next";
|
||||
import { getBlogList } from "@/services/blog.service";
|
||||
import { createPageMetadata, getPageSEO } from "@/services/seo.service";
|
||||
import PageSEO from "@/components/layout/PageSEO";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "技术博客",
|
||||
};
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return createPageMetadata(await getPageSEO("blog.BlogIndexPage", "blog").catch(() => null), "技术博客");
|
||||
}
|
||||
|
||||
export default async function BlogListPage() {
|
||||
const posts = await getBlogList().catch(() => []);
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-4xl px-6 py-24">
|
||||
<PageSEO type="blog.BlogIndexPage" slug="blog" />
|
||||
<h1 className="mb-12 text-4xl font-bold text-slate-900">技术博客</h1>
|
||||
<ul className="space-y-6">
|
||||
{posts.map((post) => (
|
||||
|
||||
Reference in New Issue
Block a user