diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-05-12 16:29:36 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-05-12 16:29:36 +0200 |
commit | 53c72f08061094d895b3e81964ff2d2944a6d6a9 (patch) | |
tree | af832a31b4f41c8d59dbca4e55635d3bf5b26094 /lib/api | |
parent | c8c2a61f966a5f99e41bfc316fe91141536f1483 (diff) | |
download | gitbook-53c72f08061094d895b3e81964ff2d2944a6d6a9.zip gitbook-53c72f08061094d895b3e81964ff2d2944a6d6a9.tar.gz gitbook-53c72f08061094d895b3e81964ff2d2944a6d6a9.tar.bz2 |
Add api method getPageByPath for plugins
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/encodeGlobal.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/api/encodeGlobal.js b/lib/api/encodeGlobal.js index f7ca649..ffd0e8f 100644 --- a/lib/api/encodeGlobal.js +++ b/lib/api/encodeGlobal.js @@ -12,6 +12,7 @@ var gitbook = require('../gitbook'); var encodeConfig = require('./encodeConfig'); var encodeSummary = require('./encodeSummary'); var encodeNavigation = require('./encodeNavigation'); +var encodePage = require('./encodePage'); /** Encode a global context into a JS object @@ -81,6 +82,19 @@ function encodeGlobal(output) { return path.resolve(book.getContentRoot(), fileName); }, + /** + Resolve a page by it path + + @param {String} filePath + @return {String} + */ + getPageByPath: function(filePath) { + var page = output.getPage(filePath); + if (!page) return undefined; + + return encodePage(output, page); + }, + template: { /** Apply a templating block and returns its result |