diff --git a/packages/page-composer/lib/create-page-composer.js b/packages/page-composer/lib/create-page-composer.js index 53bfde07d5098714481951efd628260f851d374a..2e775792884e75b6df224b125a9cd493e33c4269 100644 --- a/packages/page-composer/lib/create-page-composer.js +++ b/packages/page-composer/lib/create-page-composer.js @@ -68,6 +68,8 @@ function createPageComposerInternal (siteModel, env, layouts) { * @returns {File} The file whose contents were wrapped in the specified page layout. */ return function composePage (file, contentCatalog, navigationCatalog) { + // eslint-disable-next-line no-prototype-builtins + if (file.asciidoc && file.asciidoc.attributes && !file.asciidoc.attributes['page-layout'] && file.asciidoc.attributes.hasOwnProperty('page-layout')) return file // QUESTION should we pass the playbook to the uiModel? const uiModel = buildUiModel(siteModel, file, contentCatalog, navigationCatalog, env) diff --git a/packages/page-composer/test/compose-page-test.js b/packages/page-composer/test/compose-page-test.js index f3aa43492e7d58bd6c71556749e1a15831cebaa7..76948eb4fbd0436edc57051837c95cc62562bdc6 100644 --- a/packages/page-composer/test/compose-page-test.js +++ b/packages/page-composer/test/compose-page-test.js @@ -392,6 +392,30 @@ describe('createPageComposer()', () => { expect(file.contents.toString()).to.include('') }) + it('should use no layout if layout is specified null', () => { + file.asciidoc.attributes['page-layout'] = null + const composePage = createPageComposer(playbook, contentCatalog, uiCatalog) + const originalContent = file.contents.toString() + composePage(file, contentCatalog, navigationCatalog) + expect(file.contents.toString()).to.equal(originalContent) + }) + + it('should use no layout if layout is specified undefined', () => { + file.asciidoc.attributes['page-layout'] = undefined + const composePage = createPageComposer(playbook, contentCatalog, uiCatalog) + const originalContent = file.contents.toString() + composePage(file, contentCatalog, navigationCatalog) + expect(file.contents.toString()).to.equal(originalContent) + }) + + it('should use no layout if layout is specified empty', () => { + file.asciidoc.attributes['page-layout'] = '' + const composePage = createPageComposer(playbook, contentCatalog, uiCatalog) + const originalContent = file.contents.toString() + composePage(file, contentCatalog, navigationCatalog) + expect(file.contents.toString()).to.equal(originalContent) + }) + // QUESTION should this be checked in the function generator? it('should throw an error if default layout cannot be found', () => { playbook.ui.defaultLayout = 'does-not-exist'