Skip to content

Commit

Permalink
feat: add zstatic into cdn providers
Browse files Browse the repository at this point in the history
Add sustech and zstatic into cdn providers. #347
  • Loading branch information
EvanNotFound committed Apr 6, 2024
1 parent b155abd commit ec13f54
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
4 changes: 2 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 26 additions & 10 deletions scripts/helpers/themeHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
? `<script src="${cdnBase}/hexo-theme-redefine/${themeVersion}/${path}"></script>`
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
? `<script type="module" src="${cdnBase}/hexo-theme-redefine/${themeVersion}/${path}"></script>`
Expand Down Expand Up @@ -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",
Expand All @@ -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}`
Expand Down Expand Up @@ -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,
};

Expand All @@ -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
? `<link rel="stylesheet" href="${cdnBase}/hexo-theme-redefine/${themeVersion}/${path}">`
Expand Down

0 comments on commit ec13f54

Please sign in to comment.