mirror of https://github.com/curbengh/hexo-yam
refactor: destructure object
This commit is contained in:
parent
7085b15d10
commit
fd474580ce
|
@ -28,9 +28,8 @@ function minifyHtml (str, data) {
|
||||||
// Return if disabled.
|
// Return if disabled.
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
const path = data.path
|
const { path } = data
|
||||||
const exclude = options.exclude
|
const { exclude, globOptions } = options
|
||||||
const globOptions = options.globOptions
|
|
||||||
|
|
||||||
let excludeString = exclude || ''
|
let excludeString = exclude || ''
|
||||||
if (Array.isArray(exclude)) excludeString = exclude.join('')
|
if (Array.isArray(exclude)) excludeString = exclude.join('')
|
||||||
|
@ -50,9 +49,8 @@ function minifyCss (str, data) {
|
||||||
const options = hexo.config.minify.css
|
const options = hexo.config.minify.css
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
const path = data.path
|
const { path } = data
|
||||||
const exclude = options.exclude
|
const { exclude, globOptions } = options
|
||||||
const globOptions = options.globOptions
|
|
||||||
|
|
||||||
let excludeString = exclude || ''
|
let excludeString = exclude || ''
|
||||||
if (exclude && Array.isArray(exclude)) excludeString = exclude.join('')
|
if (exclude && Array.isArray(exclude)) excludeString = exclude.join('')
|
||||||
|
@ -74,9 +72,8 @@ function minifyJs (str, data) {
|
||||||
const options = hexo.config.minify.js
|
const options = hexo.config.minify.js
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
const path = data.path
|
const { path } = data
|
||||||
const exclude = options.exclude
|
const { exclude, globOptions } = options
|
||||||
const globOptions = options.globOptions
|
|
||||||
|
|
||||||
let excludeString = exclude || ''
|
let excludeString = exclude || ''
|
||||||
if (exclude && Array.isArray(exclude)) excludeString = exclude.join('')
|
if (exclude && Array.isArray(exclude)) excludeString = exclude.join('')
|
||||||
|
@ -103,16 +100,15 @@ function minifySvg () {
|
||||||
// Return if disabled.
|
// Return if disabled.
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
const route = hexo.route
|
const { route } = hexo
|
||||||
const routeList = route.list()
|
const routeList = route.list()
|
||||||
const include = options.include
|
const { globOptions, include } = options
|
||||||
const globOptions = options.globOptions
|
|
||||||
|
|
||||||
let includeString = include || ''
|
let includeString = include || ''
|
||||||
if (include && Array.isArray(include)) includeString = include.join('')
|
if (include && Array.isArray(include)) includeString = include.join('')
|
||||||
if (includeString && includeString.includes('/')) globOptions.basename = false
|
if (includeString && includeString.includes('/')) globOptions.basename = false
|
||||||
|
|
||||||
return Promise.all((micromatch(routeList, include, globOptions)).map(path => {
|
return Promise.all((micromatch(routeList, include, globOptions)).map((path) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// Grab all assets using hexo router
|
// Grab all assets using hexo router
|
||||||
const assetPath = route.get(path)
|
const assetPath = route.get(path)
|
||||||
|
@ -142,16 +138,15 @@ function gzipFn () {
|
||||||
// Return if disabled.
|
// Return if disabled.
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
const route = hexo.route
|
const { route } = hexo
|
||||||
const routeList = route.list()
|
const routeList = route.list()
|
||||||
const include = options.include
|
const { globOptions, include } = options
|
||||||
const globOptions = options.globOptions
|
|
||||||
|
|
||||||
let includeString = include || ''
|
let includeString = include || ''
|
||||||
if (include && Array.isArray(include)) includeString = include.join('')
|
if (include && Array.isArray(include)) includeString = include.join('')
|
||||||
if (includeString && includeString.includes('/')) globOptions.basename = false
|
if (includeString && includeString.includes('/')) globOptions.basename = false
|
||||||
|
|
||||||
return Promise.all((micromatch(routeList, include, globOptions)).map(path => {
|
return Promise.all((micromatch(routeList, include, globOptions)).map((path) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// Grab all assets using hexo router
|
// Grab all assets using hexo router
|
||||||
const assetPath = route.get(path)
|
const assetPath = route.get(path)
|
||||||
|
@ -185,16 +180,15 @@ function brotliFn () {
|
||||||
// Return if disabled.
|
// Return if disabled.
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
const route = hexo.route
|
const { route } = hexo
|
||||||
const routeList = route.list()
|
const routeList = route.list()
|
||||||
const include = options.include
|
const { globOptions, include } = options
|
||||||
const globOptions = options.globOptions
|
|
||||||
|
|
||||||
let includeString = include || ''
|
let includeString = include || ''
|
||||||
if (include && Array.isArray(include)) includeString = include.join('')
|
if (include && Array.isArray(include)) includeString = include.join('')
|
||||||
if (includeString && includeString.includes('/')) globOptions.basename = false
|
if (includeString && includeString.includes('/')) globOptions.basename = false
|
||||||
|
|
||||||
return Promise.all((micromatch(routeList, include, globOptions)).map(path => {
|
return Promise.all((micromatch(routeList, include, globOptions)).map((path) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// Grab all assets using hexo router
|
// Grab all assets using hexo router
|
||||||
const assetPath = route.get(path)
|
const assetPath = route.get(path)
|
||||||
|
|
Loading…
Reference in New Issue