diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-12-22 10:18:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-22 10:18:38 +0100 |
commit | 194ebc3da9641ff96f083f9d8ab43c2d27944f9a (patch) | |
tree | c50988f32ccf18df93ae7ab40be78e9459642818 /lib/api/encodeNavigation.js | |
parent | 64ccb6b00b4b63fa0e516d4e35351275b34f8c07 (diff) | |
parent | 16af264360e48e8a833e9efa9ab8d194574dbc70 (diff) | |
download | gitbook-194ebc3da9641ff96f083f9d8ab43c2d27944f9a.zip gitbook-194ebc3da9641ff96f083f9d8ab43c2d27944f9a.tar.gz gitbook-194ebc3da9641ff96f083f9d8ab43c2d27944f9a.tar.bz2 |
Merge pull request #1543 from GitbookIO/dream
React for rendering website with plugins
Diffstat (limited to 'lib/api/encodeNavigation.js')
-rw-r--r-- | lib/api/encodeNavigation.js | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/lib/api/encodeNavigation.js b/lib/api/encodeNavigation.js deleted file mode 100644 index 8e329a1..0000000 --- a/lib/api/encodeNavigation.js +++ /dev/null @@ -1,64 +0,0 @@ -var Immutable = require('immutable'); - -/** - Encode an article for next/prev - - @param {Map<String:Page>} - @param {Article} - @return {Object} -*/ -function encodeArticle(pages, article) { - var articlePath = article.getPath(); - - return { - path: articlePath, - title: article.getTitle(), - level: article.getLevel(), - exists: (articlePath && pages.has(articlePath)), - external: article.isExternal() - }; -} - -/** - this.navigation is a deprecated property from GitBook v2 - - @param {Output} - @return {Object} -*/ -function encodeNavigation(output) { - var book = output.getBook(); - var pages = output.getPages(); - var summary = book.getSummary(); - var articles = summary.getArticlesAsList(); - - - var navigation = articles - .map(function(article, i) { - var ref = article.getRef(); - if (!ref) { - return undefined; - } - - var prev = articles.get(i - 1); - var next = articles.get(i + 1); - - return [ - ref, - { - index: i, - title: article.getTitle(), - introduction: (i === 0), - prev: prev? encodeArticle(pages, prev) : undefined, - next: next? encodeArticle(pages, next) : undefined, - level: article.getLevel() - } - ]; - }) - .filter(function(e) { - return Boolean(e); - }); - - return Immutable.Map(navigation).toJS(); -} - -module.exports = encodeNavigation; |