chore(*): update theme revision and bundle assets

pull/701/head
ppoffice 2018-11-11 17:41:45 -05:00
parent 09aeb16a70
commit e07001a089
7 changed files with 165 additions and 81 deletions

View File

@ -89,4 +89,6 @@ marked:
gfm: false
githubEmojis:
className: not-gallery-item
className: not-gallery-item
all_minifier: true

156
package-lock.json generated
View File

@ -427,11 +427,18 @@
"integrity": "sha1-EQHpVE9KdrG8OybUUsqW16NeeXg="
},
"basic-auth": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz",
"integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz",
"integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==",
"requires": {
"safe-buffer": "5.1.1"
"safe-buffer": "5.1.2"
},
"dependencies": {
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
}
}
},
"bcrypt-pbkdf": {
@ -1930,13 +1937,11 @@
},
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"optional": true
"bundled": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -1949,18 +1954,15 @@
},
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"optional": true
"bundled": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"optional": true
"bundled": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"optional": true
"bundled": true
},
"core-util-is": {
"version": "1.0.2",
@ -2063,8 +2065,7 @@
},
"inherits": {
"version": "2.0.3",
"bundled": true,
"optional": true
"bundled": true
},
"ini": {
"version": "1.3.5",
@ -2074,7 +2075,6 @@
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -2087,20 +2087,17 @@
"minimatch": {
"version": "3.0.4",
"bundled": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"bundled": true,
"optional": true
"bundled": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@ -2117,7 +2114,6 @@
"mkdirp": {
"version": "0.5.1",
"bundled": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -2190,8 +2186,7 @@
},
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"optional": true
"bundled": true
},
"object-assign": {
"version": "4.1.1",
@ -2201,7 +2196,6 @@
"once": {
"version": "1.4.0",
"bundled": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -2307,7 +2301,6 @@
"string-width": {
"version": "1.0.2",
"bundled": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -4490,13 +4483,13 @@
}
},
"morgan": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz",
"integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=",
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz",
"integrity": "sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA==",
"requires": {
"basic-auth": "~2.0.0",
"debug": "2.6.9",
"depd": "~1.1.1",
"depd": "~1.1.2",
"on-finished": "~2.3.0",
"on-headers": "~1.0.1"
},
@ -7041,6 +7034,55 @@
"requires": {
"optimist": "~0.6",
"uglify-js": "2.6.0"
},
"dependencies": {
"camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk="
},
"cliui": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
"integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=",
"requires": {
"center-align": "^0.1.1",
"right-align": "^0.1.1",
"wordwrap": "0.0.2"
}
},
"uglify-js": {
"version": "2.6.0",
"resolved": "http://registry.npmjs.org/uglify-js/-/uglify-js-2.6.0.tgz",
"integrity": "sha1-JeqhzDVQ45QQzu+v0c+7a20V8AE=",
"requires": {
"async": "~0.2.6",
"source-map": "~0.5.1",
"uglify-to-browserify": "~1.0.0",
"yargs": "~3.10.0"
}
},
"window-size": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz",
"integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0="
},
"wordwrap": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
"integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8="
},
"yargs": {
"version": "3.10.0",
"resolved": "http://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
"integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=",
"requires": {
"camelcase": "^1.0.2",
"cliui": "^2.1.0",
"decamelize": "^1.0.0",
"window-size": "0.1.0"
}
}
}
},
"tar-stream": {
@ -7259,52 +7301,24 @@
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
"uglify-js": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.6.0.tgz",
"integrity": "sha1-JeqhzDVQ45QQzu+v0c+7a20V8AE=",
"uglify-es": {
"version": "3.3.9",
"resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz",
"integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==",
"requires": {
"async": "~0.2.6",
"source-map": "~0.5.1",
"uglify-to-browserify": "~1.0.0",
"yargs": "~3.10.0"
"commander": "~2.13.0",
"source-map": "~0.6.1"
},
"dependencies": {
"camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk="
"commander": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz",
"integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA=="
},
"cliui": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
"integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=",
"requires": {
"center-align": "^0.1.1",
"right-align": "^0.1.1",
"wordwrap": "0.0.2"
}
},
"window-size": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz",
"integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0="
},
"wordwrap": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
"integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8="
},
"yargs": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
"integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=",
"requires": {
"camelcase": "^1.0.2",
"cliui": "^2.1.0",
"decamelize": "^1.0.0",
"window-size": "0.1.0"
}
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
}
}
},

View File

@ -6,6 +6,7 @@
"version": "3.7.1"
},
"dependencies": {
"clean-css": "^4.2.1",
"hexo": "^3.7.1",
"hexo-all-minifier": "^0.5.2",
"hexo-deployer-git": "^0.3.1",
@ -18,6 +19,7 @@
"hexo-renderer-ejs": "^0.2.0",
"hexo-renderer-marked": "^0.2.10",
"hexo-renderer-stylus": "^0.3.1",
"hexo-server": "^0.2.0"
"hexo-server": "^0.2.0",
"uglify-es": "^3.3.9"
}
}

57
scripts/concat.js Normal file
View File

@ -0,0 +1,57 @@
const fs = require('fs');
const path = require('path');
const cheerio = require('cheerio');
const UglifyJS = require('uglify-es');
const CleanCSS = require('clean-css');
const root = path.join(__dirname, '../themes/icarus/source/');
function replaceWithBundled(html) {
const urlFor = hexo.extend.helper.get('url_for').bind(hexo);
const $ = cheerio.load(html, { decodeEntities: false });
$('script').each(function () {
const url = $(this).attr('src');
if (url && url.startsWith(urlFor('/js')) && url.endsWith('.js')) {
$(this).remove();
}
});
$('body').append(`<script src="${urlFor('/js/bundle.js')}" defer></script>`);
$('link[rel="stylesheet"]').each(function () {
const url = $(this).attr('href');
if (url && url.startsWith(urlFor('/css')) && url.endsWith('.css') && !url.endsWith('style.css')) {
$(this).remove();
}
});
$('head').append(`<link rel="stylesheet" href="${urlFor('/css/bundle.css')}">`);
return $.html();
}
hexo.extend.generator.register('bundle.js', function (locals) {
const folder = path.join(root, 'js');
const concated = fs.readdirSync(path.join(root, 'js'))
.filter(filename => filename.endsWith('.js'))
.map(filename => fs.readFileSync(path.join(folder, filename)))
.join('\n');
const result = UglifyJS.minify(concated);
return {
path: '/js/bundle.js',
data: result.code
};
});
hexo.extend.generator.register('bundle.css', function (locals) {
const folder = path.join(root, 'css');
const concated = fs.readdirSync(path.join(root, 'css'))
.filter(filename => filename.endsWith('.css'))
.map(filename => fs.readFileSync(path.join(folder, filename)))
.join('\n');
const result = new CleanCSS().minify(concated);
return {
path: '/css/bundle.css',
data: result.styles
};
});
hexo.extend.filter.register('after_render:html', function (content, data) {
return replaceWithBundled(content);
});

View File

@ -2,13 +2,7 @@ const cheerio = require('cheerio');
function fixStyle(content) {
const $ = cheerio.load(content, { decodeEntities: false });
$('body').append(`
<style>
#_hj_feedback_container *:after {
box-shadow: none !important;
}
</style>
`);
$('body').append(`<style>#_hj_feedback_container *:after {box-shadow: none !important;}</style>`);
return $.html();
}

15
scripts/inline-script.js Normal file
View File

@ -0,0 +1,15 @@
const cheerio = require('cheerio');
const UglifyJS = require('uglify-es');
hexo.extend.filter.register('after_render:html', function (content, data) {
const $ = cheerio.load(content, { decodeEntities: false });
$('script').each(function () {
const url = $(this).attr('src');
if (!url) {
$(this).html(UglifyJS.minify($(this).html()).code);
}
});
return $.html();
});

@ -1 +1 @@
Subproject commit b138ed3a8897be059ee94249db59c5ccf2c6181d
Subproject commit 8c356afb62f9253b1ec5267e101357ea23688972