diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backbone/summary.js | 6 | ||||
-rw-r--r-- | lib/page/index.js | 1 |
2 files changed, 7 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; diff --git a/lib/page/index.js b/lib/page/index.js index 11cbb57..57b048d 100644 --- a/lib/page/index.js +++ b/lib/page/index.js @@ -122,6 +122,7 @@ Page.prototype.getContext = function() { next: next? next.getContext() : null, previous: prev? prev.getContext() : null, level: article? article.level : null, + depth: article? article.depth : 0, content: this.content, dir: dir } |