hexo-theme-nblog 1.2.0 → 1.2.2
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/_config.yml +0 -2
- package/layout/_partial/footer.ejs +5 -5
- package/layout/_partial/post-license.ejs +3 -5
- package/layout/layout.ejs +42 -65
- package/layout/post.ejs +2 -3
- package/package.json +1 -1
- package/scripts/helpers.js +1 -1
- package/source/css/admonition.css +3 -3
- package/source/css/highlight.css +2 -2
- package/source/css/lazyload.css +6 -9
- package/source/css/main.css +29 -32
- package/source/css/markdown.css +15 -110
- package/source/css/tocbot.css +1 -0
- package/source/js/lazyload.js +34 -0
- package/source/js/main.js +49 -25
- package/source/lib/css/materialdesignicons.min.css +3 -0
- package/source/lib/fonts/materialdesignicons-webfont.eot +0 -0
- package/source/lib/fonts/materialdesignicons-webfont.ttf +0 -0
- package/source/lib/fonts/materialdesignicons-webfont.woff +0 -0
- package/source/lib/fonts/materialdesignicons-webfont.woff2 +0 -0
- package/source/lib/js/highlight.min.js +1213 -0
- package/source/lib/js/medium-zoom.min.js +2 -0
- package/source/lib/js/pjax.min.js +1 -0
- package/source/lib/js/tocbot.min.js +1 -0
- package/source/lib/js/twikoo.all.min.js +2 -0
package/source/css/markdown.css
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
.post-body h4,
|
|
11
11
|
.post-body h5,
|
|
12
12
|
.post-body h6 {
|
|
13
|
-
margin-top:
|
|
13
|
+
margin-top: 1em;
|
|
14
14
|
margin-bottom: 0.5em;
|
|
15
15
|
font-weight: 600;
|
|
16
16
|
line-height: 1.4;
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
color: var(--primary-color);
|
|
27
27
|
font-weight: normal;
|
|
28
28
|
opacity: 1;
|
|
29
|
+
bottom: -0.5em;
|
|
29
30
|
transition: opacity var(--transition-fast);
|
|
30
31
|
border-bottom: none;
|
|
31
32
|
position: relative;
|
|
@@ -111,14 +112,13 @@
|
|
|
111
112
|
position: relative;
|
|
112
113
|
z-index: 1;
|
|
113
114
|
transition: color var(--transition-fast);
|
|
114
|
-
bottom: -0.
|
|
115
|
+
bottom: -0.65em;
|
|
115
116
|
right: 0.1em;
|
|
116
117
|
word-break: break-word;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
.post-body a::before {
|
|
120
121
|
position: absolute;
|
|
121
|
-
bottom: 0;
|
|
122
122
|
left: 0;
|
|
123
123
|
width: 100%;
|
|
124
124
|
height: 0;
|
|
@@ -145,20 +145,11 @@
|
|
|
145
145
|
.post-body ul,
|
|
146
146
|
.post-body ol {
|
|
147
147
|
margin-bottom: 1em;
|
|
148
|
-
padding-left: 1em;
|
|
149
148
|
}
|
|
150
149
|
|
|
151
150
|
.post-body li {
|
|
152
151
|
margin-bottom: 0.5em;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
.post-body li::marker {
|
|
156
|
-
color: var(--primary-color);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.post-body li>strong,
|
|
160
|
-
.post-body li>a {
|
|
161
|
-
display: inline-flex;
|
|
152
|
+
display: flex;
|
|
162
153
|
align-items: center;
|
|
163
154
|
}
|
|
164
155
|
|
|
@@ -176,109 +167,38 @@
|
|
|
176
167
|
}
|
|
177
168
|
|
|
178
169
|
.post-body code {
|
|
179
|
-
font-family: Consolas, Menlo, 'Fira Code', monospace;
|
|
180
170
|
font-size: 0.9em;
|
|
181
171
|
padding: 0.2em 0.4em;
|
|
182
172
|
margin: 0em 0.4em;
|
|
183
|
-
background: var(--
|
|
184
|
-
border-radius:
|
|
173
|
+
background: var(--primary-light);
|
|
174
|
+
border-radius: 5px;
|
|
185
175
|
color: var(--primary-color);
|
|
186
176
|
}
|
|
187
177
|
|
|
188
|
-
.post-body pre {
|
|
189
|
-
margin: 1em 0;
|
|
190
|
-
padding: 0;
|
|
191
|
-
background: #282c34;
|
|
192
|
-
border-radius: 10px;
|
|
193
|
-
overflow: hidden;
|
|
194
|
-
font-family: Consolas, Menlo, 'Fira Code', monospace;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.post-body pre code {
|
|
198
|
-
padding: 0;
|
|
199
|
-
background: transparent;
|
|
200
|
-
font-size: 0.9em;
|
|
201
|
-
line-height: 1.6;
|
|
202
|
-
color: inherit;
|
|
203
|
-
font-family: Consolas, Menlo, 'Fira Code', monospace;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
.post-body .highlight {
|
|
207
|
-
margin: 1em 0;
|
|
208
|
-
border-radius: 10px;
|
|
209
|
-
overflow-x: auto;
|
|
210
|
-
background: #282c34;
|
|
211
|
-
padding: 1em;
|
|
212
|
-
position: relative;
|
|
213
|
-
font-family: Consolas, Menlo, 'Fira Code', monospace;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.post-body .highlight pre {
|
|
217
|
-
margin: 0;
|
|
218
|
-
padding: 0;
|
|
219
|
-
background: transparent;
|
|
220
|
-
font-family: Consolas, Menlo, 'Fira Code', monospace;
|
|
221
|
-
white-space: pre;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
178
|
.post-body .highlight code {
|
|
225
179
|
padding: 0;
|
|
226
180
|
background: transparent;
|
|
227
181
|
color: inherit;
|
|
228
|
-
font-family: Consolas, Menlo, 'Fira Code', monospace;
|
|
229
182
|
white-space: pre;
|
|
230
183
|
}
|
|
231
184
|
|
|
232
|
-
.post-body
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
.post-body .highlight table tr {
|
|
238
|
-
background: transparent;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.post-body .highlight table td {
|
|
242
|
-
padding: 0;
|
|
243
|
-
border: none;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.post-body .highlight .gutter {
|
|
247
|
-
width: 20px;
|
|
248
|
-
padding-right: 5px;
|
|
249
|
-
border-right: 1px solid #3e4451;
|
|
250
|
-
text-align: right;
|
|
251
|
-
user-select: none;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
.post-body .highlight .gutter pre {
|
|
255
|
-
padding: 0 0.5em 0 0.5em;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.post-body .highlight .gutter .line {
|
|
259
|
-
color: #5c6370;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
.post-body .highlight .code pre {
|
|
263
|
-
padding: 0 0 0 0.5em;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
.post-body .highlight .line {
|
|
267
|
-
height: 1.6em;
|
|
268
|
-
line-height: 1.6;
|
|
185
|
+
.post-body pre,
|
|
186
|
+
code {
|
|
187
|
+
font-family: Consolas, Menlo, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
|
269
188
|
}
|
|
270
189
|
|
|
271
190
|
.post-body .highlight-wrap {
|
|
272
191
|
position: relative;
|
|
273
192
|
margin: 1em 0;
|
|
274
193
|
border-radius: 10px;
|
|
275
|
-
background:
|
|
194
|
+
background-color: var(--border-color);
|
|
276
195
|
overflow-x: auto;
|
|
196
|
+
font-family: Consolas, Menlo, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
|
277
197
|
}
|
|
278
198
|
|
|
279
199
|
.post-body .highlight-wrap .highlight {
|
|
280
|
-
margin:
|
|
281
|
-
padding:
|
|
200
|
+
margin: 0px;
|
|
201
|
+
padding: 0px;
|
|
282
202
|
overflow-x: auto;
|
|
283
203
|
overflow-y: hidden;
|
|
284
204
|
}
|
|
@@ -314,20 +234,11 @@
|
|
|
314
234
|
border-color: #98c379;
|
|
315
235
|
}
|
|
316
236
|
|
|
317
|
-
.post-body .highlight .code,
|
|
318
|
-
.post-body .highlight .gutter {
|
|
319
|
-
user-select: none;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
.post-body .highlight .code pre {
|
|
323
|
-
user-select: text;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
237
|
.post-body img {
|
|
327
|
-
|
|
238
|
+
width: 100%;
|
|
328
239
|
height: auto;
|
|
329
240
|
border-radius: var(--border-radius-sm);
|
|
330
|
-
margin:
|
|
241
|
+
margin: 0;
|
|
331
242
|
}
|
|
332
243
|
|
|
333
244
|
.post-body .medium-zoom-image {
|
|
@@ -364,7 +275,6 @@
|
|
|
364
275
|
|
|
365
276
|
.post-body table {
|
|
366
277
|
width: 100%;
|
|
367
|
-
margin: 1em 0;
|
|
368
278
|
border-collapse: collapse;
|
|
369
279
|
border-radius: var(--border-radius-sm);
|
|
370
280
|
overflow: hidden;
|
|
@@ -374,7 +284,6 @@
|
|
|
374
284
|
.post-body td {
|
|
375
285
|
padding: 12px 16px;
|
|
376
286
|
text-align: left;
|
|
377
|
-
border: 1px solid var(--border-color);
|
|
378
287
|
}
|
|
379
288
|
|
|
380
289
|
.post-body th {
|
|
@@ -455,10 +364,6 @@
|
|
|
455
364
|
font-size: 15px;
|
|
456
365
|
}
|
|
457
366
|
|
|
458
|
-
.post-body pre {
|
|
459
|
-
font-size: 0.85em;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
367
|
.post-body table {
|
|
463
368
|
display: block;
|
|
464
369
|
overflow-x: auto;
|
|
@@ -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
|
}
|
|
@@ -114,6 +115,19 @@
|
|
|
114
115
|
img.removeAttribute('data-src');
|
|
115
116
|
img.removeAttribute('data-srcset');
|
|
116
117
|
|
|
118
|
+
if (img.hasAttribute('data-zoomable') && typeof mediumZoom !== 'undefined') {
|
|
119
|
+
img.classList.add('medium-zoom-image');
|
|
120
|
+
var globalZoom = window.mediumZoomInstance;
|
|
121
|
+
if (!globalZoom) {
|
|
122
|
+
window.mediumZoomInstance = mediumZoom('.medium-zoom-image', {
|
|
123
|
+
margin: 24,
|
|
124
|
+
background: getComputedStyle(document.documentElement).getPropertyValue('--bg-color') || '#fff'
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
globalZoom.attach(img);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
117
131
|
img.dispatchEvent(new CustomEvent('lazyload:loaded', {
|
|
118
132
|
bubbles: true,
|
|
119
133
|
detail: { img: img }
|
|
@@ -122,6 +136,8 @@
|
|
|
122
136
|
|
|
123
137
|
tempImg.onerror = function () {
|
|
124
138
|
img.classList.add('lazyload-error');
|
|
139
|
+
img.classList.remove('lazyload-image');
|
|
140
|
+
img.style.opacity = '1';
|
|
125
141
|
if (wrapper) {
|
|
126
142
|
wrapper.classList.add('lazyload-wrapper--error');
|
|
127
143
|
self.showErrorPlaceholder(wrapper, src);
|
|
@@ -179,4 +195,22 @@
|
|
|
179
195
|
window.initLazyload = initLazyload;
|
|
180
196
|
window.refreshLazyload = refreshLazyload;
|
|
181
197
|
window.destroyLazyload = destroyLazyload;
|
|
198
|
+
|
|
199
|
+
function autoInit() {
|
|
200
|
+
if (document.readyState === 'loading') {
|
|
201
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
202
|
+
initLazyload({
|
|
203
|
+
rootMargin: '100px 0px',
|
|
204
|
+
threshold: 0.01
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
} else {
|
|
208
|
+
initLazyload({
|
|
209
|
+
rootMargin: '100px 0px',
|
|
210
|
+
threshold: 0.01
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
autoInit();
|
|
182
216
|
})();
|
package/source/js/main.js
CHANGED
|
@@ -249,37 +249,39 @@
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
const script = document.createElement('script');
|
|
252
|
-
script.src = '
|
|
253
|
-
script.onload =
|
|
254
|
-
const vueScript = document.createElement('script');
|
|
255
|
-
vueScript.src = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/vue.min.js';
|
|
256
|
-
vueScript.onload = callback;
|
|
257
|
-
document.head.appendChild(vueScript);
|
|
258
|
-
};
|
|
252
|
+
script.src = '/lib/js/highlight.min.js';
|
|
253
|
+
script.onload = callback;
|
|
259
254
|
document.head.appendChild(script);
|
|
260
255
|
}
|
|
261
256
|
|
|
262
257
|
function applyHighlight(element, language) {
|
|
263
258
|
if (!window.hljs) return;
|
|
264
259
|
|
|
265
|
-
const codeElement = element.querySelector('code
|
|
260
|
+
const codeElement = element.querySelector('.code code') || element.querySelector('code');
|
|
266
261
|
if (!codeElement) return;
|
|
267
262
|
|
|
268
|
-
let codeText
|
|
263
|
+
let codeText;
|
|
264
|
+
const tempEl = codeElement.cloneNode(true);
|
|
265
|
+
tempEl.querySelectorAll('br').forEach(br => br.replaceWith('\n'));
|
|
266
|
+
codeText = tempEl.textContent || tempEl.innerText;
|
|
267
|
+
|
|
268
|
+
const gutter = element.querySelector('.gutter');
|
|
269
|
+
const lines = codeText.split('\n');
|
|
270
|
+
if (lines.length > 0 && lines[lines.length - 1] === '') {
|
|
271
|
+
lines.pop();
|
|
272
|
+
}
|
|
273
|
+
const lineCount = lines.length;
|
|
269
274
|
|
|
270
|
-
|
|
275
|
+
if (gutter) {
|
|
276
|
+
gutter.innerHTML = '<pre>' + Array.from({ length: lineCount }, (_, i) => `<span class="line">${i + 1}</span><br>`).join('') + '</pre>';
|
|
277
|
+
}
|
|
271
278
|
|
|
272
|
-
|
|
273
|
-
const code = document.createElement('code');
|
|
274
|
-
code.className = language ? `hljs language-${language}` : 'hljs';
|
|
275
|
-
code.textContent = codeText;
|
|
276
|
-
pre.appendChild(code);
|
|
277
|
-
element.appendChild(pre);
|
|
279
|
+
codeElement.textContent = codeText;
|
|
278
280
|
|
|
279
281
|
if (language && hljs.getLanguage(language)) {
|
|
280
|
-
hljs.highlightElement(
|
|
282
|
+
hljs.highlightElement(codeElement);
|
|
281
283
|
} else {
|
|
282
|
-
hljs.highlightElement(
|
|
284
|
+
hljs.highlightElement(codeElement);
|
|
283
285
|
}
|
|
284
286
|
}
|
|
285
287
|
|
|
@@ -367,11 +369,11 @@
|
|
|
367
369
|
|
|
368
370
|
const link = document.createElement('link');
|
|
369
371
|
link.rel = 'stylesheet';
|
|
370
|
-
link.href = '
|
|
372
|
+
link.href = '/css/tocbot.css';
|
|
371
373
|
document.head.appendChild(link);
|
|
372
374
|
|
|
373
375
|
const script = document.createElement('script');
|
|
374
|
-
script.src = '
|
|
376
|
+
script.src = '/lib/js/tocbot.min.js';
|
|
375
377
|
script.onload = callback;
|
|
376
378
|
document.head.appendChild(script);
|
|
377
379
|
}
|
|
@@ -543,6 +545,8 @@
|
|
|
543
545
|
setTimeout(updateTocPosition, 500);
|
|
544
546
|
}
|
|
545
547
|
|
|
548
|
+
let zoomInstance = null;
|
|
549
|
+
|
|
546
550
|
function initMediumZoom() {
|
|
547
551
|
if (typeof mediumZoom === 'undefined') return;
|
|
548
552
|
|
|
@@ -555,19 +559,23 @@
|
|
|
555
559
|
images.forEach(img => {
|
|
556
560
|
if (img.closest('a')) return;
|
|
557
561
|
if (img.classList.contains('medium-zoom-image')) return;
|
|
562
|
+
if (img.hasAttribute('data-src')) return;
|
|
558
563
|
img.classList.add('medium-zoom-image');
|
|
559
564
|
});
|
|
560
565
|
|
|
561
566
|
document.querySelectorAll('[data-zoomable]').forEach(function (img) {
|
|
562
|
-
if (!img.classList.contains('medium-zoom-image')) {
|
|
567
|
+
if (!img.classList.contains('medium-zoom-image') && !img.hasAttribute('data-src')) {
|
|
563
568
|
img.classList.add('medium-zoom-image');
|
|
564
569
|
}
|
|
565
570
|
});
|
|
566
571
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
572
|
+
if (!zoomInstance) {
|
|
573
|
+
zoomInstance = mediumZoom('.medium-zoom-image', {
|
|
574
|
+
margin: 24,
|
|
575
|
+
background: getComputedStyle(document.documentElement).getPropertyValue('--bg-color') || '#fff'
|
|
576
|
+
});
|
|
577
|
+
window.mediumZoomInstance = zoomInstance;
|
|
578
|
+
}
|
|
571
579
|
}
|
|
572
580
|
|
|
573
581
|
function initPage() {
|
|
@@ -591,6 +599,9 @@
|
|
|
591
599
|
initToc();
|
|
592
600
|
initMediumZoom();
|
|
593
601
|
initNotifications();
|
|
602
|
+
if (typeof refreshLazyload === 'function') {
|
|
603
|
+
refreshLazyload();
|
|
604
|
+
}
|
|
594
605
|
|
|
595
606
|
window.scrollTo(0, 0);
|
|
596
607
|
}
|
|
@@ -626,7 +637,20 @@
|
|
|
626
637
|
|
|
627
638
|
initCodeBlocks();
|
|
628
639
|
initToc();
|
|
640
|
+
initMediumZoom();
|
|
629
641
|
initNotifications();
|
|
642
|
+
initLazyloadAuto();
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
function initLazyloadAuto() {
|
|
646
|
+
if (typeof initLazyload === 'function') {
|
|
647
|
+
initLazyload({
|
|
648
|
+
rootMargin: '100px 0px',
|
|
649
|
+
threshold: 0.01
|
|
650
|
+
});
|
|
651
|
+
} else if (typeof refreshLazyload === 'function') {
|
|
652
|
+
refreshLazyload();
|
|
653
|
+
}
|
|
630
654
|
}
|
|
631
655
|
|
|
632
656
|
function handleOutsideClick(e) {
|