hexo-theme-gnix 5.0.5 → 5.0.6
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/comment/twikoo.jsx +0 -26
- package/layout/common/navbar.jsx +28 -31
- package/layout/common/scripts.jsx +1 -0
- package/layout/common/theme_selector.jsx +0 -1
- package/package.json +1 -1
- package/source/css/default.css +11 -15
- package/source/css/responsive/mobile.css +1 -2
- package/source/js/main.js +23 -29
|
@@ -5,17 +5,6 @@ const {
|
|
|
5
5
|
lazy_load_css,
|
|
6
6
|
} = require("../../include/util/common");
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Twikoo comment JSX component.
|
|
10
|
-
*
|
|
11
|
-
* @see https://twikoo.js.org/quick-start.html
|
|
12
|
-
* @example
|
|
13
|
-
* <Twikoo
|
|
14
|
-
* envId="env_id"
|
|
15
|
-
* region="ap-guangzhou"
|
|
16
|
-
* lang="zh-CN"
|
|
17
|
-
* jsUrl="/path/to/Twikoo.js" />
|
|
18
|
-
*/
|
|
19
8
|
class Twikoo extends Component {
|
|
20
9
|
render() {
|
|
21
10
|
const { envId, region, lang, jsUrl } = this.props;
|
|
@@ -36,21 +25,6 @@ twikoo.init(window.twikooConfig);
|
|
|
36
25
|
}
|
|
37
26
|
}
|
|
38
27
|
|
|
39
|
-
/**
|
|
40
|
-
* Cacheable Twikoo comment JSX component.
|
|
41
|
-
* <p>
|
|
42
|
-
* This class is supposed to be used in combination with the <code>locals</code> hexo filter
|
|
43
|
-
* ({@link module:hexo/filter/locals}).
|
|
44
|
-
*
|
|
45
|
-
* @see module:util/cache.cacheComponent
|
|
46
|
-
* @example
|
|
47
|
-
* <Twikoo.Cacheable
|
|
48
|
-
* comment={{
|
|
49
|
-
* env_id: "env_id",
|
|
50
|
-
* region: "ap-guangzhou",
|
|
51
|
-
* lang: "zh-CN",
|
|
52
|
-
* }} />
|
|
53
|
-
*/
|
|
54
28
|
Twikoo.Cacheable = cacheComponent(Twikoo, "comment.twikoo", (props) => {
|
|
55
29
|
const { comment, helper, page, config } = props;
|
|
56
30
|
|
package/layout/common/navbar.jsx
CHANGED
|
@@ -21,7 +21,6 @@ function isSameLink(a, b) {
|
|
|
21
21
|
|
|
22
22
|
const renderLinkIcon = (link) => {
|
|
23
23
|
if (!link.icon) return null;
|
|
24
|
-
// start with '<' means svg icon
|
|
25
24
|
if (link.icon === "travellings") {
|
|
26
25
|
return (
|
|
27
26
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
@@ -37,7 +36,7 @@ const renderLinkIcon = (link) => {
|
|
|
37
36
|
|
|
38
37
|
class Navbar extends Component {
|
|
39
38
|
render() {
|
|
40
|
-
const { siteUrl, menu, links,
|
|
39
|
+
const { siteUrl, menu, links, searchTitle } = this.props;
|
|
41
40
|
|
|
42
41
|
return (
|
|
43
42
|
<nav class="navbar navbar-main" onclick="handleNavbarClick(event);">
|
|
@@ -65,19 +64,6 @@ class Navbar extends Component {
|
|
|
65
64
|
</div>
|
|
66
65
|
) : null}
|
|
67
66
|
<div class="navbar-end">
|
|
68
|
-
<button
|
|
69
|
-
type="button"
|
|
70
|
-
class="navbar-item"
|
|
71
|
-
title="Choose Theme"
|
|
72
|
-
onclick="window.openThemeModal?.()"
|
|
73
|
-
>
|
|
74
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
75
|
-
<title>brightness_fill</title>
|
|
76
|
-
<g id="brightness_fill" fill="currentColor">
|
|
77
|
-
<path d="M12 18.5a1.5 1.5 0 0 1 1.493 1.356L13.5 20v1a1.5 1.5 0 0 1-2.993.144L10.5 21v-1a1.5 1.5 0 0 1 1.5-1.5m4.596-1.904a1.5 1.5 0 0 1 2.008-.103l.114.103.707.707a1.5 1.5 0 0 1-2.008 2.225l-.114-.103-.707-.707a1.5 1.5 0 0 1 0-2.122m-11.314 0a1.5 1.5 0 0 1 2.225 2.008l-.103.114-.707.707a1.5 1.5 0 0 1-2.225-2.008l.103-.114zM12 6a6 6 0 1 1 0 12 6 6 0 0 1 0-12m0 3a3 3 0 0 0-.176 5.995L12 15zm-8 1.5a1.5 1.5 0 0 1 .144 2.993L4 13.5H3a1.5 1.5 0 0 1-.144-2.993L3 10.5zm17 0a1.5 1.5 0 0 1 .144 2.993L21 13.5h-1a1.5 1.5 0 0 1-.144-2.993L20 10.5zM4.575 4.575a1.5 1.5 0 0 1 2.008-.103l.114.103.707.707a1.5 1.5 0 0 1-2.008 2.225l-.114-.103-.707-.707a1.5 1.5 0 0 1 0-2.122m12.728 0a1.5 1.5 0 0 1 2.225 2.008l-.103.114-.707.707a1.5 1.5 0 0 1-2.225-2.008l.103-.114zM12 1.5a1.5 1.5 0 0 1 1.493 1.356L13.5 3v1a1.5 1.5 0 0 1-2.993.144L10.5 4V3A1.5 1.5 0 0 1 12 1.5"></path>
|
|
78
|
-
</g>
|
|
79
|
-
</svg>
|
|
80
|
-
</button>
|
|
81
67
|
{Object.keys(links).length ? (
|
|
82
68
|
<Fragment>
|
|
83
69
|
{Object.keys(links).map((name) => {
|
|
@@ -96,20 +82,32 @@ class Navbar extends Component {
|
|
|
96
82
|
})}
|
|
97
83
|
</Fragment>
|
|
98
84
|
) : null}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
</
|
|
111
|
-
</
|
|
112
|
-
|
|
85
|
+
<button
|
|
86
|
+
type="button"
|
|
87
|
+
class="navbar-item"
|
|
88
|
+
id="theme-selector-trigger"
|
|
89
|
+
title="Choose Theme"
|
|
90
|
+
onclick="window.openThemeModal?.()"
|
|
91
|
+
>
|
|
92
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
93
|
+
<title>brightness_fill</title>
|
|
94
|
+
<g id="brightness_fill" fill="currentColor">
|
|
95
|
+
<path d="M12 18.5a1.5 1.5 0 0 1 1.493 1.356L13.5 20v1a1.5 1.5 0 0 1-2.993.144L10.5 21v-1a1.5 1.5 0 0 1 1.5-1.5m4.596-1.904a1.5 1.5 0 0 1 2.008-.103l.114.103.707.707a1.5 1.5 0 0 1-2.008 2.225l-.114-.103-.707-.707a1.5 1.5 0 0 1 0-2.122m-11.314 0a1.5 1.5 0 0 1 2.225 2.008l-.103.114-.707.707a1.5 1.5 0 0 1-2.225-2.008l.103-.114zM12 6a6 6 0 1 1 0 12 6 6 0 0 1 0-12m0 3a3 3 0 0 0-.176 5.995L12 15zm-8 1.5a1.5 1.5 0 0 1 .144 2.993L4 13.5H3a1.5 1.5 0 0 1-.144-2.993L3 10.5zm17 0a1.5 1.5 0 0 1 .144 2.993L21 13.5h-1a1.5 1.5 0 0 1-.144-2.993L20 10.5zM4.575 4.575a1.5 1.5 0 0 1 2.008-.103l.114.103.707.707a1.5 1.5 0 0 1-2.008 2.225l-.114-.103-.707-.707a1.5 1.5 0 0 1 0-2.122m12.728 0a1.5 1.5 0 0 1 2.225 2.008l-.103.114-.707.707a1.5 1.5 0 0 1-2.225-2.008l.103-.114zM12 1.5a1.5 1.5 0 0 1 1.493 1.356L13.5 3v1a1.5 1.5 0 0 1-2.993.144L10.5 4V3A1.5 1.5 0 0 1 12 1.5"></path>
|
|
96
|
+
</g>
|
|
97
|
+
</svg>
|
|
98
|
+
</button>
|
|
99
|
+
<button
|
|
100
|
+
type="button"
|
|
101
|
+
class="navbar-item search"
|
|
102
|
+
title={searchTitle}
|
|
103
|
+
>
|
|
104
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
105
|
+
<title>search_line</title>
|
|
106
|
+
<g id="search_line" fill="currentColor">
|
|
107
|
+
<path d="M10.5 2a8.5 8.5 0 1 0 5.262 15.176l3.652 3.652a1 1 0 0 0 1.414-1.414l-3.652-3.652A8.5 8.5 0 0 0 10.5 2M4 10.5a6.5 6.5 0 1 1 13 0 6.5 6.5 0 0 1-13 0"></path>
|
|
108
|
+
</g>
|
|
109
|
+
</svg>
|
|
110
|
+
</button>
|
|
113
111
|
</div>
|
|
114
112
|
</div>
|
|
115
113
|
<button
|
|
@@ -131,7 +129,7 @@ class Navbar extends Component {
|
|
|
131
129
|
module.exports = cacheComponent(Navbar, "common.navbar", (props) => {
|
|
132
130
|
const { config, helper, page } = props;
|
|
133
131
|
const { url_for, _p, __ } = helper;
|
|
134
|
-
const { logo, title, navbar, widgets
|
|
132
|
+
const { logo, title, navbar, widgets } = config;
|
|
135
133
|
|
|
136
134
|
const hasTocWidget =
|
|
137
135
|
Array.isArray(widgets) && widgets.find((widget) => widget.type === "toc");
|
|
@@ -169,7 +167,6 @@ module.exports = cacheComponent(Navbar, "common.navbar", (props) => {
|
|
|
169
167
|
links,
|
|
170
168
|
showToc,
|
|
171
169
|
tocTitle: _p("widget.catalogue", Infinity),
|
|
172
|
-
showSearch: search?.type,
|
|
173
170
|
searchTitle: __("search.search"),
|
|
174
171
|
};
|
|
175
172
|
});
|
|
@@ -26,6 +26,7 @@ module.exports = class extends Component {
|
|
|
26
26
|
<script
|
|
27
27
|
defer
|
|
28
28
|
src="/js/host/medium-zoom/dist/medium-zoom.min.js"
|
|
29
|
+
onLoad={`const zoom = mediumZoom(".article img", { background: "hsla(from var(--mantle) / 0.9)" })`}
|
|
29
30
|
></script>
|
|
30
31
|
<script async src="/js/shiki/shiki.js"></script>
|
|
31
32
|
<script async src="/js/instant-page.min.js" type="module"></script>
|
package/package.json
CHANGED
package/source/css/default.css
CHANGED
|
@@ -476,7 +476,7 @@ body {
|
|
|
476
476
|
|
|
477
477
|
/* #region Theme Selector */
|
|
478
478
|
|
|
479
|
-
|
|
479
|
+
#theme-selector-modal {
|
|
480
480
|
position: fixed;
|
|
481
481
|
inset: 0;
|
|
482
482
|
z-index: 100;
|
|
@@ -504,7 +504,7 @@ body {
|
|
|
504
504
|
opacity 0.2s ease;
|
|
505
505
|
}
|
|
506
506
|
|
|
507
|
-
|
|
507
|
+
#theme-selector-modal.is-active {
|
|
508
508
|
opacity: 1;
|
|
509
509
|
visibility: visible;
|
|
510
510
|
pointer-events: auto;
|
|
@@ -1023,40 +1023,36 @@ body {
|
|
|
1023
1023
|
}
|
|
1024
1024
|
|
|
1025
1025
|
table {
|
|
1026
|
-
table-layout: fixed;
|
|
1027
|
-
word-wrap: break-word;
|
|
1028
1026
|
width: 100%;
|
|
1029
|
-
border-collapse:
|
|
1027
|
+
border-collapse: collapse;
|
|
1030
1028
|
border-spacing: 0;
|
|
1031
|
-
|
|
1032
|
-
overflow: hidden;
|
|
1029
|
+
overflow: auto;
|
|
1033
1030
|
margin: 1rem 0;
|
|
1034
1031
|
font-size: 1rem;
|
|
1035
|
-
border: 1px solid var(--surface0);
|
|
1036
1032
|
}
|
|
1037
1033
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1034
|
+
td,
|
|
1035
|
+
th {
|
|
1040
1036
|
vertical-align: middle;
|
|
1041
1037
|
padding: 0.75em 1em;
|
|
1042
1038
|
}
|
|
1043
1039
|
|
|
1044
|
-
|
|
1040
|
+
thead th {
|
|
1045
1041
|
font-weight: 700;
|
|
1046
1042
|
border-bottom: 1px solid var(--surface0);
|
|
1047
1043
|
padding: 1em;
|
|
1048
1044
|
}
|
|
1049
1045
|
|
|
1050
|
-
|
|
1051
|
-
|
|
1046
|
+
td:not([align]),
|
|
1047
|
+
th:not([align]) {
|
|
1052
1048
|
text-align: left;
|
|
1053
1049
|
}
|
|
1054
1050
|
|
|
1055
|
-
|
|
1051
|
+
tbody tr td {
|
|
1056
1052
|
border-bottom: 1px solid var(--surface0);
|
|
1057
1053
|
}
|
|
1058
1054
|
|
|
1059
|
-
|
|
1055
|
+
tbody tr:last-child td {
|
|
1060
1056
|
border-bottom: none;
|
|
1061
1057
|
}
|
|
1062
1058
|
|
package/source/js/main.js
CHANGED
|
@@ -92,21 +92,10 @@ function syncRelatedTabs(syncId) {
|
|
|
92
92
|
|
|
93
93
|
// #region Keyboard Shortcuts
|
|
94
94
|
|
|
95
|
-
function initKeyboardShortcuts() {
|
|
96
|
-
// 移除旧事件(防止PJAX重复绑定)
|
|
97
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
98
|
-
document.addEventListener("keydown", handleKeyDown, {
|
|
99
|
-
capture: true, // 捕获阶段监听,优先于浏览器默认处理
|
|
100
|
-
passive: false, // 允许调用 preventDefault
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// 抽离键盘事件处理函数
|
|
105
95
|
function handleKeyDown(e) {
|
|
106
96
|
const isModifier = e.metaKey || e.ctrlKey;
|
|
107
97
|
if (!isModifier) return;
|
|
108
98
|
|
|
109
|
-
// 性能优化 2: 如果用户在输入框内输入,不触发快捷键
|
|
110
99
|
const tag = e.target.tagName;
|
|
111
100
|
if (tag === "INPUT" || tag === "TEXTAREA" || e.target.isContentEditable) {
|
|
112
101
|
return;
|
|
@@ -118,10 +107,7 @@ function handleKeyDown(e) {
|
|
|
118
107
|
if (searchBtn) searchBtn.click();
|
|
119
108
|
} else if ((e.shiftKey && e.code === "KeyP") || e.code === "KeyP") {
|
|
120
109
|
e.preventDefault();
|
|
121
|
-
|
|
122
|
-
"button.navbar-item.theme-selector-trigger",
|
|
123
|
-
);
|
|
124
|
-
if (themeBtn) themeBtn.click();
|
|
110
|
+
window.openThemeModal?.();
|
|
125
111
|
}
|
|
126
112
|
}
|
|
127
113
|
|
|
@@ -150,7 +136,7 @@ function initializeTableOfContents() {
|
|
|
150
136
|
});
|
|
151
137
|
|
|
152
138
|
if (headers.length > 0) {
|
|
153
|
-
//
|
|
139
|
+
// 先移除旧的滚动事件
|
|
154
140
|
window.removeEventListener("scroll", handleTocScroll, { passive: true });
|
|
155
141
|
|
|
156
142
|
function handleTocScroll() {
|
|
@@ -192,13 +178,10 @@ function initializeTableOfContents() {
|
|
|
192
178
|
// #endregion
|
|
193
179
|
|
|
194
180
|
function initLogic() {
|
|
195
|
-
initKeyboardShortcuts();
|
|
196
181
|
initializeTableOfContents();
|
|
197
182
|
initializeTabs();
|
|
198
|
-
if (
|
|
199
|
-
|
|
200
|
-
background: "hsla(from var(--mantle) / 0.9)",
|
|
201
|
-
});
|
|
183
|
+
if (document.getElementById("twikoo")) {
|
|
184
|
+
twikoo?.init(window.twikooConfig);
|
|
202
185
|
}
|
|
203
186
|
}
|
|
204
187
|
|
|
@@ -210,14 +193,6 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
210
193
|
if (typeof swup !== "undefined") {
|
|
211
194
|
swup.hooks.on("page:view", () => {
|
|
212
195
|
initLogic();
|
|
213
|
-
|
|
214
|
-
// Re-initialize Twikoo if available
|
|
215
|
-
if (typeof twikoo !== "undefined" && window.twikooConfig) {
|
|
216
|
-
const twikooContainer = document.getElementById("twikoo");
|
|
217
|
-
if (twikooContainer) {
|
|
218
|
-
twikoo.init(window.twikooConfig);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
196
|
});
|
|
222
197
|
}
|
|
223
198
|
|
|
@@ -245,3 +220,22 @@ function handleNavbarClick(e) {
|
|
|
245
220
|
}
|
|
246
221
|
}
|
|
247
222
|
}
|
|
223
|
+
|
|
224
|
+
function tableWrapFix() {
|
|
225
|
+
document.querySelectorAll(".content table").forEach((table) => {
|
|
226
|
+
// if width exceeds container, wrap it
|
|
227
|
+
const wrapper = document.createElement("div");
|
|
228
|
+
Object.assign(wrapper.style, {
|
|
229
|
+
width: "100%",
|
|
230
|
+
overflowX: "auto",
|
|
231
|
+
});
|
|
232
|
+
table.parentNode.insertBefore(wrapper, table);
|
|
233
|
+
wrapper.appendChild(table);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
tableWrapFix();
|
|
238
|
+
document.addEventListener("keydown", handleKeyDown, {
|
|
239
|
+
capture: true, // 捕获阶段监听,优先于浏览器默认处理
|
|
240
|
+
passive: false, // 允许调用 preventDefault
|
|
241
|
+
});
|