Skip to content

Commit d4e9900

Browse files
ryan-williamsclaude
andcommitted
Add target="_blank" to external links in MDX
Use rehype-external-links plugin to automatically add target="_blank" and rel="noopener noreferrer" to links pointing to external domains (GitHub, Superhuman, Vimium, etc.). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f8241d3 commit d4e9900

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

site/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"react-dom": "^19.2.0",
2727
"react-icons": "^5.5.0",
2828
"react-router-dom": "^7.11.0",
29+
"rehype-external-links": "^3.0.0",
2930
"rehype-pretty-code": "^0.14.1",
3031
"rehype-raw": "^7.0.0",
3132
"remark-code-extra": "^1.0.1",

site/pnpm-lock.yaml

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/vite.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
33
import mdx from '@mdx-js/rollup'
4+
import rehypeExternalLinks from 'rehype-external-links'
45

56
// https://vite.dev/config/
67
export default defineConfig({
78
plugins: [
8-
{ enforce: 'pre', ...mdx() },
9+
{
10+
enforce: 'pre',
11+
...mdx({
12+
rehypePlugins: [
13+
[rehypeExternalLinks, { target: '_blank', rel: ['noopener', 'noreferrer'] }],
14+
],
15+
}),
16+
},
917
react({ include: /\.(jsx|js|mdx|md|tsx|ts)$/ }),
1018
],
1119
resolve: {

0 commit comments

Comments
 (0)