File tree Expand file tree Collapse file tree 4 files changed +20
-15
lines changed Expand file tree Collapse file tree 4 files changed +20
-15
lines changed Original file line number Diff line number Diff line change 22'use strict' ;
33
44const Hexo = require ( 'hexo' ) ;
5- let hexo = new Hexo ( `${ process . cwd ( ) } ` , {
6- //debug: true
7- } ) ;
5+ const YAML = require ( 'js-yaml' ) ;
6+ const cwd = process . cwd ( ) ;
7+ const fs = require ( 'fs' ) ;
8+
9+ exports . hexo = new Hexo ( cwd ) ;
10+
11+ exports . config = YAML . safeLoad (
12+ fs . readFileSync ( `${ cwd } /_config.yml` , 'utf8' )
13+ ) ;
814
9- exports . hexo = hexo ;
Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22'use strict' ;
33
4- let hexo = require ( './hexo ' ) . hexo ;
5- let browserSync = require ( 'browser-sync' ) . create ( ) ;
4+ const browserSync = require ( 'browser-sync ' ) . create ( ) ;
5+ const { hexo , config } = require ( './hexo' ) ;
66
77function initServer ( ) {
8- let publicDir = 'public' ;
8+ const serverRoutes = { }
9+
10+ // account for Hexo "root" configuration
11+ serverRoutes [ `${ config . root } ` ] = config . public_dir ;
912
1013 browserSync . init ( {
1114 files : [ // (See 'watchEvents')
12- `${ publicDir } /**/*` ,
15+ `${ config . public_dir } /**/*` ,
1316 {
1417 match : [
1518 'source/**/*' ,
@@ -26,10 +29,8 @@ function initServer () {
2629 reloadOnRestart : true ,
2730 reloadDebounce : 250 , // prevent calling numerous reloads on forced hexo generate
2831 server : {
29- baseDir : publicDir ,
30- routes : {
31- '/helix-ui/' : publicDir // account for Hexo "root" configuration
32- }
32+ baseDir : config . public_dir ,
33+ routes : serverRoutes
3334 } ,
3435 watchEvents : [ 'change' ]
3536 } ) ;
@@ -46,5 +47,3 @@ hexo.init().then(() => {
4647 hexo . exit ( err ) ;
4748 } ) ;
4849} ) ; //hexo.init()
49-
50- // TODO: "release" task to generate, copy, and minify CSS assets
Original file line number Diff line number Diff line change 1919 "gulp" : " 3.x" ,
2020 "gulp-bump" : " 2.x" ,
2121 "gulp-load-plugins" : " 1.5.0" ,
22+ "js-yaml" : " ^3.9.1" ,
2223 "less" : " 2.x" ,
2324 "less-plugin-clean-css" : " ^1.5.1" ,
2425 "lodash" : " 4.x"
Original file line number Diff line number Diff line change @@ -1885,7 +1885,7 @@ js-tokens@^3.0.0:
18851885 version "3.0.2"
18861886 resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
18871887
1888- js-yaml@^3.6.1 :
1888+ js-yaml@^3.6.1, js-yaml@^3.9.1 :
18891889 version "3.9.1"
18901890 resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.9.1.tgz#08775cebdfdd359209f0d2acd383c8f86a6904a0"
18911891 dependencies :
You can’t perform that action at this time.
0 commit comments