From 887f9ec1161f7ae94b2d6132748b646a278c05da Mon Sep 17 00:00:00 2001
From: curben <2809763-curben@users.noreply.gitlab.com>
Date: Thu, 14 Nov 2019 02:27:25 +0000
Subject: [PATCH] refactor(helpers): js() and css() helpers now support custom
attributes
- https://github.com/hexojs/hexo/pull/3681
- https://github.com/hexojs/hexo/pull/3690
---
.../layout/_partial/after-footer.ejs | 6 ++--
themes/chameleon/layout/_partial/head.ejs | 7 ++--
themes/chameleon/scripts/addCss.js | 32 ------------------
themes/chameleon/scripts/addJs.js | 33 -------------------
4 files changed, 7 insertions(+), 71 deletions(-)
delete mode 100644 themes/chameleon/scripts/addCss.js
delete mode 100644 themes/chameleon/scripts/addJs.js
diff --git a/themes/chameleon/layout/_partial/after-footer.ejs b/themes/chameleon/layout/_partial/after-footer.ejs
index 39fc077..6085256 100644
--- a/themes/chameleon/layout/_partial/after-footer.ejs
+++ b/themes/chameleon/layout/_partial/after-footer.ejs
@@ -1,6 +1,6 @@
<% if (is_post()) { %>
-<%- addJs({ src: '/libs/clipboard.js/2.0.4/clipboard.min.js', 'data-sri-fallback': '/js/clipboard.min.js', integrity: 'sha384-8CYhPwYlLELodlcQV713V9ZikA3DlCVaXFDpjHfP8Z36gpddf/Vrt47XmKDsCttu', crossorigin: 'anonymous', defer: true}) %>
+<%- js({ src: '/libs/clipboard.js/2.0.4/clipboard.min.js', 'data-sri-fallback': '/js/clipboard.min.js', integrity: 'sha384-8CYhPwYlLELodlcQV713V9ZikA3DlCVaXFDpjHfP8Z36gpddf/Vrt47XmKDsCttu', crossorigin: 'anonymous', defer: true}) %>
<% } %>
-<%/* javascript of Typing theme */%>
-<%- addJs('/js/chameleon.js') %>
+<%/* javascript of Chameleon theme */%>
+<%- js('/js/chameleon.js') %>
diff --git a/themes/chameleon/layout/_partial/head.ejs b/themes/chameleon/layout/_partial/head.ejs
index 5ce879c..090eddf 100644
--- a/themes/chameleon/layout/_partial/head.ejs
+++ b/themes/chameleon/layout/_partial/head.ejs
@@ -44,11 +44,12 @@
<%/* Fallback function for SRI */%>
- <%- addJs({ src: '/js/sri.min.js', 'async': true }) %>
+ <%- js({ src: '/js/sri.min.js', 'async': true }) %>
- <%- addCss('/css/chameleon.css') %>
+ <%/* CSS of Chameleon theme */%>
+ <%- css('/css/chameleon.css') %>
<% if (theme.icons) { %>
- <%- addCss({ href: '/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' }) %>
+ <%- css({ href: '/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' }) %>
<% } %>
diff --git a/themes/chameleon/scripts/addCss.js b/themes/chameleon/scripts/addCss.js
deleted file mode 100644
index 5f200ac..0000000
--- a/themes/chameleon/scripts/addCss.js
+++ /dev/null
@@ -1,32 +0,0 @@
-'use strict'
-/* global hexo */
-
-/*
-* Helper to embed css file with support of custom attributes
-* https://github.com/hexojs/hexo/pull/3690
-*/
-
-hexo.extend.helper.register('addCss', (...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 = ' {
- tmpResult += ` ${attribute}="${item[attribute]}"`
- })
- tmpResult += '>\n'
- result += tmpResult
- }
- })
- return result
-})
diff --git a/themes/chameleon/scripts/addJs.js b/themes/chameleon/scripts/addJs.js
deleted file mode 100644
index 0851732..0000000
--- a/themes/chameleon/scripts/addJs.js
+++ /dev/null
@@ -1,33 +0,0 @@
-'use strict'
-/* global hexo */
-
-/*
-* Helper to add \n`
- } else {
- // New syntax
- let tmpResult = '\n'
- result += tmpResult
- }
- })
- return result
-})