|
|
@ -1,7 +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 assign = require('assign-deep')
|
|
|
|
|
|
|
|
|
|
|
|
const configStore = require('./config.js')
|
|
|
|
const configStore = require('./config.js')
|
|
|
|
|
|
|
|
|
|
|
@ -31,6 +31,11 @@ class Siteomat {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
constructor(source, views, options = {}) {
|
|
|
|
constructor(source, views, options = {}) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (options.destination === undefined) {
|
|
|
|
|
|
|
|
throw new Error('Destination is undefined')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._source = source
|
|
|
|
this._source = source
|
|
|
|
this._views = views
|
|
|
|
this._views = views
|
|
|
|
this._destination = options.destination
|
|
|
|
this._destination = options.destination
|
|
|
@ -39,7 +44,7 @@ class Siteomat {
|
|
|
|
configStore.set('source', source)
|
|
|
|
configStore.set('source', source)
|
|
|
|
configStore.set('destination', this._destination)
|
|
|
|
configStore.set('destination', this._destination)
|
|
|
|
configStore.set('views', views)
|
|
|
|
configStore.set('views', views)
|
|
|
|
configStore.set('options', Object.assign({}, {
|
|
|
|
configStore.set('options', assign({
|
|
|
|
'minifyHtml': true
|
|
|
|
'minifyHtml': true
|
|
|
|
}, options))
|
|
|
|
}, options))
|
|
|
|
|
|
|
|
|
|
|
@ -81,17 +86,6 @@ 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)
|
|
|
|