summaryrefslogtreecommitdiffstats
path: root/lib/api/encodeNavigation.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-09-05 11:04:18 +0200
committerSamy Pessé <samypesse@gmail.com>2016-09-05 11:04:18 +0200
commita14ca3e268e95a7eab59fb205b41da7331d57631 (patch)
tree9c84b2cbd561345335fca3e26af961b2ea23d8ec /lib/api/encodeNavigation.js
parent9c071dade573aa6990878006f83c89b6065a1395 (diff)
downloadgitbook-a14ca3e268e95a7eab59fb205b41da7331d57631.zip
gitbook-a14ca3e268e95a7eab59fb205b41da7331d57631.tar.gz
gitbook-a14ca3e268e95a7eab59fb205b41da7331d57631.tar.bz2
Switch to lerna
Diffstat (limited to 'lib/api/encodeNavigation.js')
-rw-r--r--lib/api/encodeNavigation.js64
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;