Skip to content

Commit

Permalink
#17: 在页面中增加<extoc></extoc>标签,会在此处生成TOC目录。
Browse files Browse the repository at this point in the history
fix bug: #16 : mode=pageTop. 的时候没有回到顶部的悬浮按钮了
  • Loading branch information
zhuqiang committed May 15, 2017
1 parent 699c539 commit 87a84fa
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [x] 导航标题前的层级图标是否显示,自定义H1-H3的层级图标
- [x] plugins["theme-default"],页面标题层级与官方默认主题的`showLevel`层级关联
- [x] plugins["theme-default"],插件样式支持官网默认主题的三种样式:White、Sepia、Night
- [x] 在页面中增加`<extoc></extoc>`标签,会在此处生成TOC目录

# 插件效果
* 风格:极简
Expand Down
12 changes: 11 additions & 1 deletion assets/lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ function handlerFloatNavbar($, tocs, page) {
}

function handlerPageTopNavbar($, tocs, page) {
var html = buildTopNavbar($, tocs, page);
html += "<a href='#" + tocs[0].url + "' id='anchorNavigationExGoTop'><i class='fa fa-arrow-up'></i></a>";
page.content = html + $.html();
}

function buildTopNavbar($, tocs, page) {
var config = Config.config;
var pageTop = config.pageTop;
var level1Icon = '';
Expand Down Expand Up @@ -272,7 +278,7 @@ function handlerPageTopNavbar($, tocs, page) {

html += "</ul></div>";

page.content = html + $.html();
return html;
}

function start(bookIns, page) {
Expand All @@ -292,6 +298,10 @@ function start(bookIns, page) {
} else if (mode = 'pageTop') {
handlerPageTopNavbar($, tocs, page);
}

var $x = cheerio.load(page.content);
$x('extoc').replaceWith($x(getToc($, tocs, page)));
page.content = $x.html();
}

module.exports = start;
1 change: 1 addition & 0 deletions doc/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- [x] navigation title before the hierarchy of the icon is displayed, the custom of H1, H3 level icon
- [x] plugins["theme-default"],The page title level with the default theme official ` showLevel ` hierarchy correlation
- [x] plugins["theme-default"],Plug-in style website three kinds of style of the default theme:White、Sepia、Night
- [x] Adding `<extoc></extoc>` tags to a page generates the TOC directory here

# plug-in effect
* style: a minimalist
Expand Down
5 changes: 4 additions & 1 deletion doc/config-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,7 @@ pageTop: {
level2Icon: "fa fa-hand-o-right",
level3Icon: "fa fa-hand-o-right"
}
```
```

# additional support function
Adding `<extoc></extoc>` tags to a page generates the TOC directory here.
7 changes: 5 additions & 2 deletions doc/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
}
}
```

## showLevel : TYPE:boolean
标题是否显示层级序号.页面标题和导航中的标题都会加上层级显示。

Expand Down Expand Up @@ -98,4 +97,8 @@ pageTop: {
level2Icon: "fa fa-hand-o-right",
level3Icon: "fa fa-hand-o-right"
}
```
```

# 额外功能支持

在页面中增加`<extoc></extoc>`标签,会在此处生成TOC目录。
3 changes: 3 additions & 0 deletions doc/updateRecord-en.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Update record
## v1.0.2 - 2017-05-15
- [#17](https://github.com/zq99299/gitbook-plugin-anchor-navigation-ex/pull/17)Adding an `<extoc></extoc>` tag to the page generates the TOC directory here (which is consistent with the mode: pageTop pattern for the moment)

## v1.0.0 - 2017-03-09
- [#7](https://github.com/zq99299/gitbook-plugin-anchor-navigation-ex/pull/7)
- [#8](https://github.com/zq99299/gitbook-plugin-anchor-navigation-ex/pull/8)
Expand Down
4 changes: 4 additions & 0 deletions doc/updateRecord.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Update record
## v1.0.2 - 2017-05-15
- [#17](https://github.com/zq99299/gitbook-plugin-anchor-navigation-ex/pull/17)在页面中增加`<extoc></extoc>`标签,会在此处生成TOC目录(该目录暂时与mode: "pageTop"模式生成的一致)


## v1.0.0 - 2017-03-09
- [#7](https://github.com/zq99299/gitbook-plugin-anchor-navigation-ex/pull/7)
- [#8](https://github.com/zq99299/gitbook-plugin-anchor-navigation-ex/pull/8)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gitbook-plugin-anchor-navigation-ex",
"version": "1.0.1",
"version": "1.0.2",
"description": "Supports two navigation mode, title, anchor effect is the default theme, style, follow the website",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 87a84fa

Please sign in to comment.