diff --git a/app/[locale]/blog/[slug]/page.tsx b/app/[locale]/blog/[slug]/page.tsx index 84d1f9d..e830e05 100644 --- a/app/[locale]/blog/[slug]/page.tsx +++ b/app/[locale]/blog/[slug]/page.tsx @@ -1,3 +1,4 @@ +import React from "react"; import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { MDXRemote } from "next-mdx-remote/rsc"; @@ -6,6 +7,7 @@ import { ArticleHero } from "@/components/sections/ArticleHero"; import { ArticleSummary } from "@/components/sections/ArticleSummary"; import { locales } from "@/middleware"; import Link from "next/link"; +import { MermaidDiagram } from "@/components/mdx/MermaidDiagram"; type props = { params: Promise<{ @@ -110,15 +112,26 @@ const mdxComponents = { } return ( - {props.children} ); }, + pre: (props: React.ComponentPropsWithoutRef<"pre"> & { children?: React.ReactElement<{ className?: string; children?: React.ReactNode }> }) => { + const child = props.children; + const isMermaid = child?.props?.className?.includes("language-mermaid"); + + if (isMermaid && child) { + const code = String(child.props.children).trimEnd(); + return ; + } + + return
;
+    },
 };
 
 export default async function ArticlePage({ params }: props) {
@@ -197,8 +210,9 @@ export default async function ArticlePage({ params }: props) {
                 )}