summaryrefslogtreecommitdiffstats
path: root/lib/backbone/summary.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-24 17:19:52 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-24 17:19:52 +0100
commit52eccb29e49f2199cbd73f522de47a7bd764c7dd (patch)
tree6be72bce0a06533a1a1ef249057132f91f6e74b4 /lib/backbone/summary.js
parent86e4a935e2956e0929b273aece04bea528d1cf4e (diff)
downloadgitbook-52eccb29e49f2199cbd73f522de47a7bd764c7dd.zip
gitbook-52eccb29e49f2199cbd73f522de47a7bd764c7dd.tar.gz
gitbook-52eccb29e49f2199cbd73f522de47a7bd764c7dd.tar.bz2
Add property depth to article and pages
Diffstat (limited to 'lib/backbone/summary.js')
-rw-r--r--lib/backbone/summary.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/backbone/summary.js b/lib/backbone/summary.js
index 439546b..4ae3453 100644
--- a/lib/backbone/summary.js
+++ b/lib/backbone/summary.js
@@ -74,6 +74,7 @@ TOCArticle.prototype.getContext = function() {
return {
level: this.level,
title: this.title,
+ depth: this.depth(),
path: this.isExternal()? undefined : this.path,
anchor: this.isExternal()? undefined : this.anchor,
url: this.isExternal()? this.ref : undefined
@@ -105,6 +106,11 @@ TOCArticle.prototype.hasParent = function() {
return !(this.parent instanceof TOCPart);
};
+// Return depth of this article
+TOCArticle.prototype.depth = function() {
+ return this.level.split('.').length;
+};
+
// Return next article in the TOC
TOCArticle.prototype.next = function() {
return this._next;