diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-06-24 12:34:29 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-06-24 12:34:29 +0200 |
commit | 8b6a80cffbb991db70687cf226bcf71f6a7740d8 (patch) | |
tree | a9caa4884b9fcd6273cf1998fcc8507c19465878 /lib/parse | |
parent | 86f8a9d8fb96de82912d5a5c52f1d0c56a932b53 (diff) | |
download | gitbook-8b6a80cffbb991db70687cf226bcf71f6a7740d8.zip gitbook-8b6a80cffbb991db70687cf226bcf71f6a7740d8.tar.gz gitbook-8b6a80cffbb991db70687cf226bcf71f6a7740d8.tar.bz2 |
Fix error when chapters list is empty
Fix GitbookIO/gitbook.io#101 and GitbookIO/gitbook.io#102
Diffstat (limited to 'lib/parse')
-rw-r--r-- | lib/parse/summary.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/parse/summary.js b/lib/parse/summary.js index 7746f10..fd300bc 100644 --- a/lib/parse/summary.js +++ b/lib/parse/summary.js @@ -100,11 +100,13 @@ function parseChapter(nodes, nums) { function defaultChapterList(chapterList) { var first = _.first(chapterList); - var chapter = parseChapter(first, [0]); + if (first) { + var chapter = parseChapter(first, [0]); - // Already have README node, we're good to go - if(chapter.path === 'README.md') { - return chapterList; + // Already have README node, we're good to go + if(chapter.path === 'README.md') { + return chapterList; + } } return [ |