summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-25 14:50:58 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-25 14:50:58 +0100
commitb240d6a8fcbab80ea35da8cee58576f674ea1821 (patch)
tree0322ec1bc4997b5e48322e3854fbb4ff2d28f322
parent3cda0643fb95806aff16f1b32633763e90437e1b (diff)
downloadgitbook-b240d6a8fcbab80ea35da8cee58576f674ea1821.zip
gitbook-b240d6a8fcbab80ea35da8cee58576f674ea1821.tar.gz
gitbook-b240d6a8fcbab80ea35da8cee58576f674ea1821.tar.bz2
Add filter fileExists
-rw-r--r--lib/output/website.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/output/website.js b/lib/output/website.js
index 0beef24..230af71 100644
--- a/lib/output/website.js
+++ b/lib/output/website.js
@@ -110,6 +110,11 @@ WebsiteOutput.prototype.prepare = function() {
return location.normalize(that.resolveForPage(this.ctx.file.path, href));
});
+ // Test if a file exists
+ that.env.addFilter('fileExists', function(href) {
+ return fs.existsSync(that.resolve(href));
+ });
+
// Transform a '.md' into a '.html' (README -> index)
that.env.addFilter('contentURL', function(s) {
return location.normalize(that.outputUrl(s));