summaryrefslogtreecommitdiffstats
path: root/lib/models
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-05-12 15:12:08 +0200
committerSamy Pessé <samypesse@gmail.com>2016-05-12 15:12:08 +0200
commit2e74fafa36c35c11148c09d4745402f23c53c1f8 (patch)
treef620a2c1dc056af4ff3e61b60c3ec53ed99571c7 /lib/models
parent28ac9ab88a009711837c379c3b18ab7f901299c6 (diff)
downloadgitbook-2e74fafa36c35c11148c09d4745402f23c53c1f8.zip
gitbook-2e74fafa36c35c11148c09d4745402f23c53c1f8.tar.gz
gitbook-2e74fafa36c35c11148c09d4745402f23c53c1f8.tar.bz2
Add template method "getPageByPath"
Diffstat (limited to 'lib/models')
-rw-r--r--lib/models/output.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/models/output.js b/lib/models/output.js
index 43e36f8..0f008ec 100644
--- a/lib/models/output.js
+++ b/lib/models/output.js
@@ -1,6 +1,7 @@
var Immutable = require('immutable');
var Book = require('./book');
+var LocationUtils = require('../utils/location');
var Output = Immutable.Record({
book: Book(),
@@ -53,6 +54,19 @@ Output.prototype.getState = function() {
};
/**
+ Return a page byt its file path
+
+ @param {String} filePath
+ @return {Page|undefined}
+*/
+Output.prototype.getPage = function(filePath) {
+ filePath = LocationUtils.normalize(filePath);
+
+ var pages = this.getPages();
+ return pages.get(filePath);
+};
+
+/**
Get root folder for output
@return {String}