diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-03-31 17:17:34 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-03-31 17:17:34 -0700 |
commit | ce3e1030248e07bca2d4112b5754bdbca20a5229 (patch) | |
tree | 1f1e8a989cd74c6bc67a2f6867da83ca387f50a7 | |
parent | 8ecaeb86f9c530cdf38ee7026c2f91bae57c0d0f (diff) | |
download | gitbook-ce3e1030248e07bca2d4112b5754bdbca20a5229.zip gitbook-ce3e1030248e07bca2d4112b5754bdbca20a5229.tar.gz gitbook-ce3e1030248e07bca2d4112b5754bdbca20a5229.tar.bz2 |
Add navigation parsed in footer
-rw-r--r-- | lib/generate/index.js | 8 | ||||
-rw-r--r-- | lib/generate/template.js | 5 | ||||
-rw-r--r-- | templates/page.html | 6 |
3 files changed, 12 insertions, 7 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js index 14168fd..351cc82 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -7,7 +7,7 @@ var parse = require("../parse"); var template = require("./template"); var generate = function(root, output, options) { - var files, summary, tpl; + var files, summary, navigation, tpl; options = _.defaults(options || {}, { // Book title @@ -45,6 +45,9 @@ var generate = function(root, output, options) { return fs.readFile(path.join(root, "SUMMARY.md"), "utf-8") .then(function(_summary) { summary = parse.summary(_summary); + + // Parse navigation + navigation = parse.navigation(summary); }); }) @@ -57,7 +60,8 @@ var generate = function(root, output, options) { githubAuthor: options.github.split("/")[0], githubId: options.github, title: options.title, - summary: summary + summary: summary, + allNavigation: navigation } }) }) diff --git a/lib/generate/template.js b/lib/generate/template.js index e29464c..0fad90c 100644 --- a/lib/generate/template.js +++ b/lib/generate/template.js @@ -27,7 +27,7 @@ var initTemplate = function(options) { }); return function(input, output, local) { - var _input = input; + var _input = input, _output = output; input = path.join(options.root, input); output = path.join(options.output, output); @@ -48,7 +48,8 @@ var initTemplate = function(options) { _input: _input, content: sections, basePath: basePath, - staticBase: path.join(basePath, "gitbook") + staticBase: path.join(basePath, "gitbook"), + navigation: options.locals.allNavigation[_output] }) ); }) diff --git a/templates/page.html b/templates/page.html index 270cd54..5a8d422 100644 --- a/templates/page.html +++ b/templates/page.html @@ -25,13 +25,13 @@ <div class="page-footer"> <div class="navigation"> {% if _input == "README.md" %} - <a href="{{ navigation.next.path }}" class="navigation-link">Start this book</a> + <a href="{{ basePath }}/{{ navigation.next.path }}" class="navigation-link">Start this book</a> {% else %} {% if navigation.prev %} - <a href="{{ navigation.prev.path }}" class="navigation-link"><i class="fa fa-chevron-left"></i> {{ navigation.prev.title }}</a> + <a href="{{ basePath }}/{{ navigation.prev.path }}" class="navigation-link"><i class="fa fa-chevron-left"></i> {{ navigation.prev.title }}</a> {% endif %} {% if navigation.next %} - <a href="{{ navigation.next.path }}" class="navigation-link">{{ navigation.next.title }} <i class="fa fa-chevron-right"></i></a> + <a href="{{ basePath }}/{{ navigation.next.path }}" class="navigation-link">{{ navigation.next.title }} <i class="fa fa-chevron-right"></i></a> {% endif %} {% endif %} </div> |