Skip to content

Commit

Permalink
Fix #36: add mathjax plugin as default
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse committed Apr 20, 2014
1 parent 878c105 commit 4a380e9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
10 changes: 6 additions & 4 deletions lib/generate/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var _ = require("lodash");
var Q = require("q");
var semver = require("semver");
var path = require("path");
var url = require("url");
var fs = require("./fs");

var pkg = require("../../package.json");
Expand Down Expand Up @@ -42,9 +43,9 @@ Plugin.prototype.getResources = function(resource) {
}
return _.chain(this.infos.book[resource])
.map(function(resource) {
return {
"path": this.name+"/"+resource
}
var parsed = url.parse(resource);
if (parsed.protocol) return {"url": resource}
else return { "path": this.name+"/"+resource };
}.bind(this))
.value();
};
Expand Down Expand Up @@ -172,7 +173,8 @@ Plugin.fromList = function(names) {

// Default plugins
Plugin.defaults = [
"mixpanel"
"mixpanel",
"mathjax"
];

module.exports = Plugin;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"semver": "2.2.1",

"gitbook-plugin": "0.0.1",
"gitbook-plugin-mixpanel": "0.0.1"
"gitbook-plugin-mixpanel": "0.0.1",
"gitbook-plugin-mathjax": "0.0.1"
},
"devDependencies": {
"mocha": "1.18.2",
Expand Down
12 changes: 10 additions & 2 deletions theme/templates/site.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,21 @@
{% block javascript %}
{% parent %}
{% for resource in plugins.resources.js %}
<script src="{{ staticBase }}/plugins/{{ resource.path }}"></script>
{% if resource.url %}
<script src="{{ resource.url }}"></script>
{% else %}
<script src="{{ staticBase }}/plugins/{{ resource.path }}"></script>
{% endif %}
{% endfor %}
{% endblock %}

{% block style %}
{% parent %}
{% for resource in plugins.resources.css %}
<link rel="stylesheet" href="{{ staticBase }}/plugins/{{ resource.path }}">
{% if resource.url %}
<link rel="stylesheet" href="{{ resource.url }}">
{% else %}
<link rel="stylesheet" href="{{ staticBase }}/plugins/{{ resource.path }}">
{% endif %}
{% endfor %}
{% endblock %}

0 comments on commit 4a380e9

Please sign in to comment.