zhangdocs 1.1.15 → 1.1.18

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/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,47 +1,47 @@
1
- {
2
- "name": "zhangdocs",
3
- "version": "1.1.15",
4
- "description": "Simple document generation tool. Dependence Node.js run.",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/jaywcjlove/zhangdocs.git"
8
- },
9
- "main": "index.js",
10
- "bin": {
11
- "doc": ".bin/zhangdocs.js"
12
- },
13
- "keywords": [
14
- "zhangdocs",
15
- "markdown",
16
- "api",
17
- "document",
18
- "tool"
19
- ],
20
- "scripts": {
21
- "test": "echo \"Error: no test specified\" && exit 1"
22
- },
23
- "author": "kenny wang <wowohoo@qq.com>",
24
- "license": "MIT",
25
- "dependencies": {
26
- "autoprefixer-stylus": "^0.13.0",
27
- "cheerio": "^0.22.0",
28
- "chokidar": "^1.6.1",
29
- "colors-cli": "^1.0.7",
30
- "commander": "^2.9.0",
31
- "ejs": "^2.5.6",
32
- "highlight.js": "^11.11.1",
33
- "inquirer": "^3.0.5",
34
- "marked": "^0.3.6",
35
- "semver": "^5.3.0",
36
- "shelljs": "0.6.0",
37
- "ssr": "^1.0.15",
38
- "stylus": "^0.54.5",
39
- "underscore": "^1.8.3"
40
- },
41
- "zhangdocs": {
42
- "theme": "default",
43
- "md": [
44
- "README.md"
45
- ]
46
- }
1
+ {
2
+ "name": "zhangdocs",
3
+ "version": "1.1.18",
4
+ "description": "Simple document generation tool. Dependence Node.js run.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github飁.com/jaywcjlove/zhangdocs.git"
8
+ },
9
+ "main": "index.js",
10
+ "bin": {
11
+ "doc": ".bin/zhangdocs.js"
12
+ },
13
+ "keywords": [
14
+ "zhangdocs",
15
+ "markdown",
16
+ "api",
17
+ "document",
18
+ "tool"
19
+ ],
20
+ "scripts": {
21
+ "test": "echo \"Error: no test specified\" && exit 1"
22
+ },
23
+ "author": "kenny wang <wowohoo@qq.com>",
24
+ "license": "MIT",
25
+ "dependencies": {
26
+ "autoprefixer-stylus": "^0.13.0",
27
+ "cheerio": "^0.22.0",
28
+ "chokidar": "^1.6.1",
29
+ "colors-cli": "^1.0.7",
30
+ "commander": "^2.9.0",
31
+ "ejs": "^2.5.6",
32
+ "highlight.js": "^11.11.1",
33
+ "inquirer": "^3.0.5",
34
+ "marked": "^0.3.6",
35
+ "semver": "^5.3.0",
36
+ "shelljs": "0.6.0",
37
+ "ssr": "^1.0.15",
38
+ "stylus": "^0.54.5",
39
+ "underscore": "^1.8.3"
40
+ },
41
+ "zhangdocs": {
42
+ "theme": "default",
43
+ "md": [
44
+ "README.md"
45
+ ]
46
+ }
47
47
  }
@@ -13,35 +13,6 @@
13
13
  $('.nav').css('display', 'none');
14
14
  $('.warpper').css('padding', '0px');
15
15
  })
16
- $('#toc-toggle').on('click', function () {
17
- let width = $('.page-toc').width();
18
- if (width > 100) {
19
- $('.page-toc').width(0);
20
- $('.page-toc').css({
21
- 'width': '0',
22
- 'min-width': '0',
23
- 'padding': '0',
24
- 'border': 'none'
25
- });
26
- $('.content').css('margin-left', '0px');
27
- $(this).css({
28
- 'left': '0px'
29
- });
30
- } else {
31
- $('.page-toc').width(200);
32
- $('.page-toc').css({
33
- 'width': '200px',
34
- 'min-width': '0',
35
- 'padding': '0',
36
- 'border': 'none'
37
- });
38
- $('.content').css('margin-left', '200px');
39
- $(this).css({
40
- 'left': '200px'
41
- });
42
- }
43
- });
44
-
45
16
  // 高亮当前页面菜单
46
17
  var pathname = window.location.pathname;
47
18
  var hash = window.location.hash;
@@ -6,13 +6,6 @@
6
6
  </div>
7
7
  <% } %>
8
8
  <div class="content markdown-body <%= index ? 'index-page-content' : '' %>">
9
- <% if (!index) { %>
10
- <svg id="toc-toggle" class="toc-toggle" stroke="black" fill="none" stroke-width="2" viewBox="0 0 24 24"
11
- stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4 text-black" xmlns="http://www.w3.org/2000/svg">
12
- <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
13
- <line x1="9" y1="3" x2="9" y2="21" />
14
- </svg>
15
- <% } %>
16
9
 
17
10
  <%- markdown_html %>
18
11
  </div>
@@ -40,7 +40,7 @@ $hover-color = #1ABC9C // 悬停绿色
40
40
  // 右上角菜单图标
41
41
  .menu-icon
42
42
  position: fixed
43
- top: 20px
43
+ top: 12px
44
44
  right: 20px
45
45
  width: 32px
46
46
  height: 32px
@@ -202,11 +202,14 @@ $hover-color = #1ABC9C // 悬停绿色
202
202
  overflow-y: auto
203
203
  overflow-x: hidden
204
204
  font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif !important;
205
+ padding-top: 20px
205
206
  @media mq-mobile
206
207
  display none
207
208
  ul
208
209
  list-style-type: none
209
210
  margin: 0
211
+ padding: 0
212
+ padding-right: 5px
210
213
 
211
214
  a
212
215
  display: block
@@ -219,12 +222,13 @@ $hover-color = #1ABC9C // 悬停绿色
219
222
  &:hover
220
223
  text-decoration: underline
221
224
  li
222
- padding-left:3px
225
+ padding-left: 3px
223
226
  line-height:25px
224
227
  text-align:left
225
228
  ul
226
- margin:0 0 0 10px
227
- padding: 0 0 0 9px
229
+ margin: 0
230
+ padding-left: 12px
231
+ padding-right: 5px
228
232
  li
229
233
  a
230
234
  font-size:90%
@@ -365,28 +369,8 @@ table
365
369
  &:hover
366
370
  background: darken($primary-color, 10%)
367
371
 
368
- .toc-toggle
369
- transition: all 0.3s ease
370
- position: fixed
371
- left: 200px
372
- top: 20px
373
- width: 24px
374
- height: 24px
375
- cursor: pointer
376
- z-index: 0
377
- @media mq-mobile
378
- display: none
379
-
380
- .page-toc
381
- transition: all 0.3s ease
382
- &.toc-collapsed
383
- transform: translateX(-100%)
384
-
385
372
  .content
386
- transition: all 0.3s ease
387
373
  position: relative
388
- &.content-expanded
389
- margin-left: 12px
390
374
 
391
375
  // 数学公式样式
392
376
  .katex-display