hexo-theme-nblog 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/layout/layout.ejs +40 -63
- package/package.json +1 -1
- package/scripts/helpers.js +1 -1
- package/source/css/lazyload.css +6 -3
- package/source/css/main.css +1 -1
- package/source/css/tocbot.css +1 -0
- package/source/js/lazyload.js +21 -0
- package/source/js/lib/highlight.min.js +1213 -0
- package/source/js/lib/medium-zoom.min.js +2 -0
- package/source/js/lib/pjax.min.js +1 -0
- package/source/js/lib/tocbot.min.js +1 -0
- package/source/js/lib/twikoo.all.min.js +2 -0
- package/source/js/main.js +20 -9
package/layout/layout.ejs
CHANGED
|
@@ -51,11 +51,7 @@
|
|
|
51
51
|
}
|
|
52
52
|
</style>
|
|
53
53
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
|
54
|
-
<link rel="
|
|
55
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
56
|
-
<link
|
|
57
|
-
href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Noto+Sans+SC:wght@400;500;700&display=swap"
|
|
58
|
-
rel="stylesheet">
|
|
54
|
+
<link rel="preload" href="<%= url_for('/css/main.css') %>" as="style">
|
|
59
55
|
<link rel="stylesheet" href="<%= url_for('/css/main.css') %>">
|
|
60
56
|
<% if (theme.lazyload && theme.lazyload.enable) { %>
|
|
61
57
|
<link rel="stylesheet" href="<%= url_for('/css/lazyload.css') %>">
|
|
@@ -105,78 +101,59 @@
|
|
|
105
101
|
</main>
|
|
106
102
|
<%- partial('_partial/footer') %>
|
|
107
103
|
</div>
|
|
108
|
-
<script src="<%= url_for('/js/main.js') %>"></script>
|
|
104
|
+
<script defer src="<%= url_for('/js/main.js') %>"></script>
|
|
109
105
|
<% if (theme.lazyload && theme.lazyload.enable) { %>
|
|
110
|
-
<script src="<%= url_for('/js/lazyload.js') %>"></script>
|
|
111
|
-
<script>
|
|
112
|
-
document.addEventListener('DOMContentLoaded', function () {
|
|
113
|
-
if (typeof initLazyload === 'function') {
|
|
114
|
-
initLazyload({
|
|
115
|
-
rootMargin: '100px 0px',
|
|
116
|
-
threshold: 0.01
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
document.addEventListener('pjax:complete', function () {
|
|
121
|
-
if (typeof refreshLazyload === 'function') {
|
|
122
|
-
refreshLazyload();
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
</script>
|
|
106
|
+
<script defer src="<%= url_for('/js/lazyload.js') %>"></script>
|
|
126
107
|
<% } %>
|
|
127
108
|
<% if (theme.medium_zoom && theme.medium_zoom.enable) { %>
|
|
128
|
-
<script src="
|
|
129
|
-
<script>
|
|
130
|
-
document.addEventListener('DOMContentLoaded', function () {
|
|
131
|
-
if (typeof initMediumZoom === 'function') {
|
|
132
|
-
initMediumZoom();
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
document.addEventListener('pjax:complete', function () {
|
|
136
|
-
if (typeof initMediumZoom === 'function') {
|
|
137
|
-
initMediumZoom();
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
</script>
|
|
109
|
+
<script defer src="<%= url_for('/js/lib/medium-zoom.min.js') %>"></script>
|
|
141
110
|
<% } %>
|
|
142
111
|
<% if (theme.pjax && theme.pjax.enable) { %>
|
|
143
|
-
<script src="
|
|
112
|
+
<script defer src="<%= url_for('/js/lib/pjax.min.js') %>"></script>
|
|
144
113
|
<script>
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
114
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
115
|
+
if (typeof Pjax !== 'undefined') {
|
|
116
|
+
var pjax = new Pjax({
|
|
117
|
+
selectors: [
|
|
118
|
+
'title',
|
|
119
|
+
'meta[name="description"]',
|
|
120
|
+
'meta[property="og:title"]',
|
|
121
|
+
'meta[property="og:description"]',
|
|
122
|
+
'meta[property="og:url"]',
|
|
123
|
+
'meta[property="og:image"]',
|
|
124
|
+
'meta[property="article:published_time"]',
|
|
125
|
+
'meta[property="article:modified_time"]',
|
|
126
|
+
'#pjax-container',
|
|
127
|
+
'#header'
|
|
128
|
+
],
|
|
129
|
+
cacheBust: false
|
|
130
|
+
});
|
|
160
131
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
132
|
+
document.addEventListener('pjax:complete', function () {
|
|
133
|
+
if (typeof initPage === 'function') {
|
|
134
|
+
initPage();
|
|
135
|
+
}
|
|
136
|
+
if (typeof twikoo !== 'undefined' && twikoo.init) {
|
|
137
|
+
twikoo.init({
|
|
138
|
+
envId: '<%= theme.twikoo.envId %>',
|
|
139
|
+
el: '#twikoo-comment'
|
|
140
|
+
});
|
|
141
|
+
}
|
|
169
142
|
});
|
|
170
143
|
}
|
|
171
144
|
});
|
|
172
145
|
</script>
|
|
173
146
|
<% } %>
|
|
174
147
|
<% if (is_post() && theme.twikoo && theme.twikoo.enable) { %>
|
|
175
|
-
<script src="
|
|
148
|
+
<script defer src="<%= url_for('/js/lib/twikoo.all.min.js') %>"></script>
|
|
176
149
|
<script>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
150
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
151
|
+
if (typeof twikoo !== 'undefined' && twikoo.init) {
|
|
152
|
+
twikoo.init({
|
|
153
|
+
envId: '<%= theme.twikoo.envId %>',
|
|
154
|
+
el: '#twikoo-comment'
|
|
155
|
+
});
|
|
156
|
+
}
|
|
180
157
|
});
|
|
181
158
|
</script>
|
|
182
159
|
<% } %>
|
package/package.json
CHANGED
package/scripts/helpers.js
CHANGED
|
@@ -32,7 +32,7 @@ hexo.extend.filter.register('after_post_render', function (data) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
return '<img' + before + 'data-src="' + src + '"' + newAfter + '>';
|
|
35
|
+
return '<img' + before + 'src="data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 1 1\'%3E%3C/svg%3E" data-src="' + src + '"' + newAfter + '>';
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
|
package/source/css/lazyload.css
CHANGED
|
@@ -10,15 +10,18 @@
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
img[data-src] {
|
|
13
|
-
opacity: 0
|
|
14
|
-
visibility: hidden !important;
|
|
13
|
+
opacity: 0;
|
|
15
14
|
min-height: 1px;
|
|
16
15
|
min-width: 1px;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
img[data-src].lazyload-image {
|
|
20
|
-
visibility: visible !important;
|
|
21
19
|
opacity: 0;
|
|
20
|
+
transition: opacity 0.3s ease;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
img[data-src].lazyload-loaded {
|
|
24
|
+
opacity: 1;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
.lazyload-skeleton {
|
package/source/css/main.css
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
--transition-fast: 0.15s ease;
|
|
23
23
|
--transition-normal: 0.3s ease;
|
|
24
24
|
--transition-slow: 0.5s ease;
|
|
25
|
-
--font-family: '
|
|
25
|
+
--font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
|
26
26
|
--font-mono: 'Fira Code', 'Consolas', monospace;
|
|
27
27
|
--header-height: 64px;
|
|
28
28
|
--sidebar-width: 280px;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.toc{overflow-y:auto}.toc>.toc-list{overflow:hidden;position:relative}.toc>.toc-list li{list-style:none}.toc-list{margin:0;padding-left:10px}a.toc-link{color:currentColor;height:100%}.is-collapsible{max-height:1000px;overflow:hidden;transition:all 300ms ease-in-out}.is-collapsed{max-height:0}.is-position-fixed{position:fixed !important;top:0}.is-active-link{font-weight:700}.toc-link::before{background-color:#eee;content:" ";display:inline-block;height:inherit;left:0;margin-top:-1px;position:absolute;width:2px}.is-active-link::before{background-color:#54bc4b}/*# sourceMappingURL=tocbot.css.map */
|
package/source/js/lazyload.js
CHANGED
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
img.src = src;
|
|
108
108
|
|
|
109
109
|
img.classList.add('lazyload-loaded');
|
|
110
|
+
img.classList.remove('lazyload-image');
|
|
110
111
|
if (wrapper) {
|
|
111
112
|
wrapper.classList.add('lazyload-wrapper--loaded');
|
|
112
113
|
}
|
|
@@ -122,6 +123,8 @@
|
|
|
122
123
|
|
|
123
124
|
tempImg.onerror = function () {
|
|
124
125
|
img.classList.add('lazyload-error');
|
|
126
|
+
img.classList.remove('lazyload-image');
|
|
127
|
+
img.style.opacity = '1';
|
|
125
128
|
if (wrapper) {
|
|
126
129
|
wrapper.classList.add('lazyload-wrapper--error');
|
|
127
130
|
self.showErrorPlaceholder(wrapper, src);
|
|
@@ -179,4 +182,22 @@
|
|
|
179
182
|
window.initLazyload = initLazyload;
|
|
180
183
|
window.refreshLazyload = refreshLazyload;
|
|
181
184
|
window.destroyLazyload = destroyLazyload;
|
|
185
|
+
|
|
186
|
+
function autoInit() {
|
|
187
|
+
if (document.readyState === 'loading') {
|
|
188
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
189
|
+
initLazyload({
|
|
190
|
+
rootMargin: '100px 0px',
|
|
191
|
+
threshold: 0.01
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
} else {
|
|
195
|
+
initLazyload({
|
|
196
|
+
rootMargin: '100px 0px',
|
|
197
|
+
threshold: 0.01
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
autoInit();
|
|
182
203
|
})();
|