Yuki Takei 2 лет назад
Родитель
Сommit
428ed0f794
2 измененных файлов с 10 добавлено и 7 удалено
  1. 8 0
      packages/remark-lsx/src/utils/depth-utils.ts
  2. 2 7
      packages/remark-lsx/src/utils/page-node.ts

+ 8 - 0
packages/remark-lsx/src/utils/depth-utils.ts

@@ -0,0 +1,8 @@
+import { isTopPage } from '@growi/core/dist/utils/page-path-utils';
+
+export const getDepthOfPath = (path: string): number => {
+  if (isTopPage(path)) {
+    return 0;
+  }
+  return (path.match(/\//g) ?? []).length;
+};

+ 2 - 7
packages/remark-lsx/src/utils/page-node.ts

@@ -1,16 +1,11 @@
 import * as url from 'url';
 import * as url from 'url';
 
 
 import { IPageHasId, ParseRangeResult, pathUtils } from '@growi/core';
 import { IPageHasId, ParseRangeResult, pathUtils } from '@growi/core';
-import { isTopPage } from '@growi/core/dist/utils/page-path-utils';
 
 
 import type { PageNode } from '../interfaces/page-node';
 import type { PageNode } from '../interfaces/page-node';
 
 
-function getDepthOfPath(path: string) {
-  if (isTopPage(path)) {
-    return 0;
-  }
-  return (path.match(/\//g) ?? []).length;
-}
+import { getDepthOfPath } from './depth-utils';
+
 
 
 function getParentPath(path: string) {
 function getParentPath(path: string) {
   return pathUtils.removeTrailingSlash(decodeURIComponent(url.resolve(path, './')));
   return pathUtils.removeTrailingSlash(decodeURIComponent(url.resolve(path, './')));