Skip to content

Commit 9d1a6d5

Browse files
committed
🚀 npm publish & enable cdn
1 parent 0f8544e commit 9d1a6d5

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

_config.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ visit_counter:
124124
site_uv: 站点总访客数:
125125
site_pv: 站点总访问量:
126126

127-
128-
#动态定义title
127+
# 动态定义title
129128
title_change:
130129
normal: (つェ⊂)咦!又好了!
131130
leave: 死鬼去哪里了!
131+
132+
# 设置为 true 发布后将使用 unpkg cdn
133+
cdn: true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<% if (theme.duoshuo && enabled ){ %>
22
var duoshuoQuery = {short_name:'<%- theme.duoshuo %>', theme: 'none'};
3-
lazyScripts.push('<%- url_for('/js/embed' + (cache ? '.min': '') + '.js?v=' + theme_version()) %>');
3+
lazyScripts.push('<%- url_for(theme_js("/js/embed", cache)) %>');
44
<% } %>

layout/_partial/script.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ lazyScripts.push('//s95.cnzz.com/z_stat.php?id=<%-theme.cnzz %>&web_id=<%-theme.
77
<% } %>
88
</script>
99

10-
<script src="<%- url_for('/js/main' + (cache ? '.min': '') + '.js?v=' + theme_version()) %>"></script>
10+
<script src="<%- url_for(theme_js('/js/main', cache)) %>"></script>
1111
<% if (theme.search){ %>
1212
<%- partial('search') %>
13-
<script src="<%- url_for('/js/search' + (cache ? '.min': '') + '.js?v=' + theme_version()) %>" async></script>
13+
<script src="<%- url_for(theme_js('/js/search', cache)) %>" async></script>
1414
<% } %>
1515

1616
<%- partial('plugins/mathjax') %>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hexo-theme-material-indigo",
3-
"version": "1.4.14",
3+
"version": "1.5.0",
44
"description": "Material Design theme for Hexo.",
55
"keywords": [
66
"hexo",

scripts/plugins.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
const version = require('../package.json').version
1+
const { version, name } = require('../package.json')
2+
23
hexo.extend.helper.register('theme_version', () => version)
34

5+
const source = (path, cache, ext) => {
6+
if(cache) {
7+
const minFile = `${path}.min${ext}`
8+
return hexo.theme.config.cdn ? `//unpkg.com/${name}@${version}/source${minFile}` : `${minFile}?v=${version}`
9+
} else {
10+
return path + ext
11+
}
12+
}
13+
hexo.extend.helper.register('theme_js', (path, cache) => source(path, cache, '.js'))
14+
hexo.extend.helper.register('theme_css', (path, cache) => source(path, cache, '.css'))
15+
416
function renderImage(src, alt = '', title = '') {
517
return `<figure class="image-bubble">
618
<div class="img-lightbox">

0 commit comments

Comments
 (0)