Support cdnjs

This commit is contained in:
Mimi 2020-09-07 09:50:12 +08:00
parent 4b8a17b8e8
commit 96c68a9321
5 changed files with 6 additions and 5 deletions

View File

@ -148,7 +148,7 @@ Also, we welcome Issue or PR to our [official-plugins][official-plugins-url].
[docs-installation-url]: https://theme-next.js.org/docs/getting-started/installation.html [docs-installation-url]: https://theme-next.js.org/docs/getting-started/installation.html
[docs-configuration-url]: https://theme-next.js.org/docs/getting-started/configuration.html [docs-configuration-url]: https://theme-next.js.org/docs/getting-started/configuration.html
[docs-custom-files-url]: https://theme-next.js.org/docs/theme-settings/custom-files.html [docs-custom-files-url]: https://theme-next.js.org/docs/advanced-settings/custom-files.html
[docs-update-5-1-x-url]: https://theme-next.js.org/docs/getting-started/update-from-v5.html [docs-update-5-1-x-url]: https://theme-next.js.org/docs/getting-started/update-from-v5.html
[gitter-url]: https://gitter.im/hexo-next [gitter-url]: https://gitter.im/hexo-next

View File

@ -852,7 +852,7 @@ canvas_ribbon:
# Remember to use the https protocol of CDN links when you enable https on your site. # Remember to use the https protocol of CDN links when you enable https on your site.
vendors: vendors:
# The CDN provider of NexT internal scripts. # The CDN provider of NexT internal scripts.
# Available values: local | jsdelivr | unpkg # Available values: local | jsdelivr | unpkg | cdnjs
# Warning: If you are using the latest master branch of NexT, please set `internal: local` # Warning: If you are using the latest master branch of NexT, please set `internal: local`
internal: local internal: local
# The default CDN provider of third-party plugins. # The default CDN provider of third-party plugins.

View File

@ -151,7 +151,7 @@ Also, we welcome Issue or PR to our [official-plugins][official-plugins-url].
[docs-installation-url]: https://theme-next.js.org/docs/getting-started/installation.html [docs-installation-url]: https://theme-next.js.org/docs/getting-started/installation.html
[docs-configuration-url]: https://theme-next.js.org/docs/getting-started/configuration.html [docs-configuration-url]: https://theme-next.js.org/docs/getting-started/configuration.html
[docs-custom-files-url]: https://theme-next.js.org/docs/theme-settings/custom-files.html [docs-custom-files-url]: https://theme-next.js.org/docs/advanced-settings/custom-files.html
[docs-update-5-1-x-url]: https://theme-next.js.org/docs/getting-started/update-from-v5.html [docs-update-5-1-x-url]: https://theme-next.js.org/docs/getting-started/update-from-v5.html
[gitter-url]: https://gitter.im/hexo-next [gitter-url]: https://gitter.im/hexo-next

View File

@ -148,7 +148,7 @@ $ git pull
[docs-installation-url]: https://theme-next.js.org/docs/getting-started/installation.html [docs-installation-url]: https://theme-next.js.org/docs/getting-started/installation.html
[docs-configuration-url]: https://theme-next.js.org/docs/getting-started/configuration.html [docs-configuration-url]: https://theme-next.js.org/docs/getting-started/configuration.html
[docs-custom-files-url]: https://theme-next.js.org/docs/theme-settings/custom-files.html [docs-custom-files-url]: https://theme-next.js.org/docs/advanced-settings/custom-files.html
[docs-update-5-1-x-url]: https://theme-next.js.org/docs/getting-started/update-from-v5.html [docs-update-5-1-x-url]: https://theme-next.js.org/docs/getting-started/update-from-v5.html
[gitter-url]: https://gitter.im/hexo-next [gitter-url]: https://gitter.im/hexo-next

View File

@ -21,7 +21,8 @@ hexo.extend.helper.register('next_js', function(file, pjax = false) {
const links = { const links = {
local : this.url_for(`${this.theme.js}/${file}`), local : this.url_for(`${this.theme.js}/${file}`),
jsdelivr: `//cdn.jsdelivr.net/npm/hexo-theme-next@${next_version}/source/js/${file}`, jsdelivr: `//cdn.jsdelivr.net/npm/hexo-theme-next@${next_version}/source/js/${file}`,
unpkg : `//unpkg.com/hexo-theme-next@${next_version}/source/js/${file}` unpkg : `//unpkg.com/hexo-theme-next@${next_version}/source/js/${file}`,
cdnjs : `//cdnjs.cloudflare.com/ajax/libs/hexo-theme-next/${next_version}/${file}`
}; };
const src = links[internal] || links.local; const src = links[internal] || links.local;
return `<script ${pjax ? 'data-pjax ' : ''}src="${src}"></script>`; return `<script ${pjax ? 'data-pjax ' : ''}src="${src}"></script>`;