Fix all relative links

This commit is contained in:
Samy Pessé
2014-03-31 12:31:01 -07:00
parent 77a4c1042c
commit 4210794de6
4 changed files with 15 additions and 10 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ var generate = function(root, output, options) {
github: null
});
if (!options.github) return Q.reject(new Error("Need options.github for specifing the github origin"));
if (!options.github || !options.title) return Q.reject(new Error("Need options.github and optiosn.title"));
// List all files in the repository
return Q.nfcall(glob, "**/*", {
+7 -2
View File
@@ -22,9 +22,12 @@ var initTemplate = function(options) {
});
return function(input, output, local) {
var _input = input;
input = path.join(options.root, input);
output = path.join(options.output, output);
var basePath = path.relative(path.dirname(output), options.output) || ".";
// Read markdown file
return fs.readFile(input, "utf-8")
@@ -37,8 +40,10 @@ var initTemplate = function(options) {
.then(function(sections) {
return tpl(
_.extend(local || {}, options.locals, {
_input: input,
content: sections
_input: _input,
content: sections,
basePath: basePath,
staticBase: path.join(basePath, "gitbook")
})
);
})
+4 -4
View File
@@ -1,20 +1,20 @@
<div class="book-summary">
<ul class="summary">
<li>
<a href="/book/{{ book.attributes.full_name }}/README.md">Introduction</a>
<a href="{{ basePath }}/README.html">Introduction</a>
</li>
<li>
<a href="https://github.com/{{ book.attributes.owner.login }}" target="blank">About the author</a>
<a href="https://github.com/{{ owner }}" target="blank">About the author</a>
</li>
<li class="divider"></li>
{% for item in summary.chapters %}
<li>
<a href="{{ item.chapter.path }}">{{ item.chapter.title }}</a>
<a href="{{ basePath }}/{{ item.chapter.path }}">{{ item.chapter.title }}</a>
{% if item.articles.length > 0 %}
<ul class="articles">
{% for article in item.articles %}
<li>
<a href="{{ article.path }}">{{ article.title }}</a>
<a href="{{ basePath }}/{{ article.path }}">{{ article.title }}</a>
</li>
{% endfor %}
</ul>
+3 -3
View File
@@ -9,8 +9,8 @@
{% else %}
<meta name="robots" content="{% block robots %}noindex, nofollow{% endblock %}">
{% endif %}
<link rel="icon" href="gitbook/images/icons/32.png">
<link rel="stylesheet" href="gitbook/style.css">
<link rel="icon" href="{{ staticBase }}/images/icons/32.png">
<link rel="stylesheet" href="{{ staticBase }}/style.css">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="{% block description %}{% endblock %}">
<meta name="keywords" content="{% block keywords %}{% endblock %}" >
@@ -19,7 +19,7 @@
<meta name="og:site_name" content="GitBook">
<meta name="og:url" content="{{ config.web.url }}">
<meta name="og:description" content="{% block description %}{% endblock %}">
<meta name="og:image" content="gitbook/images/icons/ios.png" >
<meta name="og:image" content="{{ staticBase }}/images/icons/ios.png" >
<meta name="application-name" content="Gitbook">
<meta name="application-url" content="{{ config.web.url }}">
<meta name="msapplication-tooltip" content="{% block description %}{% endblock %}">