summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/generate/index.js2
-rw-r--r--lib/parse/navigation.js2
-rw-r--r--test/fixtures/SUMMARY.md1
-rw-r--r--test/navigation.js14
4 files changed, 15 insertions, 4 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js
index 8bb7052..6b75dea 100644
--- a/lib/generate/index.js
+++ b/lib/generate/index.js
@@ -238,7 +238,7 @@ var generateBook = function(options) {
return loadGenerator(options);
})
- // Detect multi-languages book
+ // Convert files
.then(function(generator) {
// Generate the book
return Q()
diff --git a/lib/parse/navigation.js b/lib/parse/navigation.js
index 2f8669e..2c783e4 100644
--- a/lib/parse/navigation.js
+++ b/lib/parse/navigation.js
@@ -8,7 +8,7 @@ function clean(obj) {
function flattenChapters(chapters) {
return _.reduce(chapters, function(accu, chapter) {
- return accu.concat([clean(chapter)].concat(chapter.articles));
+ return accu.concat([clean(chapter)].concat(flattenChapters(chapter.articles)));
}, []);
}
diff --git a/test/fixtures/SUMMARY.md b/test/fixtures/SUMMARY.md
index 1145025..8418f1e 100644
--- a/test/fixtures/SUMMARY.md
+++ b/test/fixtures/SUMMARY.md
@@ -4,6 +4,7 @@
* [Article 1](chapter-1/ARTICLE1.md)
* [Article 2](chapter-1/ARTICLE2.md)
* [article 1.2.1](chapter-1/ARTICLE-1-2-1.md)
+ * [article 1.2.2](chapter-1/ARTICLE-1-2-2.md)
* [Chapter 2](chapter-2/README.md)
* [Chapter 3](chapter-3/README.md)
* [Chapter 4](chapter-4/README.md)
diff --git a/test/navigation.js b/test/navigation.js
index b0e5b98..0330d74 100644
--- a/test/navigation.js
+++ b/test/navigation.js
@@ -18,6 +18,8 @@ describe('Summary navigation', function() {
'chapter-1/ARTICLE1.md',
'chapter-1/ARTICLE2.md',
'chapter-2/README.md',
+ 'chapter-1/ARTICLE-1-2-1.md',
+ 'chapter-1/ARTICLE-1-2-2.md'
]);
// Make sure it found the files we gave it
@@ -26,6 +28,8 @@ describe('Summary navigation', function() {
assert(nav['chapter-1/ARTICLE1.md']);
assert(nav['chapter-1/ARTICLE2.md']);
assert(nav['chapter-2/README.md']);
+ assert(nav['chapter-1/ARTICLE-1-2-1.md']);
+ assert(nav['chapter-1/ARTICLE-1-2-2.md']);
assert.equal(nav['README.md'].prev, null);
@@ -38,9 +42,15 @@ describe('Summary navigation', function() {
assert.equal(nav['chapter-1/ARTICLE1.md'].next.path, 'chapter-1/ARTICLE2.md');
assert.equal(nav['chapter-1/ARTICLE2.md'].prev.path, 'chapter-1/ARTICLE1.md');
- assert.equal(nav['chapter-1/ARTICLE2.md'].next.path, 'chapter-2/README.md');
+ assert.equal(nav['chapter-1/ARTICLE2.md'].next.path, 'chapter-1/ARTICLE-1-2-1.md');
- assert.equal(nav['chapter-2/README.md'].prev.path, 'chapter-1/ARTICLE2.md');
+ assert.equal(nav['chapter-1/ARTICLE-1-2-1.md'].prev.path, 'chapter-1/ARTICLE2.md');
+ assert.equal(nav['chapter-1/ARTICLE-1-2-1.md'].next.path, 'chapter-1/ARTICLE-1-2-2.md');
+
+ assert.equal(nav['chapter-1/ARTICLE-1-2-2.md'].prev.path, 'chapter-1/ARTICLE-1-2-1.md');
+ assert.equal(nav['chapter-1/ARTICLE-1-2-2.md'].next.path, 'chapter-2/README.md');
+
+ assert.equal(nav['chapter-2/README.md'].prev.path, 'chapter-1/ARTICLE-1-2-2.md');
assert.equal(nav['chapter-2/README.md'].next.path, 'chapter-3/README.md');
});