From e06ff2d08de9e2f8e64097df723c555159153c9c Mon Sep 17 00:00:00 2001 From: HerrHase Date: Sun, 19 Feb 2023 18:32:00 +0100 Subject: [PATCH] adding #4 --- src/engines/nunjucks.js | 8 ++++---- src/queries/blocks.js | 1 + src/siteomat.js | 12 ++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/engines/nunjucks.js b/src/engines/nunjucks.js index aaccfd8..a63308d 100644 --- a/src/engines/nunjucks.js +++ b/src/engines/nunjucks.js @@ -46,12 +46,12 @@ class Engine { }, true) // adding defaults for view, data from site.yml, functions and pageQuery - this._defaults = { + this._defaults = assign(this._options.defaults, { site: site, asset: asset, dayjs: dayjs, pageQuery: new PageQuery(configStore.get('source')) - } + }) } /** @@ -77,7 +77,7 @@ class Engine { const options = configStore.get('options') // if options minifyHtml is set, minify html, but only if page has type html - if (options.minifyHtml === true && data.page.type === 'html') { + if (options.minifyHtml === true && data.page.extensions === 'html') { response = minify(response, { removeComments: true, collapseWhitespace: true, @@ -96,4 +96,4 @@ class Engine { } -module.exports = Engine \ No newline at end of file +module.exports = Engine diff --git a/src/queries/blocks.js b/src/queries/blocks.js index d7f64df..878e57a 100644 --- a/src/queries/blocks.js +++ b/src/queries/blocks.js @@ -28,6 +28,7 @@ class Blocks { this._dirPath = dirPath + // if filename is not index.md add filename to path if (filename !== 'index.md') { this._dirPath += '/' + filename } diff --git a/src/siteomat.js b/src/siteomat.js index b17d11f..b4e6bfa 100644 --- a/src/siteomat.js +++ b/src/siteomat.js @@ -36,9 +36,15 @@ class Siteomat { throw new Error('Destination is undefined') } + this._options = assign({ + 'defaults': { + + } + }, options) + this._source = source this._views = views - this._destination = options.destination + this._destination = this._options.destination // fill singleton for configuration configStore.set('source', source) @@ -63,7 +69,9 @@ class Siteomat { configStore.set('site', this._site) - this._engine = new Engine(views, this._site) + this._engine = new Engine(views, this._site, { + 'defaults': this._options.defaults + }) } /**