Przeglądaj źródła

refactor use perma link

yusuketk 5 lat temu
rodzic
commit
23863684cc

+ 1 - 0
src/client/js/components/PageEditor/LinkEditModal.jsx

@@ -77,6 +77,7 @@ class LinkEditModal extends React.PureComponent {
       isUsePermanentLink: false,
       isUsePermanentLink: false,
       permalink: '',
       permalink: '',
       linkerType: type,
       linkerType: type,
+      isUseRelativePath: false,
     });
     });
   }
   }
 
 

+ 9 - 4
src/client/js/models/Linker.js

@@ -88,8 +88,13 @@ export default class Linker {
     }
     }
 
 
     // TODO GW-3074 相対パスを利用しているかテキストから判定し以下の値に反映する
     // TODO GW-3074 相対パスを利用しているかテキストから判定し以下の値に反映する
-    const isUseRelativePath = false;
-    const rootPath = '';
+    const isUseRelativePath = link.startsWith('.');
+    const rootPath = window.location.pathname;
+    if (isUseRelativePath) {
+      link = path.resolve(rootPath, link);
+    }
+    const isUsePermanentLink = false;
+    const permalink = '';
 
 
     return new Linker(
     return new Linker(
       type,
       type,
@@ -97,8 +102,8 @@ export default class Linker {
       link,
       link,
       isUseRelativePath,
       isUseRelativePath,
       rootPath,
       rootPath,
-      false,
-      '',
+      isUsePermanentLink,
+      permalink,
     );
     );
   }
   }