Fix error when chapters list is empty

Fix GitbookIO/gitbook.io#101 and GitbookIO/gitbook.io#102