feat: Open links in new tab

This commit is contained in:
April Hall 2025-02-24 11:24:40 -05:00
parent 40bf3e64fd
commit 74d6e86e79
No known key found for this signature in database
GPG Key ID: A49AC35CB186266C
3 changed files with 9 additions and 0 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -41,6 +41,7 @@
"@tailwindcss/typography": "^0.5.16", "@tailwindcss/typography": "^0.5.16",
"@types/better-sqlite3": "^7.6.12", "@types/better-sqlite3": "^7.6.12",
"@types/express": "^5.0.0", "@types/express": "^5.0.0",
"@types/markdown-it-link-attributes": "^3.0.5",
"@types/minio": "^7.1.1", "@types/minio": "^7.1.1",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"better-auth": "^1.1.16", "better-auth": "^1.1.16",
@ -52,6 +53,7 @@
"lucide-svelte": "^0.474.0", "lucide-svelte": "^0.474.0",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
"markdown-it-highlightjs": "^4.2.0", "markdown-it-highlightjs": "^4.2.0",
"markdown-it-link-attributes": "^4.0.1",
"minio": "^8.0.4", "minio": "^8.0.4",
"mode-watcher": "^0.5.1", "mode-watcher": "^0.5.1",
"socket.io": "^4.8.1", "socket.io": "^4.8.1",

View File

@ -1,5 +1,6 @@
import markdownit from 'markdown-it'; import markdownit from 'markdown-it';
import highlightjs from 'markdown-it-highlightjs'; import highlightjs from 'markdown-it-highlightjs';
import mila from 'markdown-it-link-attributes';
export default function renderMarkdown(input: string): string { export default function renderMarkdown(input: string): string {
const md = markdownit({ const md = markdownit({
@ -11,6 +12,12 @@ export default function renderMarkdown(input: string): string {
md.disable(['image', 'table']); md.disable(['image', 'table']);
md.use(highlightjs); md.use(highlightjs);
md.use(mila, {
attrs: {
target: '_blank',
rel: 'noopener',
},
});
return md.render(input); return md.render(input);
} }