summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/generate/template.js1
-rw-r--r--lib/parse/navigation.js1
-rw-r--r--lib/parse/progress.js14
-rw-r--r--templates/layout.html2
-rw-r--r--templates/page.html12
5 files changed, 19 insertions, 11 deletions
diff --git a/lib/generate/template.js b/lib/generate/template.js
index d8c1f79..3edd4da 100644
--- a/lib/generate/template.js
+++ b/lib/generate/template.js
@@ -49,7 +49,6 @@ var initTemplate = function(options) {
content: sections,
basePath: basePath,
staticBase: path.join(basePath, "gitbook"),
- navigation: options.locals.allNavigation[_output],
progress: parse.progress(options.locals.allNavigation, _output)
})
);
diff --git a/lib/parse/navigation.js b/lib/parse/navigation.js
index 29b1a0c..9ed82b9 100644
--- a/lib/parse/navigation.js
+++ b/lib/parse/navigation.js
@@ -70,6 +70,7 @@ function navigation(summary, files) {
// Hack for README.html
mapping['README.html'] = {
+ title: README_NAV.title,
prev: null,
next: clean(summary.chapters[0]),
level: '0',
diff --git a/lib/parse/progress.js b/lib/parse/progress.js
index 73fbbe0..7259e07 100644
--- a/lib/parse/progress.js
+++ b/lib/parse/progress.js
@@ -2,7 +2,7 @@ var _ = require("lodash");
var calculProgress = function(navigation, current) {
var n = _.size(navigation);
- var percent = 0, prevPercent = 0;
+ var percent = 0, prevPercent = 0, currentChapter = null;
var done = true;
var chapters = _.chain(navigation)
@@ -20,6 +20,7 @@ var calculProgress = function(navigation, current) {
// Is it done
nav.done = done;
if (nav.path == current) {
+ currentChapter = nav;
percent = nav.percent;
done = false;
} else if (done) {
@@ -30,11 +31,18 @@ var calculProgress = function(navigation, current) {
})
.value();
-
return {
+ // Previous percent
prevPercent: prevPercent,
+
+ // Current percent
percent: percent,
- chapters: chapters
+
+ // List of chapter with progress
+ chapters: chapters,
+
+ // Current chapter
+ current: currentChapter
};
}
diff --git a/templates/layout.html b/templates/layout.html
index 735f5d3..e07b385 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -3,7 +3,7 @@
<head>
{% block head %}
<meta charset="UTF-8">
- <title>{% block title %} | GitBook{% endblock %}</title>
+ <title>{% block title %} | {{ title }}{% endblock %}</title>
<meta name="robots" content="{% block robots %}noindex, nofollow{% endblock %}">
<link rel="shortcut icon" href="{{ staticBase }}/images/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="{{ staticBase }}/style.css">
diff --git a/templates/page.html b/templates/page.html
index 01868cb..6f27b33 100644
--- a/templates/page.html
+++ b/templates/page.html
@@ -1,10 +1,10 @@
{% extends "layout.html" %}
-{% block title %}{{ _input }} {{ title }}{% parent %}{% endblock %}
+{% block title %}{{ progress.current.title }}{% parent %}{% endblock %}
{% block description %}{% endblock %}
{% block robots %}index, follow{% endblock %}
{% block content %}
-<div class="book {% if _input == "README.md" %}with-summary{% endif %}" data-github="{{ githubId }}" data-level="{{ navigation.level }}">
+<div class="book {% if _input == "README.md" %}with-summary{% endif %}" data-github="{{ githubId }}" data-level="{{ progress.current.level }}">
{% include "includes/book/header.html" %}
{% include "includes/book/summary.html" %}
<div class="book-body">
@@ -34,11 +34,11 @@
<div class="page-footer">
{% if _input == "README.md" %}
- <a href="{{ basePath }}/{{ navigation.next.path }}" class="navigation-link">Start</a>
+ <a href="{{ basePath }}/{{ progress.current.next.path }}" class="navigation-link">Start</a>
{% else %}
- {% if navigation.next %}
- {% if navigation.next.path %}
- <a href="{{ basePath }}/{{ navigation.next.path }}" class="navigation-link next">Next</a>
+ {% if progress.current.next %}
+ {% if progress.current.next.path %}
+ <a href="{{ basePath }}/{{ progress.current.next.path }}" class="navigation-link next">Next</a>
{% else %}
<div class="navigation-link coming-soon">Coming soon</div>
{% endif %}