import type { ReactNode } from "react"; import type { Components } from "react-markdown"; import { renderMarkdownToReact } from "@/components/markdown/renderMarkdown"; import { splitContentSegments } from "@/lib/directiveBlocks"; import type { HideKind } from "@/lib/hideBlocks"; import MdHideBlock from "@/components/markdown/MdHideBlock"; import MdTimeline from "@/components/markdown/MdTimeline"; type MarkdownBodyProps = { content: string; className?: string; components?: Components; /** 详情页解锁门禁需要 */ postId?: number; /** 登录跳转(公告等无 postId 时) */ loginHref?: string; loggedIn?: boolean; }; /** * 站点统一 Markdown 渲染(服务端):GFM + Shiki;支持 [hide] / [timeline]。 */ export default async function MarkdownBody({ content, className = "prose-content", components, postId, loginHref, loggedIn = false, }: MarkdownBodyProps) { const segs = splitContentSegments(content || ""); const nodes = []; for (let i = 0; i < segs.length; i++) { const seg = segs[i]; if (seg.type === "md") { if (!seg.text.trim()) continue; nodes.push(