diff --git a/_config.yml b/_config.yml
index 93cd626..52aa78d 100644
--- a/_config.yml
+++ b/_config.yml
@@ -28,7 +28,7 @@ style:
# Favicon (You can use local image or image external link)
favicon: /images/logo.svg
- # Article image align position, value: left | center
+ # Article image align position, values: left | center
article_img_align: left
# Left side width
@@ -132,7 +132,7 @@ post:
author_label:
enable: true
auto: true # if true, show Lv1, Lv2, Lv3... , If false, show custom label
- # label array item can be one or more
+ # Label array item can be one or more
custom_label_list: ["Trainee", "Engineer", "Architect", "CTO", "BOSS"]
# ---------------------------------------------------------------------------------------
@@ -233,6 +233,7 @@ lazyload:
# ---------------------------------------------------------------------------------------
cdn:
enable: false
+ provider: jsdelivr # values: jsdelivr | unpkg
# ---------------------------------------------------------------------------------------
# PJAX
diff --git a/scripts/helpers/helper.js b/scripts/helpers/helper.js
index 7bcbcef..fa73f8e 100644
--- a/scripts/helpers/helper.js
+++ b/scripts/helpers/helper.js
@@ -54,12 +54,34 @@ hexo.extend.helper.register('getPostUrl', function (rootUrl, path) {
}
});
+const getSourceCdnUrl = (tyle, themeConfig, path) => {
+ const { version = '3.4.5', cdn = {} } = themeConfig
+ const { provider = 'jsdelivr' } = cdn
+
+ let urlPrefix = ''
+ switch (provider.toLocaleLowerCase()) {
+ case 'jsdelivr':
+ urlPrefix = '//cdn.jsdelivr.net/npm/hexo-theme-keep'
+ if (tyle === 'js') {
+ return ``;
+ } else {
+ return ``;
+ }
+ case 'unpkg':
+ urlPrefix = '//unpkg.com/hexo-theme-keep'
+ if (tyle === 'js') {
+ return ``;
+ } else {
+ return ``;
+ }
+ }
+}
+
hexo.extend.helper.register('__js', function (path) {
+ const { enable } = this.theme.cdn
const _js = hexo.extend.helper.get('js').bind(hexo);
- const cdnPathHandle = (path_2) => {
- return this.theme.cdn.enable
- ? ``
- : _js(path_2);
+ const cdnPathHandle = (pa) => {
+ return enable ? getSourceCdnUrl('js', this.theme, pa) : _js(pa);
}
let t = ``;
@@ -76,10 +98,7 @@ hexo.extend.helper.register('__js', function (path) {
});
hexo.extend.helper.register('__css', function (path) {
+ const { enable } = this.theme.cdn
const _css = hexo.extend.helper.get('css').bind(hexo);
- if (this.theme.cdn.enable) {
- return ``;
- } else {
- return _css(path);
- }
+ return enable ? getSourceCdnUrl('css', this.theme, path) : _css(path);
});