Skip to content

Commit

Permalink
set target and rel
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Sep 25, 2024
1 parent 9abc896 commit 7f1a617
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/composables/Markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export function useLinkifyIt() {
const md = new MarkdownIt('zero', { linkify: true })
md.enable('linkify')

md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
const token = tokens[idx]
token.attrSet('target', '_blank')
token.attrSet('rel', 'noreferrer')
return self.renderToken(tokens, idx, options)
}

return (source: string) => {
return md.renderInline(source)
}
Expand Down

0 comments on commit 7f1a617

Please sign in to comment.