mirror of https://gitlab.com/curben/blog
refactor(cssFilter): async/await
This commit is contained in:
parent
be57b4edab
commit
996cb83aa2
|
@ -13,19 +13,11 @@ const autoprefixer = require('autoprefixer')
|
||||||
const normalize = require('postcss-normalize')
|
const normalize = require('postcss-normalize')
|
||||||
const postcss = require('postcss')
|
const postcss = require('postcss')
|
||||||
|
|
||||||
hexo.extend.renderer.register('css', 'css', (data, options) => {
|
hexo.extend.renderer.register('css', 'css', async (data) => {
|
||||||
if (data.path) {
|
if (data.path) {
|
||||||
if (data.path.endsWith('.min.css')) return data.text
|
if (data.path.endsWith('.min.css')) return data.text
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
const result = await postcss([normalize, autoprefixer]).process(data.text, { from: data.path })
|
||||||
postcss([normalize, autoprefixer])
|
return result.css
|
||||||
.process(data.text, { from: data.path })
|
|
||||||
.then(result => {
|
|
||||||
resolve(result.css)
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
reject(error)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue