really really open markdown links outside (#1002)

This commit is contained in:
marcelle
2025-01-31 21:02:38 -05:00
committed by GitHub
parent 44bf57b397
commit 0ca4cf01c7
@@ -6,6 +6,10 @@ import { oneLight } from 'react-syntax-highlighter/dist/cjs/styles/prism';
import { Check, Copy } from './icons'; import { Check, Copy } from './icons';
import { visit } from 'unist-util-visit'; import { visit } from 'unist-util-visit';
const UrlTransform = {
a: ({ node, ...props }) => <a {...props} target="_blank" rel="noopener noreferrer" />,
};
function rehypeinlineCodeProperty() { function rehypeinlineCodeProperty() {
return function (tree) { return function (tree) {
if (!tree) return; if (!tree) return;
@@ -84,6 +88,7 @@ export default function MarkdownContent({ content, className = '' }: MarkdownCon
prose-code:break-all prose-code:whitespace-pre-wrap prose-code:break-all prose-code:whitespace-pre-wrap
${className}`} ${className}`}
components={{ components={{
...UrlTransform,
code({ node, className, children, inlinecode, ...props }) { code({ node, className, children, inlinecode, ...props }) {
const match = /language-(\w+)/.exec(className || 'language-text'); const match = /language-(\w+)/.exec(className || 'language-text');
return inlinecode == 'false' && match ? ( return inlinecode == 'false' && match ? (