diff options
author | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-03-31 17:40:54 -0700 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-03-31 17:40:57 -0700 |
commit | abf8c59946b7e161792abd2306aca05e408a287a (patch) | |
tree | 41c7d8f1dcc97017ce66e8544d835a41f572dc73 | |
parent | 91a916e1468d8b775facb11c5b5c35dcb19d37d9 (diff) | |
download | gitbook-abf8c59946b7e161792abd2306aca05e408a287a.zip gitbook-abf8c59946b7e161792abd2306aca05e408a287a.tar.gz gitbook-abf8c59946b7e161792abd2306aca05e408a287a.tar.bz2 |
Improve navigation from 1st chapter back to intro
1st chapter’s prev, now links to the intro page
-rw-r--r-- | lib/parse/navigation.js | 8 | ||||
-rw-r--r-- | test/navigation.js | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/parse/navigation.js b/lib/parse/navigation.js index 52f3028..3140a1a 100644 --- a/lib/parse/navigation.js +++ b/lib/parse/navigation.js @@ -23,10 +23,16 @@ function navigation(summary, files) { // Mapping of prev/next for a give path var mapping = {}; + // Special README nav + var README_NAV = { + path: 'README.html', + title: 'Introdunction', + }; + // Walk the chapter/article tree and create navigation entires _.each(summary.chapters, function(chapter, idx, chapters) { var currentChapter = clean(chapter); - var prevChapter = (idx-1 < 0) ? null : chapters[idx-1]; + var prevChapter = (idx-1 < 0) ? README_NAV : chapters[idx-1]; var nextChapter = (idx+1 >= chapters.length) ? null : chapters[idx+1]; var prev = (!prevChapter || _.isEmpty(prevChapter.articles)) ? diff --git a/test/navigation.js b/test/navigation.js index 4ed2c04..9cc5745 100644 --- a/test/navigation.js +++ b/test/navigation.js @@ -31,7 +31,7 @@ describe('Summary navigation', function() { assert.equal(nav['README.html'].prev, null); assert.equal(nav['README.html'].next.path, 'chapter-1/README.html'); - assert.equal(nav['chapter-1/README.html'].prev, null); + assert.equal(nav['chapter-1/README.html'].prev.path, 'README.html'); assert.equal(nav['chapter-1/README.html'].next.path, 'chapter-1/ARTICLE1.html'); assert.equal(nav['chapter-1/ARTICLE1.html'].prev.path, 'chapter-1/README.html'); |