zhangdocs 1.1.16 → 1.1.19

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/index.html CHANGED
@@ -38,7 +38,7 @@
38
38
  }
39
39
  };
40
40
  </script>
41
- <script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
41
+ <script src="https://static.docs-hub.com/mermaidmin_1764833418462.js"></script>
42
42
  <script>
43
43
  document.addEventListener('DOMContentLoaded', function () {
44
44
  mermaid.initialize({
package/lib/build.js CHANGED
@@ -72,10 +72,9 @@ function generateIndexPage(zhangdocsmd, pathArr, currentPath, relativePath) {
72
72
  url = url.replace(process.cwd() + '/md', process.cwd() + '/html').replace(/\.md/, '.html');
73
73
  url = url.replace(process.cwd() + '/', '');
74
74
 
75
- // 获取相对路径(从index.html到目标文件)
76
- temp = file.relativePath(current, process.cwd());
77
- temp += url;
78
- return temp;
75
+ // index.html(根目录)到html目录下的文件,直接使用相对路径
76
+ // index.html在根目录,html/xxx.html也在根目录下,所以路径是 html/xxx.html
77
+ return url;
79
78
  }
80
79
 
81
80
  function generateList(arr, _sub, level) {
package/lib/file.js CHANGED
@@ -30,7 +30,16 @@ if(!String.repeat ){
30
30
  // from 文件绝对路径
31
31
  // to 指定到目录的相对目录
32
32
  function relativePath(from,to){
33
- return path.relative(from,to).replace(/\\/g,'/').replace(/\.\.$/g,'');
33
+ var relative = path.relative(path.dirname(from), to).replace(/\\/g,'/');
34
+ // 如果相对路径为空或为当前目录,返回 './'
35
+ if (!relative || relative === '.') {
36
+ return './';
37
+ }
38
+ // 确保以 / 结尾(用于目录路径)
39
+ if (!relative.endsWith('/')) {
40
+ relative += '/';
41
+ }
42
+ return relative;
34
43
  }
35
44
 
36
45
  // 波浪号的绝对路径
package/lib/nav.js CHANGED
@@ -73,14 +73,20 @@ function pathto(urlarr,basename,current,index,floor){
73
73
  current = current.replace(process.cwd()+'/md',process.cwd() + '/html').replace(/\.md/,'.html');
74
74
  }
75
75
 
76
- // 获取相对路径
77
- temp = file.relativePath(current ,process.cwd());
78
-
79
76
  // 从index.html跳转到其他页面的特殊处理
80
77
  if(floor === 0 && current.indexOf('index.html') > -1) {
81
- temp = "";
78
+ // 从根目录的index.html跳转,直接使用相对路径
79
+ return url;
82
80
  }
83
81
 
82
+ // 获取相对路径(从当前文件所在目录到项目根目录)
83
+ temp = file.relativePath(current ,process.cwd());
84
+
85
+ // 如果temp是 './',说明当前文件在根目录,直接返回url
86
+ if (temp === './') {
87
+ return url;
88
+ }
89
+
84
90
  temp += url;
85
91
  return temp;
86
92
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "zhangdocs",
3
- "version": "1.1.16",
3
+ "version": "1.1.19",
4
4
  "description": "Simple document generation tool. Dependence Node.js run.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github飁.com/jaywcjlove/zhangdocs.git"
7
+ "url": "https://github.com/jaywcjlove/zhangdocs.git"
8
8
  },
9
9
  "main": "index.js",
10
10
  "bin": {
@@ -24,8 +24,8 @@
24
24
  };
25
25
  </script>
26
26
  <!-- 加载 MathJax -->
27
- <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
28
- <script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
27
+ <script id="MathJax-script" async src="https://static.docs-hub.com/texsvg_1764833463111.js"></script>
28
+ <script src="https://static.docs-hub.com/mermaidmin_1764833418462.js"></script>
29
29
  <script>
30
30
  document.addEventListener('DOMContentLoaded', function () {
31
31
  mermaid.initialize({