feat: add solutions list/detail pages
- types: SolutionPageSummary/Detail - services/solution.service.ts - app/solutions: list + detail pages - Header nav: add 解决方案 link
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import type { Metadata } from "next";
|
||||
import { getSolutionBySlug } from "@/services/solution.service";
|
||||
import { BlockRenderer } from "@/blocks/BlockRenderer";
|
||||
|
||||
interface SolutionDetailPageProps {
|
||||
params: Promise<{ slug: string }>;
|
||||
}
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: SolutionDetailPageProps): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
const solution = await getSolutionBySlug(slug).catch(() => null);
|
||||
return { title: solution?.title ?? "解决方案未找到" };
|
||||
}
|
||||
|
||||
export default async function SolutionDetailPage({
|
||||
params,
|
||||
}: SolutionDetailPageProps) {
|
||||
const { slug } = await params;
|
||||
const solution = await getSolutionBySlug(slug).catch(() => null);
|
||||
|
||||
if (!solution) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<article className="mx-auto max-w-3xl px-6 py-24">
|
||||
<h1 className="mb-2 text-4xl font-bold text-slate-900">
|
||||
{solution.title}
|
||||
</h1>
|
||||
{solution.industry && (
|
||||
<p className="mb-12 text-sm text-slate-500">{solution.industry}</p>
|
||||
)}
|
||||
<BlockRenderer blocks={solution.body} />
|
||||
</article>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user