diff --git a/scripts/addCss.js b/scripts/addCss.js new file mode 100644 index 0000000..a5c1d61 --- /dev/null +++ b/scripts/addCss.js @@ -0,0 +1,34 @@ +'use strict' +/* global hexo */ + +/* +* Helper to embed css file with support of custom attributes +* https://github.com/hexojs/hexo/pull/3690 +*/ + +function cssHelper (...args) { + let result = '\n' + let items = args + + if (!Array.isArray(args)) { + items = [args] + } + + items.forEach(item => { + // Old syntax + if (typeof item === 'string' || item instanceof String) { + result += `\n` + } else { + // New syntax + let tmpResult = ' <%- js('js/sri.min') %> - <%- css('css/typing') %> + <%- addCss('css/typing.css') %> <% if (theme.icons) { %> - + <%- addCss({ href: 'https://cdnjs.cloudflare.com/ajax/libs/fork-awesome/1.1.7/css/fork-awesome.min.css', 'data-sri-fallback': '/forkawesome/css/fork-awesome.min.css', integrity: 'sha384-mByhW6NjnxyShh67P9+fepUvYSd7Uz/qV6e2u4kA2Fi4ZkjXxIP2mRkyK9dwK24W', crossorigin: 'anonymous' }) %> <% } %>