summaryrefslogtreecommitdiffstats
path: root/lib/generate
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generate')
-rw-r--r--lib/generate/plugin.js22
-rw-r--r--lib/generate/site/index.js4
2 files changed, 21 insertions, 5 deletions
diff --git a/lib/generate/plugin.js b/lib/generate/plugin.js
index ff94483..ca34923 100644
--- a/lib/generate/plugin.js
+++ b/lib/generate/plugin.js
@@ -65,7 +65,7 @@ Plugin.prototype.normalizeResource = function(resource) {
};
// Return resources
-Plugin.prototype.getResources = function() {
+Plugin.prototype._getResources = function() {
var book = this.infos.book;
// Nothing specified, fallback to default
@@ -80,7 +80,24 @@ Plugin.prototype.getResources = function() {
}
// Plain data object
- return Q(book);
+ return Q(_.cloneDeep(book));
+};
+
+// Normalize resources and return them
+Plugin.prototype.getResources = function() {
+ var that = this;
+
+
+
+ return this._getResources()
+ .then(function(resources) {
+
+ _.each(RESOURCES, function(resourceType) {
+ resources[resourceType] = (resources[resourceType] || []).map(that.normalizeResource);
+ });
+
+ return resources;
+ });
};
// Test if it's a valid plugin
@@ -165,7 +182,6 @@ Plugin.normalizeNames = function(names) {
// Extract data from a list of plugin
Plugin.fromList = function(names, root, generator) {
- var that = this;
var failed = [];
// Load plugins
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index bd1da53..73765ae 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -202,12 +202,12 @@ Generator.prototype.copyAssets = function() {
return plugin.copyAssets(pluginAssets)
.then(function(copiedStuff) {
// Nothing was copied
- if(!copiedStuff) return;
+ if(!copiedStuff) { return; }
return that.manifest.addFolder(pluginAssets, "gitbook/plugins/"+plugin.name);
});
})
);
- })
+ });
};
// Dump search index to disk