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', shouldProcessNode: (node) => node.name === 'img',
processNode(node, index) { processNode(node, index) {
const rp =
STORAGE_BASE && node.attribs.src.startsWith(STORAGE_BASE)
? 'origin'
: 'no-referrer';
return ( return (
<a
href={normalize_url(node.attribs.src)}
target="_blank"
referrerPolicy={rp}
>
<span className="ext-img__warpper loading"> <span className="ext-img__warpper loading">
<img <img
src={normalize_url(node.attribs.src)} src={normalize_url(node.attribs.src)}
alt={node.alt} alt={node.alt}
className="ext-img" className="ext-img"
referrerPolicy={ referrerPolicy={rp}
STORAGE_BASE && node.attribs.src.startsWith(STORAGE_BASE)
? 'origin'
: 'no-referrer'
}
onError={stop_loading} onError={stop_loading}
onLoad={stop_loading} onLoad={stop_loading}
/> />
</span> </span>
</a>
); );
}, },
}, },