Skip to content

Commit

Permalink
bypassed hero-cli, wrote own init script and set parts of config dyna…
Browse files Browse the repository at this point in the history
…mically, and fixed busted django file
  • Loading branch information
brian-mann committed Sep 9, 2017
1 parent 81c548a commit 214af21
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 76 deletions.
38 changes: 0 additions & 38 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ language: en

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://docs.cypress.io
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
Expand Down Expand Up @@ -163,40 +162,3 @@ marked:
autolink: false
## https://github.com/hexojs/hexo-renderer-markdown-it
# markdown: 'default'

## https://github.com/mamboer/hexo-filter-cleanup
hfc_useref:
enable: true
concat: true
exclude:
hfc_html:
enable: false
exclude:
hfc_css:
enable: true
exclude:
- '*.min.css'
hfc_js:
enable: true
mangle: true
output:
compress:
exclude:
- '*.min.js'
hfc_img:
enable: true
interlaced: false
multipass: false
optimizationLevel: 2
pngquant: false
progressive: false
webp: true
webpQuality: 75
gifslice: true
jpegtran: true
jpegrecompress: false
jpegrecompressQuality: 'medium'
optipng: true
svgo: false
hfc_favicons:
enable: false
100 changes: 99 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,102 @@ process.on('unhandledRejection', function (reason, p) {
process.exit(-1)
});

require('hexo-cli')();
const fs = require('fs')
const path = require('path')
const Hexo = require('hexo')
const chalk = require('chalk')
const minimist = require('minimist')

const args = minimist(process.argv.slice(2))

const cmd = args._.shift()

const hexo = new Hexo(process.cwd(), {})

function initHexo () {
// defaults outside of _config.yml
Object.assign(hexo.config, {
hfc_useref: { enable: true, concat: true, exclude: null },
hfc_html: { enable: false, exclude: null },
hfc_css: { enable: true, exclude: ['*.min.css'] },
hfc_favicons: { enable: false },
hfc_js: {
enable: true,
mangle: true,
output: null,
compress: null,
exclude: ['*.min.js'],
},
hfc_img: {
enable: true,
interlaced: false,
multipass: false,
optimizationLevel: 2,
pngquant: false,
progressive: false,
webp: true,
webpQuality: 75,
gifslice: true,
jpegtran: true,
jpegrecompress: false,
jpegrecompressQuality: 'medium',
optipng: true,
svgo: false,
},
})

// hexo does this weird thing where it literally sets
// an 'env' property on the 'env' object
// so we take that into account (and any other way its set)
const env = hexo.env.NODE_ENV || hexo.env.env || process.env.NODE_ENV || 'development'

// https://github.com/mamboer/hexo-filter-cleanup
// only run the filter_cleanup if we are in
// production mode -- deploying static asset
// this will combine multiple JS files into single "application.js"
// note that --debug mode in hexo disables clean up automatically
if (env !== 'production' && env !== 'staging') {
console.log('disabling filter cleanup for environment', env)
hexo.config.filter_cleanup = false
}

let url

if (env === 'staging') {
url = 'https://docs-staging.cypress.io'
} else {
url = 'https://docs.cypress.io'
}

console.log('in environment %s site url is %s', env, url)
hexo.config.url = url

// set this on both our process + hexo
process.env.NODE_ENV = hexo.env.NODE_ENV = env

console.log('NODE_ENV is:', chalk.cyan(env))

return hexo.init()
.then(() => {
return hexo.call(cmd, args)
})

}

const pathToBustedDjango = path.resolve('node_modules', 'prismjs', 'components', 'prism-django.js')

const pathToBustedDjangoMin = path.resolve('node_modules', 'prismjs', 'components', 'prism-django.min.js')

try {
fs.unlinkSync(pathToBustedDjango)
} catch (err) {
// noop
}

try {
fs.unlinkSync(pathToBustedDjangoMin)
} catch (err) {
// noop
}

return initHexo()
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"hexo-filter-cleanup": "1.0.7",
"hexo-generator-alias": "0.1.3",
"hexo-generator-seo-friendly-sitemap": "0.0.20",
"hexo-prism-plugin": "^2.2.0",
"hexo-prism-plugin": "2.2.0",
"hexo-renderer-marked": "0.3.0",
"hexo-renderer-scss": "1.0.2",
"hexo-server": "0.2.0",
Expand Down
36 changes: 0 additions & 36 deletions scripts/config.js

This file was deleted.

0 comments on commit 214af21

Please sign in to comment.