From a0a580002416d831034e7ed75fc6c9006491e88e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=93=E5=8F=91=E5=8F=97=E9=95=BF=E7=94=9F?= Date: Sat, 11 May 2019 00:47:37 +0800 Subject: [PATCH] =?UTF-8?q?html=E5=8E=8B=E7=BC=A9+=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + gulpfile.js | 71 + image_sync/image_synchronize.js | 135 + image_sync/list_images.js | 41 + package-lock.json | 3923 ------------------ package.json | 9 +- themes/yilia/source-src/css/core/_reset.scss | 14 +- themes/yilia/source-src/css/highlight.scss | 73 +- yarn.lock | 1465 ++++++- 9 files changed, 1743 insertions(+), 3990 deletions(-) create mode 100644 gulpfile.js create mode 100644 image_sync/image_synchronize.js create mode 100644 image_sync/list_images.js delete mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore index d4babe9..1964dfb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,12 @@ .DS_Store Thumbs.db db.json +package-lock.json *.log node_modules/ public/ .deploy*/ + # 主题构建生成的目标文件 themes/yilia/source/css/ themes/yilia/source/js/ diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..e63a1af --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,71 @@ +const gulp = require('gulp'), + htmlmin = require('gulp-htmlmin'), //html压缩组件 + htmlclean = require('gulp-htmlclean'), //html清理组件 + plumber = require('gulp-plumber'), //容错组件(发生错误不跳出任务,并报出错误内容) + Hexo = require('hexo') + +const hexo = new Hexo(process.cwd(), {}) + +// 创建静态页面 (等同 hexo generate) +gulp.task('generate', async function() { + try { + await hexo.init() + await hexo.call('clean') + await hexo.call('generate', { watch: false }) + return hexo.exit() + } + catch (err) { + return hexo.exit(err) + } +}) + +// 压缩public目录下的html文件 +gulp.task('compressHtml', () => { + const cleanOptions = { + protect: /<\!--%fooTemplate\b.*?%-->/g, //忽略处理 + unprotect: /