fix(blog): optimize component share logic, typography, and modal layouts
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 5s
Build & Deploy / 🏗️ Build (push) Failing after 14s
Build & Deploy / 🧪 QA (push) Failing after 1m48s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 5s
Build & Deploy / 🏗️ Build (push) Failing after 14s
Build & Deploy / 🧪 QA (push) Failing after 1m48s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
This commit is contained in:
22
apps/web/src/components/MDXContent.tsx
Normal file
22
apps/web/src/components/MDXContent.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
"use client";
|
||||
|
||||
import { useMDXComponent } from "next-contentlayer2/hooks";
|
||||
import { mdxComponents } from "../content-engine/registry";
|
||||
|
||||
interface MDXContentProps {
|
||||
code: string;
|
||||
}
|
||||
|
||||
export function MDXContent({ code }: MDXContentProps) {
|
||||
// FIX: Contentlayer/MDX often appends hoisted functions *after* the `return MDXContent` statement,
|
||||
// which causes Firefox to vomit hundreds of "unreachable code after return statement" warnings.
|
||||
// We rewrite the generated IIFE string to move the return to the very end.
|
||||
let patchedCode = code;
|
||||
if (patchedCode.includes("return function MDXContent(")) {
|
||||
patchedCode = patchedCode.replace("return function MDXContent(", "const MDXContent = function MDXContent(");
|
||||
patchedCode += "\nreturn MDXContent;";
|
||||
}
|
||||
|
||||
const Component = useMDXComponent(patchedCode);
|
||||
return <Component components={mdxComponents} />;
|
||||
}
|
||||
Reference in New Issue
Block a user