Skip to content

Commit

Permalink
fix: disable render code block in rss
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Jan 30, 2024
1 parent 5fd5b64 commit 3f18021
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/app/(app)/feed/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ ${ReactDOM.renderToString(
return <img src={src} alt={alt} />
},
},
extendsRules: {
codeBlock: {
react(node, output, state) {
if (node.lang === 'mermaid' || node.lang === 'excalidraw') {
return <NotSupportRender />
}
return (
<pre key={state.key}>
<code className={node.lang ? `lang-${node.lang}` : ''}>
{node.content}
</code>
</pre>
)
},
},
},
additionalParserRules: {
spoilder: SpoilerRule,
mention: MentionRule,
Expand Down
2 changes: 0 additions & 2 deletions src/components/modules/shared/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ export const CodeBlock = (props: {
</Suspense>
)
}

export default CodeBlock
4 changes: 3 additions & 1 deletion src/components/ui/markdown/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3f18021

Please sign in to comment.