@vuepress/markdown 2.0.0-rc.16 → 2.0.0-rc.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +12 -6
- package/dist/index.js +2 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -44,12 +44,6 @@ interface ImportCodePluginOptions {
|
|
|
44
44
|
declare const importCodePlugin: PluginWithOptions<ImportCodePluginOptions>;
|
|
45
45
|
|
|
46
46
|
interface LinksPluginOptions {
|
|
47
|
-
/**
|
|
48
|
-
* Tag for internal links
|
|
49
|
-
*
|
|
50
|
-
* @default 'RouteLink'
|
|
51
|
-
*/
|
|
52
|
-
internalTag?: 'a' | 'RouteLink' | 'RouterLink';
|
|
53
47
|
/**
|
|
54
48
|
* Additional attributes for external links
|
|
55
49
|
*
|
|
@@ -62,6 +56,18 @@ interface LinksPluginOptions {
|
|
|
62
56
|
* ```
|
|
63
57
|
*/
|
|
64
58
|
externalAttrs?: Record<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* Tag for internal links
|
|
61
|
+
*
|
|
62
|
+
* @default 'RouteLink'
|
|
63
|
+
*/
|
|
64
|
+
internalTag?: 'a' | 'RouteLink' | 'RouterLink';
|
|
65
|
+
/**
|
|
66
|
+
* Method to check if a link is external
|
|
67
|
+
*
|
|
68
|
+
* @default import { isLinkExternal } from '@vuepress/shared'
|
|
69
|
+
*/
|
|
70
|
+
isExternal?: (href: string, env: MarkdownEnv) => boolean;
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
67
73
|
* Process links in markdown file
|
package/dist/index.js
CHANGED
|
@@ -232,6 +232,7 @@ var resolvePaths = (rawPath, base, filePathRelative) => {
|
|
|
232
232
|
// src/plugins/linksPlugin/linksPlugin.ts
|
|
233
233
|
var linksPlugin = (md, options = {}) => {
|
|
234
234
|
const internalTag = options.internalTag || "RouteLink";
|
|
235
|
+
const isExternal = options.isExternal ?? ((href, env) => isLinkExternal(href, env.base));
|
|
235
236
|
const externalAttrs = {
|
|
236
237
|
target: "_blank",
|
|
237
238
|
rel: "noopener noreferrer",
|
|
@@ -247,7 +248,7 @@ var linksPlugin = (md, options = {}) => {
|
|
|
247
248
|
const hrefAttr = token.attrs[hrefIndex];
|
|
248
249
|
const hrefLink = hrefAttr[1];
|
|
249
250
|
const { base = "/", filePathRelative = null } = env;
|
|
250
|
-
if (
|
|
251
|
+
if (isExternal(hrefLink, env)) {
|
|
251
252
|
Object.entries(externalAttrs).forEach(([key, val]) => {
|
|
252
253
|
token.attrSet(key, val);
|
|
253
254
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/markdown",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.18",
|
|
4
4
|
"description": "Markdown package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"markdown-it-anchor": "^9.2.0",
|
|
42
42
|
"markdown-it-emoji": "^3.0.0",
|
|
43
43
|
"mdurl": "^2.0.0",
|
|
44
|
-
"@vuepress/
|
|
45
|
-
"@vuepress/
|
|
44
|
+
"@vuepress/shared": "2.0.0-rc.18",
|
|
45
|
+
"@vuepress/utils": "2.0.0-rc.18"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/mdurl": "^2.0.0"
|