mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 18:13:29 +00:00
Add navigation parsed in footer
This commit is contained in:
@@ -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
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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]
|
||||
})
|
||||
);
|
||||
})
|
||||
|
||||
+3
-3
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user