diff options
-rw-r--r-- | lib/book.js | 8 | ||||
-rw-r--r-- | test/page.js | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/book.js b/lib/book.js index cbb85c0..c81d255 100644 --- a/lib/book.js +++ b/lib/book.js @@ -196,9 +196,13 @@ Book.prototype.parse = function() { // Parse the readme .then(that.readme.load) .then(function() { - if (that.readme.exists()) return; + if (!that.readme.exists()) { + throw new error.FileNotFoundError({ filename: 'README' }); + } - throw new error.FileNotFoundError({ filename: 'README' }); + // Default configuration to infos extracted from readme + if (!that.config.get('title')) that.config.set('title', that.readme.title); + if (!that.config.get('description')) that.config.set('description', that.readme.description); }) // Parse the summary diff --git a/test/page.js b/test/page.js index 9afec1c..8eb2096 100644 --- a/test/page.js +++ b/test/page.js @@ -6,6 +6,7 @@ describe('Page', function() { before(function() { return mock.setupDefaultBook({ + 'README.md': ' # Hello World\n\nThis is a description', 'heading.md': '# Hello\n\n## World', 'links.md': '[link](hello.md) [link 2](variables/page/next.md) [readme](README.md)', @@ -31,6 +32,7 @@ describe('Page', function() { 'variables/page/next.md': '{{ page.next.title }} {{ page.next.path }}', 'variables/page/dir/ltr.md': 'This is english: {{ page.dir }}', 'variables/page/dir/rtl.md': 'بسيطة {{ page.dir }}', + 'variables/book/title.md': '{{ book.title}}', 'GLOSSARY.md': '# Glossary\n\n\n## abracadabra\n\nthis is the description' }, [ @@ -315,6 +317,12 @@ describe('Page', function() { .should.be.fulfilledWith('<p>Test Variables variables/page/title.md</p>\n'); }); + it('should set book.title', function() { + var page = book.addPage('variables/book/title.md'); + return page.toHTML(output) + .should.be.fulfilledWith('<p>Hello World</p>\n'); + }); + describe('page.dir', function() { it('should detect ltr', function() { var page = book.addPage('variables/page/dir/ltr.md'); |