XPoet / hexo-theme-keep

:rainbow: A simple and light theme for Hexo. It makes you more focused on writing.
https://xpoet.cn
GNU Affero General Public License v3.0
1.35k stars 183 forks source link

cdnjs的选项中,是否可以引入国内的一些厂商? #380

Open a2501521908 opened 14 hours ago

a2501521908 commented 14 hours ago

Issue Checklist | Issue 检查清单

Feature Request | 功能需求

我在 https://github.com/XPoet/hexo-theme-keep/blob/master/scripts/helpers/helper.js 源码中看到,cdnjs枚举目前仅支持cloudflare。是否可以引入bootCDN、360CDN等国内速度较快的厂商?

case providerEnum.cdnjs:
  urlPrefix = 'https://cdnjs.cloudflare.com/ajax/libs/hexo-theme-keep'
  if (tyle === 'js') {
    path = path.includes('.min.js') ? path : path.replace('.js', '.min.js')
    return `<script src="${urlPrefix}/${version}/${path}"></script>`
  } else {
    path = path.includes('.min.css') ? path : path.replace('.css', '.min.css')
    return `<link rel="stylesheet" href="${urlPrefix}/${version}/${path}">`
  }

也就是说urlPrefix支持自定义,比如这样?

urlPrefix = 'https://cdn.bootcdn.net/ajax/libs/hexo-theme-keep'

具体的配置key是否可以在cdn.provider.cdnjs.custom下?

Other Information | 其它信息

No response

XPoet commented 14 hours ago

挺好的建议,后续会支持自定义cdn 厂商

a2501521908 commented 14 hours ago

感觉这个功能cdn.provider.cdnjs.custom 配置项更可靠,因为它不会影响上层配置。如果用 cdn.provider.custom,就可能引入不确定性。比如,如果上层指定的是 jsdelivr,而 custom 用的是 cdnjs,就可能导致无法访问的问题~