External links
All checks were successful
Deploy / build-and-publish (push) Successful in 1m22s
Deploy / deploy (push) Successful in 14s

This commit is contained in:
2024-10-05 00:34:31 +03:00
parent b9f3b389a1
commit 8f819f3ab1
7 changed files with 97 additions and 13 deletions

17
rehype/external-links.js Normal file
View File

@@ -0,0 +1,17 @@
import {visit} from 'unist-util-visit'
export default () => {
return (tree) => {
visit(tree, 'element', function (node) {
if (
node.tagName === 'a' &&
typeof node.properties.href === 'string'
) {
const url = node.properties.href
if (url.startsWith('http://') || url.startsWith('https://')) {
node.properties.target = '_blank'
}
}
})
}
}