From 21caf32762a97aac9304cf54809d8f0c8bdbdf6e Mon Sep 17 00:00:00 2001
From: StevenJoeZhang <1119186082@qq.com>
Date: Sat, 17 Aug 2019 09:33:08 +0800
Subject: [PATCH 1/4] New helper next-vendors
---
_config.yml | 18 +++++++++---------
layout/_partials/head/head.swig | 10 +++++-----
layout/_partials/share/needsharebutton.swig | 2 +-
layout/_scripts/three.swig | 8 ++++----
layout/_scripts/vendors.swig | 18 +++++++++---------
layout/_third-party/bookmark.swig | 2 +-
layout/_third-party/quicklink.swig | 2 +-
layout/_third-party/search/algolia-search.swig | 4 ++--
scripts/helpers/next-vendors.js | 8 ++++++++
9 files changed, 40 insertions(+), 32 deletions(-)
create mode 100644 scripts/helpers/next-vendors.js
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')) %}
diff --git a/scripts/helpers/next-vendors.js b/scripts/helpers/next-vendors.js
new file mode 100644
index 0000000000..d46b00b477
--- /dev/null
+++ b/scripts/helpers/next-vendors.js
@@ -0,0 +1,8 @@
+/* global hexo */
+
+'use strict';
+
+hexo.extend.helper.register('next_vendors', function(url) {
+ let internal = hexo.theme.config._internal;
+ return this.url_for(`${internal}/${url}`);
+});
From a4d8c9e9b901e1f22d70546e2704e443d44e4bc0 Mon Sep 17 00:00:00 2001
From: StevenJoeZhang <1119186082@qq.com>
Date: Sat, 17 Aug 2019 09:39:33 +0800
Subject: [PATCH 2/4] Update
---
scripts/helpers/next-vendors.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/helpers/next-vendors.js b/scripts/helpers/next-vendors.js
index d46b00b477..6563b20fbb 100644
--- a/scripts/helpers/next-vendors.js
+++ b/scripts/helpers/next-vendors.js
@@ -3,6 +3,7 @@
'use strict';
hexo.extend.helper.register('next_vendors', function(url) {
+ if (url.startsWith('//')) return url;
let internal = hexo.theme.config._internal;
return this.url_for(`${internal}/${url}`);
});
From 1341703dc032b99146db371c17df242bcee34a51 Mon Sep 17 00:00:00 2001
From: StevenJoeZhang <1119186082@qq.com>
Date: Sat, 17 Aug 2019 09:43:53 +0800
Subject: [PATCH 3/4] QA
---
scripts/helpers/next-vendors.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/helpers/next-vendors.js b/scripts/helpers/next-vendors.js
index 6563b20fbb..4cea65a2d0 100644
--- a/scripts/helpers/next-vendors.js
+++ b/scripts/helpers/next-vendors.js
@@ -3,7 +3,7 @@
'use strict';
hexo.extend.helper.register('next_vendors', function(url) {
- if (url.startsWith('//')) return url;
- let internal = hexo.theme.config._internal;
- return this.url_for(`${internal}/${url}`);
+ if (url.startsWith('//')) return url;
+ let internal = hexo.theme.config._internal;
+ return this.url_for(`${internal}/${url}`);
});
From f7b98743dbd73ae56af9be90c82d964c9b2fb0c8 Mon Sep 17 00:00:00 2001
From: 1v9
Date: Sat, 17 Aug 2019 11:39:09 +0800
Subject: [PATCH 4/4] fix
---
scripts/helpers/next-vendors.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/helpers/next-vendors.js b/scripts/helpers/next-vendors.js
index 4cea65a2d0..b5c7fbd81d 100644
--- a/scripts/helpers/next-vendors.js
+++ b/scripts/helpers/next-vendors.js
@@ -4,6 +4,6 @@
hexo.extend.helper.register('next_vendors', function(url) {
if (url.startsWith('//')) return url;
- let internal = hexo.theme.config._internal;
+ let internal = hexo.theme.config.vendors._internal;
return this.url_for(`${internal}/${url}`);
});