mirror of https://gitlab.com/curben/blog
feat: add sanitize.css (via postcss-normalize) and autoprefixer
This commit is contained in:
parent
31d99f0dab
commit
910dde814f
|
@ -11,6 +11,7 @@
|
|||
"renovate": "renovate --token $BOT_TOKEN --platform 'gitlab' --onboarding false --update-lock-files false --labels 'renovate' --recreate-closed true --require-config false curben/blog"
|
||||
},
|
||||
"dependencies": {
|
||||
"autoprefixer": "^9.6.1",
|
||||
"hexo": "hexojs/hexo",
|
||||
"hexo-generator-archive": "hexojs/hexo-generator-archive",
|
||||
"hexo-generator-tag": "hexojs/hexo-generator-tag",
|
||||
|
@ -18,6 +19,8 @@
|
|||
"hexo-renderer-ejs": "hexojs/hexo-renderer-ejs",
|
||||
"hexo-renderer-marked": "hexojs/hexo-renderer-marked",
|
||||
"hexo-yam": "curbengh/hexo-yam"
|
||||
"postcss-normalize": "^8.0.1"
|
||||
"sanitize.css": "^11.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"hexo-server": "hexojs/hexo-server"
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
'use strict'
|
||||
/* global hexo */
|
||||
|
||||
/*
|
||||
* Normalize typing.css using sanitize.css
|
||||
* Add browser prefixes using autoprefixer
|
||||
*/
|
||||
|
||||
const micromatch = require('micromatch')
|
||||
const postcss = require('postcss')
|
||||
const normalize = require('postcss-normalize')
|
||||
const autoprefixer = require('autoprefixer')
|
||||
|
||||
function cssFilter (str, data) {
|
||||
const path = data.path
|
||||
const exclude = '*.min.css'
|
||||
|
||||
if (path && exclude && exclude.length) {
|
||||
if (micromatch.isMatch(path, exclude, { basename: true })) return str
|
||||
}
|
||||
|
||||
const output = postcss([normalize, autoprefixer])
|
||||
.process(str, {from: path})
|
||||
.then(result => {
|
||||
return result.css
|
||||
})
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
hexo.extend.filter.register('after_render:css', cssFilter)
|
|
@ -1,4 +1,5 @@
|
|||
@charset "utf-8";
|
||||
/* Require postcss-normalize */
|
||||
@import "sanitize";
|
||||
@import "sanitize/forms";
|
||||
@import "sanitize/typography";
|
||||
|
|
Loading…
Reference in New Issue