From 596bea5608f6ffe116faa16fa820fe999d63c04f Mon Sep 17 00:00:00 2001 From: HerrHase Date: Mon, 28 Nov 2022 23:25:49 +0100 Subject: [PATCH] adding --- src/engines/helpers.js | 4 ++-- src/engines/nunjucks.js | 13 ------------- src/factories/media.js | 6 ++---- src/siteomat.js | 12 ++++++++++++ test.js | 6 +++--- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/engines/helpers.js b/src/engines/helpers.js index 9d171dc..fba26db 100644 --- a/src/engines/helpers.js +++ b/src/engines/helpers.js @@ -1,7 +1,7 @@ const path = require('path') const fs = require('fs') -const Media = require('./media.js') +const Media = require('./../factories/media.js') /** * asset - checks manifest.json for given path and return @@ -13,7 +13,7 @@ const Media = require('./media.js') */ function asset(staticPath) { - + // getting basePath let result = staticPath diff --git a/src/engines/nunjucks.js b/src/engines/nunjucks.js index 4056bcc..7ac9e70 100644 --- a/src/engines/nunjucks.js +++ b/src/engines/nunjucks.js @@ -1,5 +1,4 @@ const nunjucks = require('nunjucks') -const { minify } = require('html-minifier') const fs = require('fs') const assign = require('assign-deep') @@ -69,18 +68,6 @@ class Engine { data = assign({}, data, this._defaults) this.nunjucks.render(view, data, (error, response) => { - - const options = configStore.get('options') - - // if options minifyHtml is set, minify html - if (options.minifyHtml === true) { - response = minify(response, { - removeComments: true, - collapseWhitespace: true, - collapseInlineTagWhitespace: true - }) - } - done(error, response) }) } diff --git a/src/factories/media.js b/src/factories/media.js index ef5b90e..9fe420f 100644 --- a/src/factories/media.js +++ b/src/factories/media.js @@ -1,12 +1,11 @@ const path = require('path') const fs = require('fs') - const sharp = require('sharp') const mkdirp = require('mkdirp') const crypto = require('crypto') const slugify = require('slugify') -const configStore = require('./config.js') +const configStore = require('./../config.js') /** * @@ -20,7 +19,7 @@ class Media { /** * - * @param {string} srcPath + * @param {string} src * @param {object} sizes * @param {Object} [options={}] * @return {string} @@ -75,7 +74,6 @@ class Media { // change extension this._extension = '.webp' this._process - .webp({ lossless: true }) diff --git a/src/siteomat.js b/src/siteomat.js index 3f05e9c..0973cae 100644 --- a/src/siteomat.js +++ b/src/siteomat.js @@ -1,6 +1,7 @@ const fs = require('fs') const path = require('path') const mkdirp = require('mkdirp') +const { minify } = require('html-minifier') const configStore = require('./config.js') @@ -80,6 +81,17 @@ class Siteomat { return; } + const options = configStore.get('options') + + // if options minifyHtml is set, minify html + if (options.minifyHtml === true) { + content = minify(content, { + removeComments: true, + collapseWhitespace: true, + collapseInlineTagWhitespace: true + }) + } + // create directories and write file = page mkdirp(this._destination + page.pathname).then(() => { fs.writeFileSync(this._destination + page.pathname + '/' + page.filename, content) diff --git a/test.js b/test.js index 39881b3..521e49e 100644 --- a/test.js +++ b/test.js @@ -1,4 +1,4 @@ -const HappySite = require('./src/happySite.js') +const Siteomat = require('./src/siteomat.js') -const happySite = new HappySite('./example/site', './example/views', './public') -happySite.run() \ No newline at end of file +const siteomat = new Siteomat('./example/site', './example/views', './public') +siteomat.run() \ No newline at end of file