diff --git a/bun.lockb b/bun.lockb index a5327e7..8370767 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index daae4d4..2d4216c 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "@tailwindcss/typography": "^0.5.16", "@types/better-sqlite3": "^7.6.12", "@types/express": "^5.0.0", + "@types/markdown-it-link-attributes": "^3.0.5", "@types/minio": "^7.1.1", "autoprefixer": "^10.4.20", "better-auth": "^1.1.16", @@ -52,6 +53,7 @@ "lucide-svelte": "^0.474.0", "markdown-it": "^14.1.0", "markdown-it-highlightjs": "^4.2.0", + "markdown-it-link-attributes": "^4.0.1", "minio": "^8.0.4", "mode-watcher": "^0.5.1", "socket.io": "^4.8.1", diff --git a/src/lib/functions/renderMarkdown.ts b/src/lib/functions/renderMarkdown.ts index 98c0b50..3e4a7ad 100644 --- a/src/lib/functions/renderMarkdown.ts +++ b/src/lib/functions/renderMarkdown.ts @@ -1,5 +1,6 @@ import markdownit from 'markdown-it'; import highlightjs from 'markdown-it-highlightjs'; +import mila from 'markdown-it-link-attributes'; export default function renderMarkdown(input: string): string { const md = markdownit({ @@ -11,6 +12,12 @@ export default function renderMarkdown(input: string): string { md.disable(['image', 'table']); md.use(highlightjs); + md.use(mila, { + attrs: { + target: '_blank', + rel: 'noopener', + }, + }); return md.render(input); }