Fix #127: add configuration for changing links in sidebar

This commit is contained in:
Samy Pessé
2014-04-30 16:46:24 +02:00
parent 2999d90907
commit fa00b52fb5
4 changed files with 48 additions and 17 deletions
+8 -1
View File
@@ -59,7 +59,14 @@ Here are the options that can be stored in this file:
"plugins": [],
// Global configuration for plugins
"pluginsConfig": {}
"pluginsConfig": {},
// Links in template (null: default, false: remove, string: new value)
"links": {
"about": null,
"issues": null,
"edit": null
}
}
```
+16 -11
View File
@@ -28,29 +28,34 @@ var generate = function(options) {
options = _.defaults(options || {}, {
// Folders to use
input: null,
output: null,
"input": null,
"output": null,
// Config file (relative to input)
configFile: "book.json",
"configFile": "book.json",
// Output generator
generator: "site",
"generator": "site",
// Book title, keyword, description
title: null,
description: null,
"title": null,
"description": null,
// Origin github repository id
github: null,
githubHost: 'https://github.com/',
"github": null,
"githubHost": 'https://github.com/',
// Theming
theme: path.resolve(__dirname, '../../theme'),
"theme": path.resolve(__dirname, '../../theme'),
// Plugins
plugins: [],
pluginsConfig: {}
"plugins": [],
"pluginsConfig": {},
// Links
"links": {
"about": null
}
});
if (!options.input) {
+3 -1
View File
@@ -80,7 +80,9 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
allNavigation: that.options.navigation,
plugins: that.plugins,
pluginsConfig: JSON.stringify(that.options.pluginsConfig)
pluginsConfig: JSON.stringify(that.options.pluginsConfig),
options: that.options
}, options));
})
.then(interpolate)
+21 -4
View File
@@ -3,18 +3,28 @@
<input type="text" placeholder="Search" class="form-control" />
</div>
<ul class="summary">
{% if githubId %}
{% if options.links.about !== false && (options.links.about != null || githubId) %}
<li>
<a href="{{ githubHost }}{{ githubAuthor }}" target="blank">About the author</a>
<a href="{{ options.links.about|default(githubHost+githubAuthor) }}" target="blank">About the author</a>
</li>
{% endif %}
{% if options.links.issues !== false && (options.links.issues != null || githubId) %}
<li>
<a href="{{ githubHost }}{{ githubId }}/issues" target="blank">Questions and Issues</a>
<a href="{{ options.links.issues|default(githubHost+githubId+"/issues") }}" target="blank">Questions and Issues</a>
</li>
{% endif %}
{% if options.links.contribute !== false && (options.links.contribute != null || githubId) %}
<li>
<a href="{{ githubHost }}{{ githubId }}/edit/master/{{ _input }}" target="blank">Edit and Contribute</a>
<a href="{{ options.links.contribute|default(githubHost+githubId+"/edit/master/"+_input) }}" target="blank">Edit and Contribute</a>
</li>
{% endif %}
{% if options.links.contribute || options.links.issues || options.links.about || githubId %}
<li class="divider"></li>
{% endif %}
<li data-level="0" data-path="index.html">
<a href="{{ basePath }}/"><i class="fa fa-check"></i> Introduction</a>
</li>
@@ -44,5 +54,12 @@
{% endif %}
</li>
{% endfor %}
{% if options.links.gitbook !== false %}
<li class="divider"></li>
<li>
<a href="http://www.gitbook.io/" target="blank">Generated using GitBook</a>
</li>
{% endif %}
</ul>
</div>