diff options
Diffstat (limited to 'lib/json/encodePage.js')
-rw-r--r-- | lib/json/encodePage.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/json/encodePage.js b/lib/json/encodePage.js index d876c78..be92117 100644 --- a/lib/json/encodePage.js +++ b/lib/json/encodePage.js @@ -1,3 +1,5 @@ +var encodeSummaryArticle = require('./encodeSummaryArticle'); + /** Return a JSON representation of a page @@ -10,7 +12,6 @@ function encodePage(page, summary) { var attributes = page.getAttributes(); var article = summary.getByPath(file.getPath()); - var result = attributes.toJS(); if (article) { @@ -18,7 +19,15 @@ function encodePage(page, summary) { result.level = article.getLevel(); result.depth = article.getDepth(); - // todo: next and prev + var nextArticle = summary.getNextArticle(article); + if (nextArticle) { + result.next = encodeSummaryArticle(nextArticle); + } + + var prevArticle = summary.getPrevArticle(article); + if (prevArticle) { + result.previous = encodeSummaryArticle(prevArticle); + } } result.content = page.getContent(); |