diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backbone/summary.js | 8 | ||||
-rw-r--r-- | lib/page/index.js | 6 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/backbone/summary.js b/lib/backbone/summary.js index f4b9288..cef3ae9 100644 --- a/lib/backbone/summary.js +++ b/lib/backbone/summary.js @@ -41,6 +41,14 @@ TOCArticle.prototype.walk = function(iter) { }); }; +// Return templating context for an article +TOCArticle.prototype.getContext = function() { + return { + title: this.title, + path: this.path + }; +}; + // Return true if is pointing to a file TOCArticle.prototype.hasLocation = function() { return Boolean(this.path); diff --git a/lib/page/index.js b/lib/page/index.js index 54255dd..b3ff00f 100644 --- a/lib/page/index.js +++ b/lib/page/index.js @@ -107,6 +107,8 @@ Page.prototype.read = function() { // This is used both for themes and page parsing Page.prototype.getContext = function() { var article = this.book.summary.getArticle(this); + var next = article? article.next() : null; + var prev = article? article.prev() : null; return { file: { @@ -115,8 +117,8 @@ Page.prototype.getContext = function() { }, page: { title: article? article.title : null, - next: article? article.next() : null, - previous: article? article.prev() : null + next: next? next.getContext() : null, + previous: prev? prev.getContext() : null } }; }; |