Skip to content

Commit 8aa162c

Browse files
Optimize the loading of exturl (theme-next#1076)
1 parent 6769932 commit 8aa162c

File tree

7 files changed

+11
-23
lines changed

7 files changed

+11
-23
lines changed

layout/_partials/head/head.swig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
root: '{{ config.root }}',
100100
scheme: '{{ theme.scheme }}',
101101
version: '{{ version }}',
102+
exturl: {{ theme.exturl }},
102103
sidebar: {{ theme.sidebar | json_encode }},
103104
back2top: {{ theme.back2top | json_encode }},
104105
save_scroll: {{ theme.save_scroll }},

layout/_scripts/exturl.swig

Lines changed: 0 additions & 3 deletions
This file was deleted.

layout/_scripts/index.swig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@
55
{% include scheme_script %}
66

77
{% include 'next-boot.swig' %}
8-
{% include 'exturl.swig' %}
98
{% include 'three.swig' %}

scripts/filters/minify.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ hexo.extend.filter.register('after_generate', () => {
2929
});
3030
}
3131

32-
if (!theme.exturl) {
33-
hexo.route.remove('js/exturl.js');
34-
}
35-
3632
if (theme.vendors.jquery) {
3733
hexo.route.remove('lib/jquery/index.js');
3834
}

source/js/exturl.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

source/js/next-boot.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ $(document).on('DOMContentLoaded pjax:success', function() {
5252
CONFIG.lazyload && window.lozad('.post-body img').observe();
5353
CONFIG.pangu && window.pangu.spacingPage();
5454

55+
CONFIG.exturl && NexT.utils.registerExtURL();
5556
CONFIG.copycode.enable && NexT.utils.registerCopyCode();
5657
NexT.utils.registerTabsTag();
5758
NexT.utils.registerActiveMenuItem();

source/js/utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ NexT.utils = {
4242
});
4343
},
4444

45+
registerExtURL: function() {
46+
$('.exturl').on('click', function() {
47+
var $exturl = $(this).attr('data-url');
48+
var $decurl = decodeURIComponent(escape(window.atob($exturl)));
49+
window.open($decurl, '_blank', 'noopener');
50+
return false;
51+
});
52+
},
53+
4554
/**
4655
* One-click copy code support.
4756
*/

0 commit comments

Comments
 (0)