feat: render CMS content fields and footer settings

This commit is contained in:
2026-10-11 19:44:54 +08:00
parent 870b9b4282
commit f990df3023
19 changed files with 250 additions and 38 deletions
+6 -4
View File
@@ -6,6 +6,7 @@ import { BlockRenderer } from "@/blocks/BlockRenderer";
import type { BlogPageDetail } from "@/types/wagtail";
import { createPageMetadata, getPageSEO } from "@/services/seo.service";
import PageSEO from "@/components/layout/PageSEO";
import { BlogTags, PageCover, PublicationDate } from "@/components/layout/PageContent";
interface BlogDetailPageProps {
params: Promise<{ slug: string }>;
@@ -22,7 +23,7 @@ export default async function BlogDetailPage({ params }: BlogDetailPageProps) {
const { slug } = await params;
const post = await getPreviewOrFallback<BlogPageDetail>(
"blog.blogpage",
"body,intro,published_at",
"body,intro,published_at,cover_image,tags",
() => getBlogBySlug(slug).catch(() => null),
);
@@ -34,9 +35,10 @@ export default async function BlogDetailPage({ params }: BlogDetailPageProps) {
<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>
)}
<PublicationDate value={post.published_at} />
<BlogTags tags={post.tags} />
{post.intro && <p className="my-6 text-lg text-slate-600">{post.intro}</p>}
<PageCover image={post.cover_image} />
<BlockRenderer blocks={post.body} />
</article>
);
+5 -1
View File
@@ -3,6 +3,7 @@ import type { Metadata } from "next";
import { getBlogList } from "@/services/blog.service";
import { createPageMetadata, getPageSEO } from "@/services/seo.service";
import PageSEO from "@/components/layout/PageSEO";
import { BlogTags, ColumnHeading, PageCover, PublicationDate } from "@/components/layout/PageContent";
export async function generateMetadata(): Promise<Metadata> {
return createPageMetadata(await getPageSEO("blog.BlogIndexPage", "blog").catch(() => null), "技术博客");
@@ -14,7 +15,7 @@ export default async function BlogListPage() {
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>
<ColumnHeading type="blog.BlogIndexPage" slug="blog" fallback="技术博客" />
<ul className="space-y-6">
{posts.map((post) => (
<li key={post.id} className="border-b border-slate-100 pb-6">
@@ -24,7 +25,10 @@ export default async function BlogListPage() {
>
{post.title}
</Link>
<PageCover image={post.cover_image} compact />
<PublicationDate value={post.published_at} />
{post.intro && <p className="mt-2 text-slate-600">{post.intro}</p>}
<BlogTags tags={post.tags} />
</li>
))}
{posts.length === 0 && (