Skip to content

Commit

Permalink
fix(mdx-link): open blank new tab when click mdx <a> links
Browse files Browse the repository at this point in the history
issue #614
  • Loading branch information
sabertazimi committed Apr 26, 2022
1 parent 1587767 commit a417ca5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/getPostsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import fs from 'node:fs/promises';
import path from 'node:path';
import readingTime from 'reading-time';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeExternalLinks from 'rehype-external-links';
import rehypeKatex from 'rehype-katex';
import rehypeSlug from 'rehype-slug';
import remarkGemoji from 'remark-gemoji';
Expand Down Expand Up @@ -52,7 +53,12 @@ async function generatePostData(filePath: string): Promise<Post> {
parseFrontmatter: false,
mdxOptions: {
remarkPlugins: [remarkGfm, remarkGitHub, remarkGemoji, remarkMath],
rehypePlugins: [rehypeSlug, rehypeAutolinkHeadings, rehypeKatex],
rehypePlugins: [
rehypeSlug,
rehypeAutolinkHeadings,
rehypeExternalLinks,
rehypeKatex,
],
},
});

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"prettier": "^2.6.2",
"reading-time": "^1.5.0",
"rehype-autolink-headings": "^6.1.1",
"rehype-external-links": "^1.0.1",
"rehype-katex": "^6.0.2",
"rehype-slug": "^5.0.1",
"remark-gemoji": "^7.0.1",
Expand Down
22 changes: 22 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,7 @@ __metadata:
react-dom: ^18.0.0
reading-time: ^1.5.0
rehype-autolink-headings: ^6.1.1
rehype-external-links: ^1.0.1
rehype-katex: ^6.0.2
rehype-slug: ^5.0.1
remark-gemoji: ^7.0.1
Expand Down Expand Up @@ -6601,6 +6602,13 @@ __metadata:
languageName: node
linkType: hard

"is-absolute-url@npm:^4.0.0":
version: 4.0.1
resolution: "is-absolute-url@npm:4.0.1"
checksum: de172a718439982a54477fdae55f21be69ec0e6a4b205db5484975d2f4ee749851fd46c28f3790dfc51a274c2ed1d0f8457b6d1fff02ab829069fd9cc761e48c
languageName: node
linkType: hard

"is-alphabetical@npm:^1.0.0":
version: 1.0.4
resolution: "is-alphabetical@npm:1.0.4"
Expand Down Expand Up @@ -11381,6 +11389,20 @@ __metadata:
languageName: node
linkType: hard

"rehype-external-links@npm:^1.0.1":
version: 1.0.1
resolution: "rehype-external-links@npm:1.0.1"
dependencies:
"@types/hast": ^2.0.0
extend: ^3.0.0
is-absolute-url: ^4.0.0
space-separated-tokens: ^2.0.0
unified: ^10.0.0
unist-util-visit: ^4.0.0
checksum: db83671c3c477d8c5c158880ccfa3969680895d8e59b7a358bd11baaee10d5c06d93d99cc11b044da0b8a1e6050db425f6c3910ac881b00bf407566d7449a8b4
languageName: node
linkType: hard

"rehype-katex@npm:^6.0.2":
version: 6.0.2
resolution: "rehype-katex@npm:6.0.2"
Expand Down

0 comments on commit a417ca5

Please sign in to comment.