diff --git a/_config.yml b/_config.yml index 43a412204f..450d985dc4 100644 --- a/_config.yml +++ b/_config.yml @@ -1047,7 +1047,7 @@ vendors: # pjax: //cdn.jsdelivr.net/gh/theme-next/theme-next-pjax@0/pjax.min.js pjax: - # Internal version: 2.1.5 & 3.5.7 + # FancyBox # Example: # fancybox: //cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js # fancybox: //cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js @@ -1056,24 +1056,24 @@ vendors: fancybox: fancybox_css: - # Internal version: 1.0.4 + # Medium-zoom # Example: # mediumzoom: //cdn.jsdelivr.net/npm/medium-zoom@1/dist/medium-zoom.min.js mediumzoom: - # Internal version: 1.10.0 + # Lazyload # Example: # lazyload: //cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js # lazyload: //cdnjs.cloudflare.com/ajax/libs/lozad.js/1.9.0/lozad.min.js lazyload: - # Internal version: 4.0.7 + # Pangu # Example: # pangu: //cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js # pangu: //cdnjs.cloudflare.com/ajax/libs/pangu/4.0.7/pangu.min.js pangu: - # Internal version: 1.0.0 + # Quicklink # Example: # quicklink: //cdn.jsdelivr.net/npm/quicklink@1/dist/quicklink.umd.js quicklink: @@ -1090,13 +1090,13 @@ vendors: disqusjs_js: disqusjs_css: - # valine + # Valine # Example: # valine: //cdn.jsdelivr.net/npm/valine@1/dist/Valine.min.js # valine: //cdnjs.cloudflare.com/ajax/libs/valine/1.3.4/Valine.min.js valine: - # gitalk + # Gitalk # Example: # gitalk_js: //cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js # gitalk_css: //cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css @@ -1117,9 +1117,9 @@ vendors: needmoreshare2_js: needmoreshare2_css: - # Internal version: 2.10.4 + # Algolia Search # Example: - # algolia_instant_js: //cdn.jsdelivr.net/npm/instantsearch.js@2/dist/instantsearch.js + # algolia_instant_js: //cdn.jsdelivr.net/npm/instantsearch.js@2/dist/instantsearch.min.js # algolia_instant_css: //cdn.jsdelivr.net/npm/instantsearch.js@2/dist/instantsearch.min.css algolia_instant_js: algolia_instant_css: diff --git a/layout/_partials/head/head.swig b/layout/_partials/head/head.swig index f1012b2d66..832dee312d 100644 --- a/layout/_partials/head/head.swig +++ b/layout/_partials/head/head.swig @@ -49,11 +49,11 @@ {{ next_font() }} -{%- set font_awesome_uri = theme.vendors.fontawesome | default(url_for(theme.vendors._internal + '/font-awesome/css/font-awesome.min.css?v=4.7.0')) %} +{%- set font_awesome_uri = theme.vendors.fontawesome | default(next_vendors('font-awesome/css/font-awesome.min.css?v=4.7.0')) %} {%- if theme.fancybox %} - {%- set fancybox_css_uri = theme.vendors.fancybox_css | default(url_for(theme.vendors._internal + '/fancybox/source/jquery.fancybox.css')) %} + {%- set fancybox_css_uri = theme.vendors.fancybox_css | default(next_vendors('//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css')) %} {%- endif %} @@ -63,13 +63,13 @@ {%- endif %} {%- if theme.needmoreshare2.enable %} - {%- set needmoreshare2_css_uri = theme.vendors.needmoreshare2_css | default(url_for(theme.vendors._internal + '/needsharebutton/needsharebutton.css')) %} + {%- set needmoreshare2_css_uri = theme.vendors.needmoreshare2_css | default(next_vendors('needsharebutton/needsharebutton.css')) %} {%- endif %} {%- if theme.pace.enable %} - {%- set pace_css_uri = theme.vendors.pace_css | default(url_for(theme.vendors._internal + '/pace/pace-theme-' + theme.pace.theme + '.min.css?v=1.0.2')) %} - {%- set pace_js_uri = theme.vendors.pace | default(url_for(theme.vendors._internal + '/pace/pace.min.js?v=1.0.2')) %} + {%- set pace_css_uri = theme.vendors.pace_css | default(next_vendors('pace/pace-theme-' + theme.pace.theme + '.min.css?v=1.0.2')) %} + {%- set pace_js_uri = theme.vendors.pace | default(next_vendors('pace/pace.min.js?v=1.0.2')) %} {%- endif %} diff --git a/layout/_partials/share/needsharebutton.swig b/layout/_partials/share/needsharebutton.swig index a183a69f52..616a9cff9f 100644 --- a/layout/_partials/share/needsharebutton.swig +++ b/layout/_partials/share/needsharebutton.swig @@ -6,7 +6,7 @@ {%- endif %} -{%- set needmoreshare2_js_uri = theme.vendors.needmoreshare2_js | default(url_for(theme.vendors._internal + '/needsharebutton/needsharebutton.js')) %} +{%- set needmoreshare2_js_uri = theme.vendors.needmoreshare2_js | default(next_vendors('needsharebutton/needsharebutton.js')) %} {%- endif %} {%- if theme.canvas_ribbon.enable %} - {%- set canvas_ribbon_uri = theme.vendors.canvas_ribbon | default(url_for(theme.vendors._internal + '/canvas-ribbon/canvas-ribbon.js')) %} + {%- set canvas_ribbon_uri = theme.vendors.canvas_ribbon | default(next_vendors('canvas-ribbon/canvas-ribbon.js')) %} {%- endif %} {%- for name, internal in js_vendors %} - {%- set internal_script = url_for(theme.vendors._internal + '/' + internal) %} + {%- set internal_script = next_vendors(internal) %} {%- endfor %} {%- for name, internal in js_defer_vendors %} - {%- set internal_script = url_for(theme.vendors._internal + '/' + internal) %} + {%- set internal_script = next_vendors(internal) %} {%- endfor %} diff --git a/layout/_third-party/bookmark.swig b/layout/_third-party/bookmark.swig index 655e923a80..89a7b1335d 100644 --- a/layout/_third-party/bookmark.swig +++ b/layout/_third-party/bookmark.swig @@ -1,5 +1,5 @@ {%- if theme.bookmark.enable %} - {%- set bookmark_uri = theme.vendors.bookmark | default(url_for(theme.vendors._internal + '/bookmark/bookmark.min.js?v=1.0')) %} + {%- set bookmark_uri = theme.vendors.bookmark | default(next_vendors('bookmark/bookmark.min.js?v=1.0')) %} if (CONFIG.page.isPost) { diff --git a/layout/_third-party/quicklink.swig b/layout/_third-party/quicklink.swig index 4c02a3090d..6fb5d862a4 100644 --- a/layout/_third-party/quicklink.swig +++ b/layout/_third-party/quicklink.swig @@ -1,5 +1,5 @@ {%- if theme.quicklink.enable %} - {%- set quicklink_uri = theme.vendors.quicklink | default(url_for(theme.vendors._internal + '/quicklink/quicklink.umd.js')) %} + {%- set quicklink_uri = theme.vendors.quicklink | default(next_vendors('//cdn.jsdelivr.net/npm/quicklink@1/dist/quicklink.umd.js')) %} {%- if is_home() %} {%- if theme.quicklink.home %} diff --git a/layout/_third-party/search/algolia-search.swig b/layout/_third-party/search/algolia-search.swig index 4cc6005f9c..06b74adbb2 100644 --- a/layout/_third-party/search/algolia-search.swig +++ b/layout/_third-party/search/algolia-search.swig @@ -1,5 +1,5 @@ -{%- set algolia_instant_css_uri = theme.vendors.algolia_instant_css | default(url_for(theme.vendors._internal + '/algolia-instant-search/instantsearch.min.css')) %} -{%- set algolia_instant_js_uri = theme.vendors.algolia_instant_js | default(url_for(theme.vendors._internal + '/algolia-instant-search/instantsearch.min.js')) %} +{%- set algolia_instant_css_uri = theme.vendors.algolia_instant_css | default(next_vendors('//cdn.jsdelivr.net/npm/instantsearch.js@2/dist/instantsearch.min.css')) %} +{%- set algolia_instant_js_uri = theme.vendors.algolia_instant_js | default(next_vendors('//cdn.jsdelivr.net/npm/instantsearch.js@2/dist/instantsearch.min.js')) %} diff --git a/scripts/helpers/next-vendors.js b/scripts/helpers/next-vendors.js new file mode 100644 index 0000000000..b5c7fbd81d --- /dev/null +++ b/scripts/helpers/next-vendors.js @@ -0,0 +1,9 @@ +/* global hexo */ + +'use strict'; + +hexo.extend.helper.register('next_vendors', function(url) { + if (url.startsWith('//')) return url; + let internal = hexo.theme.config.vendors._internal; + return this.url_for(`${internal}/${url}`); +});