From ec13f5462182f765e4e3970875dbb36020f49176 Mon Sep 17 00:00:00 2001 From: Evan Luo Date: Sat, 6 Apr 2024 14:08:20 -0400 Subject: [PATCH] feat: add zstatic into cdn providers Add sustech and zstatic into cdn providers. #347 --- _config.yml | 4 ++-- scripts/helpers/themeHelpers.js | 36 ++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/_config.yml b/_config.yml index 93b92e68..e84dfab5 100755 --- a/_config.yml +++ b/_config.yml @@ -445,10 +445,10 @@ cdn: # Whether to enable CDN enable: false # CDN Provider - provider: staticfile # staticfile, bootcdn, cdnjs, jsdelivr, unpkg, custom + provider: zstatic # zstatic, sustech, staticfile, bootcdn, cdnjs, jsdelivr, unpkg, aliyun, custom # Custom CDN URL # format example: https://cdn.custom.com/hexo-theme-redefine/${version}/source/${path} - # The ${path} must be in the source folder of the theme + # The ${path} must leads to the root of the "source" folder of the theme custom_url: # CDN <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end diff --git a/scripts/helpers/themeHelpers.js b/scripts/helpers/themeHelpers.js index 63c91793..3a4d06b1 100755 --- a/scripts/helpers/themeHelpers.js +++ b/scripts/helpers/themeHelpers.js @@ -93,6 +93,8 @@ hexo.extend.helper.register("renderJS", function (path) { const cdnProviders = { staticfile: "https://cdn.staticfile.net", bootcdn: "https://cdn.bootcdn.net/ajax/libs", + sustech: "https://mirrors.sustech.edu.cn/cdnjs/ajax/libs", + zstatic: "https://s4.zstatic.net/ajax/libs", cdnjs: "https://cdnjs.cloudflare.com/ajax/libs", unpkg: "https://unpkg.com", jsdelivr: "https://cdn.jsdelivr.net/npm", @@ -120,7 +122,9 @@ hexo.extend.helper.register("renderJS", function (path) { } else if ( this.theme.cdn.provider === "staticfile" || this.theme.cdn.provider === "bootcdn" || - this.theme.cdn.provider === "cdnjs" + this.theme.cdn.provider === "cdnjs" || + this.theme.cdn.provider === "sustech" || + this.theme.cdn.provider === "zstatic" ) { return this.theme.cdn.enable ? `` @@ -150,6 +154,8 @@ hexo.extend.helper.register("renderJSModule", function (path) { const cdnProviders = { staticfile: "https://cdn.staticfile.net", bootcdn: "https://cdn.bootcdn.net/ajax/libs", + sustech: "https://mirrors.sustech.edu.cn/cdnjs/ajax/libs", + zstatic: "https://s4.zstatic.net/ajax/libs", cdnjs: "https://cdnjs.cloudflare.com/ajax/libs", unpkg: "https://unpkg.com", jsdelivr: "https://cdn.jsdelivr.net/npm", @@ -177,7 +183,9 @@ hexo.extend.helper.register("renderJSModule", function (path) { } else if ( this.theme.cdn.provider === "staticfile" || this.theme.cdn.provider === "bootcdn" || - this.theme.cdn.provider === "cdnjs" + this.theme.cdn.provider === "cdnjs" || + this.theme.cdn.provider === "sustech" || + this.theme.cdn.provider === "zstatic" ) { return this.theme.cdn.enable ? `` @@ -207,6 +215,8 @@ hexo.extend.helper.register("renderJSPath", function (path) { const cdnProviders = { staticfile: "https://cdn.staticfile.net", bootcdn: "https://cdn.bootcdn.net/ajax/libs", + sustech: "https://mirrors.sustech.edu.cn/cdnjs/ajax/libs", + zstatic: "https:https://s4.zstatic.net/ajax/libs", cdnjs: "https://cdnjs.cloudflare.com/ajax/libs", unpkg: "https://unpkg.com", jsdelivr: "https://cdn.jsdelivr.net/npm", @@ -232,7 +242,9 @@ hexo.extend.helper.register("renderJSPath", function (path) { } else if ( this.theme.cdn.provider === "staticfile" || this.theme.cdn.provider === "bootcdn" || - this.theme.cdn.provider === "cdnjs" + this.theme.cdn.provider === "cdnjs" || + this.theme.cdn.provider === "sustech" || + this.theme.cdn.provider === "zstatic" ) { return this.theme.cdn.enable ? `${cdnBase}/hexo-theme-redefine/${themeVersion}/${path}` @@ -260,12 +272,14 @@ hexo.extend.helper.register("renderJSPath", function (path) { hexo.extend.helper.register("renderCSS", function (path) { const _css = hexo.extend.helper.get("css").bind(hexo); const cdnProviders = { - staticfile: "//cdn.staticfile.net", - bootcdn: "//cdn.bootcdn.net/ajax/libs", - cdnjs: "//cdnjs.cloudflare.com/ajax/libs", - unpkg: "//unpkg.com", - jsdelivr: "//cdn.jsdelivr.net/npm", - aliyun: "//evan.beee.top/projects", + staticfile: "https://cdn.staticfile.net", + bootcdn: "https://cdn.bootcdn.net/ajax/libs", + sustech: "https://mirrors.sustech.edu.cn/cdnjs/ajax/libs", + zstatic: "https://s4.zstatic.net/ajax/libs", + cdnjs: "https://cdnjs.cloudflare.com/ajax/libs", + unpkg: "https://unpkg.com", + jsdelivr: "https://cdn.jsdelivr.net/npm", + aliyun: "https://evan.beee.top/projects", custom: this.theme.cdn.custom_url, }; @@ -289,7 +303,9 @@ hexo.extend.helper.register("renderCSS", function (path) { } else if ( this.theme.cdn.provider === "staticfile" || this.theme.cdn.provider === "bootcdn" || - this.theme.cdn.provider === "cdnjs" + this.theme.cdn.provider === "cdnjs" || + this.theme.cdn.provider === "sustech" || + this.theme.cdn.provider === "zstatic" ) { return this.theme.cdn.enable ? ``