Просмотр исходного кода

Merge pull request #6378 from weseek/fix/linker-with-relative-path

fix: Default markdown linker with relative path does not respect the current page path (v5.1.0)
Yuki Takei 3 лет назад
Родитель
Сommit
6c4687725b

+ 4 - 2
packages/app/src/services/renderer/markdown-it/link-by-relative-path.ts

@@ -5,14 +5,16 @@ const PATTERN_RELATIVE_PATH = new RegExp(/^(\.{1,2})(\/.*)?$/);
 
 export default class LinkerByRelativePathConfigurer {
 
-  pagePath: string
+  pagePath: string;
 
   constructor(pagePath: string) {
     this.pagePath = pagePath;
   }
 
   // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-  configure(md, pagePath: string): void {
+  configure(md): void {
+    const pagePath = this.pagePath;
+
     // Remember old renderer, if overridden, or proxy to default renderer
     const defaultRender = md.renderer.rules.link_open || function(tokens, idx, options, env, self) {
       return self.renderToken(tokens, idx, options);