فهرست منبع

refactor use perma link

yusuketk 5 سال پیش
والد
کامیت
23863684cc
2فایلهای تغییر یافته به همراه10 افزوده شده و 4 حذف شده
  1. 1 0
      src/client/js/components/PageEditor/LinkEditModal.jsx
  2. 9 4
      src/client/js/models/Linker.js

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

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

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

@@ -88,8 +88,13 @@ export default class Linker {
     }
 
     // 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(
       type,
@@ -97,8 +102,8 @@ export default class Linker {
       link,
       isUseRelativePath,
       rootPath,
-      false,
-      '',
+      isUsePermanentLink,
+      permalink,
     );
   }