From 3f18021cf0f34177d1883a1a3efe25b8317ee679 Mon Sep 17 00:00:00 2001 From: Innei Date: Tue, 30 Jan 2024 16:00:30 +0800 Subject: [PATCH] fix: disable render code block in rss Signed-off-by: Innei --- src/app/(app)/feed/route.tsx | 16 ++++++++++++++++ src/components/modules/shared/CodeBlock.tsx | 2 -- src/components/ui/markdown/Markdown.tsx | 4 +++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/app/(app)/feed/route.tsx b/src/app/(app)/feed/route.tsx index 0ce80d7673..1d60921492 100644 --- a/src/app/(app)/feed/route.tsx +++ b/src/app/(app)/feed/route.tsx @@ -105,6 +105,22 @@ ${ReactDOM.renderToString( return {alt} }, }, + extendsRules: { + codeBlock: { + react(node, output, state) { + if (node.lang === 'mermaid' || node.lang === 'excalidraw') { + return + } + return ( +
+                
+                  {node.content}
+                
+              
+ ) + }, + }, + }, additionalParserRules: { spoilder: SpoilerRule, mention: MentionRule, diff --git a/src/components/modules/shared/CodeBlock.tsx b/src/components/modules/shared/CodeBlock.tsx index f2368a3fed..7933e6a441 100644 --- a/src/components/modules/shared/CodeBlock.tsx +++ b/src/components/modules/shared/CodeBlock.tsx @@ -36,5 +36,3 @@ export const CodeBlock = (props: { ) } - -export default CodeBlock diff --git a/src/components/ui/markdown/Markdown.tsx b/src/components/ui/markdown/Markdown.tsx index 4ea7cf0c31..d045bce499 100644 --- a/src/components/ui/markdown/Markdown.tsx +++ b/src/components/ui/markdown/Markdown.tsx @@ -41,7 +41,9 @@ import { MTag } from './renderers/tag' import { getFootNoteDomId, getFootNoteRefDomId } from './utils/get-id' import { redHighlight } from './utils/redHighlight' -const CodeBlock = dynamic(() => import('~/components/modules/shared/CodeBlock')) +const CodeBlock = dynamic(() => + import('~/components/modules/shared/CodeBlock').then((mod) => mod.CodeBlock), +) export interface MdProps { value?: string