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