@vuepress/markdown 2.0.0-rc.4 → 2.0.0-rc.5

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 CHANGED
@@ -87,9 +87,9 @@ interface LinksPluginOptions {
87
87
  /**
88
88
  * Tag for internal links
89
89
  *
90
- * @default 'VPLink'
90
+ * @default 'RouteLink'
91
91
  */
92
- internalTag?: 'a' | 'VPLink' | 'RouterLink';
92
+ internalTag?: 'a' | 'RouteLink' | 'RouterLink';
93
93
  /**
94
94
  * Additional attributes for external links
95
95
  *
@@ -106,8 +106,8 @@ interface LinksPluginOptions {
106
106
  /**
107
107
  * Process links in markdown file
108
108
  *
109
- * - internal links: convert them into `<VPLink>`
110
- * - external links: add extra attrs and external icon
109
+ * - internal links: convert `<a>` tag into internalTag
110
+ * - external links: add extra attrs
111
111
  */
112
112
  declare const linksPlugin: PluginWithOptions<LinksPluginOptions>;
113
113
 
package/dist/index.js CHANGED
@@ -400,7 +400,7 @@ var importCodePlugin = (md, options = {}) => {
400
400
  };
401
401
 
402
402
  // src/plugins/linksPlugin/linksPlugin.ts
403
- import { isLinkExternal } from "@vuepress/shared";
403
+ import { isLinkExternal, normalizeRoutePath } from "@vuepress/shared";
404
404
 
405
405
  // src/plugins/linksPlugin/resolvePaths.ts
406
406
  import { removeLeadingSlash } from "@vuepress/shared";
@@ -437,7 +437,7 @@ var resolvePaths = (rawPath, base, filePathRelative) => {
437
437
 
438
438
  // src/plugins/linksPlugin/linksPlugin.ts
439
439
  var linksPlugin = (md, options = {}) => {
440
- const internalTag = options.internalTag || "VPLink";
440
+ const internalTag = options.internalTag || "RouteLink";
441
441
  const externalAttrs = {
442
442
  target: "_blank",
443
443
  rel: "noopener noreferrer",
@@ -472,13 +472,19 @@ var linksPlugin = (md, options = {}) => {
472
472
  base,
473
473
  filePathRelative
474
474
  );
475
- const normalizedPath = absolutePath.replace(new RegExp(`^${base}`), "/").replace(/(^|\/)(README|index).md$/i, "$1").replace(/\.md$/, ".html");
476
- if (["RouterLink", "VPLink"].includes(internalTag)) {
475
+ if (["RouterLink", "RouteLink"].includes(internalTag)) {
477
476
  token.tag = internalTag;
478
477
  hrefAttr[0] = "to";
478
+ const normalizedPath = normalizeRoutePath(
479
+ absolutePath.replace(new RegExp(`^${base}`), "/")
480
+ );
481
+ hrefAttr[1] = `${normalizedPath}${rawHash}`;
479
482
  hasOpenInternalLink = true;
483
+ } else {
484
+ const normalizedPath = normalizeRoutePath(absolutePath);
485
+ hrefAttr[1] = `${normalizedPath}${rawHash}`;
480
486
  }
481
- hrefAttr[1] = `${normalizedPath}${rawHash}`;
487
+ ;
482
488
  (env.links ??= []).push({
483
489
  raw: hrefLink,
484
490
  relative: relativePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/markdown",
3
- "version": "2.0.0-rc.4",
3
+ "version": "2.0.0-rc.5",
4
4
  "description": "Markdown package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -41,8 +41,8 @@
41
41
  "markdown-it-anchor": "^8.6.7",
42
42
  "markdown-it-emoji": "^3.0.0",
43
43
  "mdurl": "^2.0.0",
44
- "@vuepress/shared": "2.0.0-rc.4",
45
- "@vuepress/utils": "2.0.0-rc.4"
44
+ "@vuepress/shared": "2.0.0-rc.5",
45
+ "@vuepress/utils": "2.0.0-rc.5"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/mdurl": "^1.0.5"