summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-04 10:45:36 -0700
committerSamy Pessé <samypesse@gmail.com>2014-04-04 10:45:36 -0700
commite0d96b316390660557c1eac72314cdd659ba58e0 (patch)
tree631a24d35b4b0c81ffefc51686525cbd7f26feed
parentf656390783922952cc1f6fe8b0a5d0dc902fa92e (diff)
downloadgitbook-e0d96b316390660557c1eac72314cdd659ba58e0.zip
gitbook-e0d96b316390660557c1eac72314cdd659ba58e0.tar.gz
gitbook-e0d96b316390660557c1eac72314cdd659ba58e0.tar.bz2
Fix links in templates
-rw-r--r--lib/generate/generator_site.js7
-rw-r--r--templates/includes/book/footer.html4
-rw-r--r--templates/includes/book/progress.html2
-rw-r--r--templates/includes/book/summary.html4
-rw-r--r--templates/layout.html4
5 files changed, 13 insertions, 8 deletions
diff --git a/lib/generate/generator_site.js b/lib/generate/generator_site.js
index 1cc8614..6e1903d 100644
--- a/lib/generate/generator_site.js
+++ b/lib/generate/generator_site.js
@@ -7,11 +7,16 @@ var fs = require("./fs");
var parse = require("../parse");
var BaseGenerator = require("./generator");
-// Init swig filter lines for returning the count of lines in a code section
+// Swig filter for returning the count of lines in a code section
swig.setFilter('lines', function(content) {
return content.split('\n').length;
});
+// Swig filter for returning a link to the associated html file of a markdown file
+swig.setFilter('mdLink', function(link) {
+ return link.replace(".md", ".html");
+});
+
var Generator = function() {
BaseGenerator.apply(this, arguments);
diff --git a/templates/includes/book/footer.html b/templates/includes/book/footer.html
index 48f4bf9..1112b14 100644
--- a/templates/includes/book/footer.html
+++ b/templates/includes/book/footer.html
@@ -1,10 +1,10 @@
<div class="page-footer">
{% if _input == "README.md" %}
- <a href="{{ basePath }}/{{ progress.current.next.path }}" class="navigation-link">Start</a>
+ <a href="{{ basePath }}/{{ progress.current.next.path|mdLink }}" class="navigation-link">Start</a>
{% else %}
{% if progress.current.next %}
{% if progress.current.next.path %}
- <a href="{{ basePath }}/{{ progress.current.next.path }}" class="navigation-link next">Next</a>
+ <a href="{{ basePath }}/{{ progress.current.next.path|mdLink }}" class="navigation-link next">Next</a>
{% else %}
<div class="navigation-link coming-soon">Coming soon</div>
{% endif %}
diff --git a/templates/includes/book/progress.html b/templates/includes/book/progress.html
index d0e3193..176c95f 100644
--- a/templates/includes/book/progress.html
+++ b/templates/includes/book/progress.html
@@ -4,7 +4,7 @@
</div>
<div class="chapters">
{% for p in progress.chapters %}
- <a href="{{ basePath }}/{{ p.path }}" title="{{ p.title }}" class="chapter {% if p.done %}done{% endif %} {% if p.level.length == 1 %}new-chapter{% endif %}" data-progress="{{ p.level }}" style="left: {{ p.percent }}%;"></a>
+ <a href="{{ basePath }}/{{ p.path|mdLink }}" title="{{ p.title }}" class="chapter {% if p.done %}done{% endif %} {% if p.level.length == 1 %}new-chapter{% endif %}" data-progress="{{ p.level }}" style="left: {{ p.percent }}%;"></a>
{% endfor %}
</div>
</div> \ No newline at end of file
diff --git a/templates/includes/book/summary.html b/templates/includes/book/summary.html
index d74fb18..996ff3d 100644
--- a/templates/includes/book/summary.html
+++ b/templates/includes/book/summary.html
@@ -16,7 +16,7 @@
{% for item in summary.chapters %}
<li {% if item._path == _input %}class="active"{% endif %} data-level="{{ item.level }}">
{% if item.path %}
- <a href="{{ basePath }}/{{ item.path }}">
+ <a href="{{ basePath }}/{{ item.path|mdLink }}">
<i class="fa fa-check"></i> <b>{{ item.level }})</b> {{ item.title }}
</a>
{% else %}
@@ -27,7 +27,7 @@
{% for article in item.articles %}
<li {% if article._path == _input %}class="active"{% endif %} data-level="{{ article.level }}">
{% if article.path %}
- <a href="{{ basePath }}/{{ article.path }}">
+ <a href="{{ basePath }}/{{ article.path|mdLink }}">
<i class="fa fa-check"></i> <b>{{ article.level }})</b> {{ article.title }}
</a>
{% else %}
diff --git a/templates/layout.html b/templates/layout.html
index c0f52cb..47184b3 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -13,10 +13,10 @@
<meta name="generator" content="www.gitbook.io">
{% if progress.current.next and progress.current.next.path %}
- <link rel="next" href="{{ basePath }}/{{ progress.current.next.path }}" />
+ <link rel="next" href="{{ basePath }}/{{ progress.current.next.path|mdLink }}" />
{% endif %}
{% if progress.current.prev and progress.current.prev.path %}
- <link rel="prev" href="{{ basePath }}/{{ progress.current.prev.path }}" />
+ <link rel="prev" href="{{ basePath }}/{{ progress.current.prev.path|mdLink }}" />
{% endif %}
<meta property="og:title" content="{% block title %} | {{ title }}{% endblock %}">