From 39cb194b5b0a138f3f5fe82c0e9123563665b39f Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Fri, 10 Apr 2026 00:56:14 +0200 Subject: [PATCH] fix: extract CodeRenderer as named component, fix external link detection --- components/markdown-content.tsx | 75 +++++++++++++++++---------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/components/markdown-content.tsx b/components/markdown-content.tsx index d0f47d0..6280a81 100644 --- a/components/markdown-content.tsx +++ b/components/markdown-content.tsx @@ -72,6 +72,41 @@ function extractHastText(node: Element): string { .trim(); } +function CodeRenderer({ children }: { children?: React.ReactNode }) { + const insidePre = useContext(InsidePreContext); + + if (insidePre) { + return ( + + {children} + + ); + } + + return ( + + {children} + + ); +} + const components: Components = { h1: ({ children }) => (

( ), - code: ({ children }) => { - const insidePre = useContext(InsidePreContext); - - if (insidePre) { - return ( - - {children} - - ); - } - - // Inline code - return ( - - {children} - - ); - }, + code: CodeRenderer, }; export default function MarkdownContent({ content }: { content: string }) {