feat: link for image

This commit is contained in:
2022-08-25 21:21:54 +08:00
parent e0afdf0074
commit e6140c32a8

View File

@@ -140,21 +140,27 @@ export class HighlightedMarkdown extends Component {
{
shouldProcessNode: (node) => node.name === 'img',
processNode(node, index) {
const rp =
STORAGE_BASE && node.attribs.src.startsWith(STORAGE_BASE)
? 'origin'
: 'no-referrer';
return (
<span className="ext-img__warpper loading">
<img
src={normalize_url(node.attribs.src)}
alt={node.alt}
className="ext-img"
referrerPolicy={
STORAGE_BASE && node.attribs.src.startsWith(STORAGE_BASE)
? 'origin'
: 'no-referrer'
}
onError={stop_loading}
onLoad={stop_loading}
/>
</span>
<a
href={normalize_url(node.attribs.src)}
target="_blank"
referrerPolicy={rp}
>
<span className="ext-img__warpper loading">
<img
src={normalize_url(node.attribs.src)}
alt={node.alt}
className="ext-img"
referrerPolicy={rp}
onError={stop_loading}
onLoad={stop_loading}
/>
</span>
</a>
);
},
},