blog/scripts/cssFilter.js

24 lines
592 B
JavaScript
Raw Normal View History

'use strict'
/* global hexo */
/*
* Normalize typing.css using sanitize.css
* Add browser prefixes using autoprefixer
*
* renderer is used (instead of filter) due to
* incompatible with hexo-yam
*/
const autoprefixer = require('autoprefixer')
const normalize = require('postcss-normalize')
const postcss = require('postcss')
2019-09-24 23:10:57 +00:00
hexo.extend.renderer.register('css', 'css', async (data) => {
2019-08-26 04:18:10 +00:00
if (data.path) {
if (data.path.endsWith('.min.css')) return data.text
2019-08-26 04:18:10 +00:00
}
2019-09-24 23:10:57 +00:00
const result = await postcss([normalize, autoprefixer]).process(data.text, { from: data.path })
return result.css
})