feat(md): add _blank for all links with http/https (#141)

This commit is contained in:
云游君 2021-06-13 14:39:22 +08:00 committed by GitHub
parent 4335ed3e6a
commit e3bc59a5f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -27,6 +27,7 @@
"cross-env": "^7.0.3",
"eslint": "^7.28.0",
"https-localhost": "^4.6.5",
"markdown-it-link-attributes": "^3.0.0",
"markdown-it-prism": "^2.1.6",
"pnpm": "^6.7.6",
"typescript": "^4.3.2",

View File

@ -14,6 +14,7 @@ specifiers:
cross-env: ^7.0.3
eslint: ^7.28.0
https-localhost: ^4.6.5
markdown-it-link-attributes: ^3.0.0
markdown-it-prism: ^2.1.6
nprogress: ^0.2.0
pnpm: ^6.7.6
@ -54,6 +55,7 @@ devDependencies:
cross-env: 7.0.3
eslint: 7.28.0
https-localhost: 4.6.5
markdown-it-link-attributes: 3.0.0
markdown-it-prism: 2.1.6
pnpm: 6.7.6
typescript: 4.3.2
@ -5049,6 +5051,10 @@ packages:
engines: {node: '>=4'}
dev: true
/markdown-it-link-attributes/3.0.0:
resolution: {integrity: sha512-B34ySxVeo6MuEGSPCWyIYryuXINOvngNZL87Mp7YYfKIf6DcD837+lXA8mo6EBbauKsnGz22ZH0zsbOiQRWTNg==}
dev: true
/markdown-it-prism/2.1.6:
resolution: {integrity: sha512-fuo5lq36A6kzb882vCsvdyh4HUzpwdfNkAl92cr+MjUO0Q9foz/7MZ/RpKRBlZSwt86LmPlW7ubaEwf4C+0b3g==}
engines: {node: '>=6.0.0'}

View File

@ -10,6 +10,7 @@ import WindiCSS from 'vite-plugin-windicss'
import { VitePWA } from 'vite-plugin-pwa'
import VueI18n from '@intlify/vite-plugin-vue-i18n'
import Prism from 'markdown-it-prism'
import LinkAttributes from 'markdown-it-link-attributes'
export default defineConfig({
resolve: {
@ -37,6 +38,13 @@ export default defineConfig({
markdownItSetup(md) {
// https://prismjs.com/
md.use(Prism)
md.use(LinkAttributes, {
pattern: /^https?:\/\//,
attrs: {
target: '_blank',
rel: 'noopener',
},
})
},
}),