diff options
-rw-r--r-- | lib/generate/index.js | 2 | ||||
-rw-r--r-- | lib/generate/template.js | 9 | ||||
-rw-r--r-- | templates/includes/book/summary.html | 8 | ||||
-rw-r--r-- | templates/layout.html | 6 |
4 files changed, 15 insertions, 10 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js index 56d1287..c265be3 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -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, "**/*", { diff --git a/lib/generate/template.js b/lib/generate/template.js index 8f63190..fdb3578 100644 --- a/lib/generate/template.js +++ b/lib/generate/template.js @@ -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") }) ); }) diff --git a/templates/includes/book/summary.html b/templates/includes/book/summary.html index 65fd398..99c226c 100644 --- a/templates/includes/book/summary.html +++ b/templates/includes/book/summary.html @@ -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> diff --git a/templates/layout.html b/templates/layout.html index 5542cfd..fb57c8a 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -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 %}"> |