develop
HerrHase 2 years ago
parent 86a7b7c790
commit 596bea5608

@ -1,7 +1,7 @@
const path = require('path') const path = require('path')
const fs = require('fs') const fs = require('fs')
const Media = require('./media.js') const Media = require('./../factories/media.js')
/** /**
* asset - checks manifest.json for given path and return * asset - checks manifest.json for given path and return
@ -13,7 +13,7 @@ const Media = require('./media.js')
*/ */
function asset(staticPath) { function asset(staticPath) {
// getting basePath // getting basePath
let result = staticPath let result = staticPath

@ -1,5 +1,4 @@
const nunjucks = require('nunjucks') const nunjucks = require('nunjucks')
const { minify } = require('html-minifier')
const fs = require('fs') const fs = require('fs')
const assign = require('assign-deep') const assign = require('assign-deep')
@ -69,18 +68,6 @@ class Engine {
data = assign({}, data, this._defaults) data = assign({}, data, this._defaults)
this.nunjucks.render(view, data, (error, response) => { 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) done(error, response)
}) })
} }

@ -1,12 +1,11 @@
const path = require('path') const path = require('path')
const fs = require('fs') const fs = require('fs')
const sharp = require('sharp') const sharp = require('sharp')
const mkdirp = require('mkdirp') const mkdirp = require('mkdirp')
const crypto = require('crypto') const crypto = require('crypto')
const slugify = require('slugify') 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} sizes
* @param {Object} [options={}] * @param {Object} [options={}]
* @return {string} * @return {string}
@ -75,7 +74,6 @@ class Media {
// change extension // change extension
this._extension = '.webp' this._extension = '.webp'
this._process this._process
.webp({ .webp({
lossless: true lossless: true
}) })

@ -1,6 +1,7 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const mkdirp = require('mkdirp') const mkdirp = require('mkdirp')
const { minify } = require('html-minifier')
const configStore = require('./config.js') const configStore = require('./config.js')
@ -80,6 +81,17 @@ class Siteomat {
return; 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 // create directories and write file = page
mkdirp(this._destination + page.pathname).then(() => { mkdirp(this._destination + page.pathname).then(() => {
fs.writeFileSync(this._destination + page.pathname + '/' + page.filename, content) fs.writeFileSync(this._destination + page.pathname + '/' + page.filename, content)

@ -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') const siteomat = new Siteomat('./example/site', './example/views', './public')
happySite.run() siteomat.run()
Loading…
Cancel
Save