hexo-theme-gnix 5.0.4 → 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.
@@ -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
 
@@ -1,4 +1,8 @@
1
- const { Component, Fragment, cacheComponent } = require("../../include/util/common");
1
+ const {
2
+ Component,
3
+ Fragment,
4
+ cacheComponent,
5
+ } = require("../../include/util/common");
2
6
 
3
7
  function isSameLink(a, b) {
4
8
  function santize(url) {
@@ -17,14 +21,13 @@ function isSameLink(a, b) {
17
21
 
18
22
  const renderLinkIcon = (link) => {
19
23
  if (!link.icon) return null;
20
- // start with '<' means svg icon
21
24
  if (link.icon === "travellings") {
22
25
  return (
23
- <svg viewBox="0 0 448 512" role="img" aria-label="Travellings Icon">
24
- <path
25
- fill="var(--text)"
26
- d="M96 0C43 0 0 43 0 96v256c0 48 35.2 87.7 81.1 94.9l-46 46c-7 7-2 19.1 7.9 19.1h39.7c8.5 0 16.6-3.4 22.6-9.4L160 448h128l54.6 54.6c6 6 14.1 9.4 22.6 9.4h39.7c10 0 15-12.1 7.9-19.1l-46-46c46-7.1 81.1-46.9 81.1-94.9V96c0-53-43-96-96-96zM64 128c0-17.7 14.3-32 32-32h80c17.7 0 32 14.3 32 32v96c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32zm208-32h80c17.7 0 32 14.3 32 32v96c0 17.7-14.3 32-32 32h-80c-17.7 0-32-14.3-32-32v-96c0-17.7 14.3-32 32-32M64 352a32 32 0 1 1 64 0a32 32 0 1 1-64 0m288-32a32 32 0 1 1 0 64a32 32 0 1 1 0-64"
27
- ></path>
26
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
27
+ <title>train_4_line</title>
28
+ <g id="train_4_line" fill="currentColor">
29
+ <path d="M14.72 2a5 5 0 0 1 4.855 3.802l.049.217 1.4 7c.496 2.482-.929 4.83-3.14 5.663l-.21.073L19.6 20.2a1 1 0 0 1-1.095 1.669L18.4 21.8 14.667 19H9.333L5.6 21.8a1 1 0 0 1-1.296-1.518L4.4 20.2l1.926-1.445c-2.26-.735-3.768-3.031-3.39-5.503l.04-.233 1.4-7a5 5 0 0 1 4.68-4.014L9.28 2h5.442Zm0 2H9.28a3 3 0 0 0-2.943 2.412l-1.4 7A3 3 0 0 0 7.88 17h8.242a3 3 0 0 0 2.942-3.588l-1.4-7A3 3 0 0 0 14.72 4m-6.47 9.25a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5m7.5 0a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5M14.61 6a1.5 1.5 0 0 1 1.416 1.005l.039.131.75 3a1.5 1.5 0 0 1-1.324 1.858L15.36 12H8.64a1.5 1.5 0 0 1-1.481-1.735l.026-.129.75-3a1.5 1.5 0 0 1 1.319-1.13L9.39 6zm-.39 2H9.78l-.5 2h5.44z"></path>
30
+ </g>
28
31
  </svg>
29
32
  );
30
33
  }
@@ -33,13 +36,18 @@ const renderLinkIcon = (link) => {
33
36
 
34
37
  class Navbar extends Component {
35
38
  render() {
36
- const { siteUrl, menu, links, showSearch, searchTitle } = this.props;
39
+ const { siteUrl, menu, links, searchTitle } = this.props;
37
40
 
38
41
  return (
39
42
  <nav class="navbar navbar-main" onclick="handleNavbarClick(event);">
40
43
  <div class="navbar-container">
41
- <a href={siteUrl} style={"font-family: homemade-apple; color: var(--text); display: flex; align-items: center; padding: 0 1em;"}>
42
- GnixAij
44
+ <a
45
+ href={siteUrl}
46
+ style={
47
+ "font-family: homemade-apple; color: var(--text); display: flex; align-items: center; padding: 0 1em;"
48
+ }
49
+ >
50
+ GnixAij
43
51
  </a>
44
52
  <div class="navbar-menu">
45
53
  {Object.keys(menu).length ? (
@@ -56,35 +64,6 @@ class Navbar extends Component {
56
64
  </div>
57
65
  ) : null}
58
66
  <div class="navbar-end">
59
- <button
60
- type="button"
61
- class="navbar-item theme-selector-trigger"
62
- title="Choose Theme"
63
- onclick="window.openThemeModal?.()"
64
- >
65
- <svg viewBox="0 0 14 14" role="img" aria-label="Theme Selector">
66
- <g fill="none">
67
- <path
68
- fill="var(--red)"
69
- d="M14 12.5v-3A1.5 1.5 0 0 0 12.5 8H3a3 3 0 1 0 0 6h9.5a1.5 1.5 0 0 0 1.5-1.5"
70
- ></path>
71
- <path
72
- fill="var(--blue)"
73
- d="M12.339 3.783L10.218 1.66a1.5 1.5 0 0 0-2.122 0L.88 8.88a3 3 0 0 0 4.24 4.24l7.218-7.217a1.5 1.5 0 0 0 0-2.121"
74
- ></path>
75
- <path
76
- fill="var(--green)"
77
- d="M4.5 0h-3A1.5 1.5 0 0 0 0 1.5V11a3 3 0 0 0 6 0V1.5A1.5 1.5 0 0 0 4.5 0"
78
- ></path>
79
- <path
80
- fill="var(--base)"
81
- fill-rule="evenodd"
82
- d="M1.395 3.375a.625.625 0 1 0 0 1.25h3.21a.625.625 0 1 0 0-1.25zm0 4.5a.625.625 0 1 0 0 1.25h3.21a.625.625 0 1 0 0-1.25z"
83
- clip-rule="evenodd"
84
- ></path>
85
- </g>
86
- </svg>
87
- </button>
88
67
  {Object.keys(links).length ? (
89
68
  <Fragment>
90
69
  {Object.keys(links).map((name) => {
@@ -103,26 +82,32 @@ class Navbar extends Component {
103
82
  })}
104
83
  </Fragment>
105
84
  ) : null}
106
- {showSearch ? (
107
- <button
108
- type="button"
109
- class="navbar-item search"
110
- title={searchTitle}
111
- >
112
- <svg viewBox="0 0 14 14" role="img" aria-label="Search Icon">
113
- <g fill="none" fill-rule="evenodd" clip-rule="evenodd">
114
- <path
115
- fill="var(--text)"
116
- d="M.5.125a.5.5 0 0 0-.5.5v10a.5.5 0 0 0 .5.5h4.756A4.5 4.5 0 0 1 5 9.625c0-1.271.527-2.42 1.375-3.238v-4.96A2 2 0 0 0 4.5.126zm7.125 1.303v4.105a4.5 4.5 0 0 1 6.347 3.584H14V.625a.5.5 0 0 0-.5-.5h-4a2 2 0 0 0-1.875 1.303"
117
- />
118
- <path
119
- fill="var(--blue)"
120
- d="M7.75 9.625a1.75 1.75 0 1 1 3.5 0a1.75 1.75 0 0 1-3.5 0m1.75-3.25a3.25 3.25 0 1 0 1.706 6.017l1.263 1.263a.75.75 0 0 0 1.06-1.06l-1.262-1.264A3.25 3.25 0 0 0 9.5 6.375"
121
- />
122
- </g>
123
- </svg>
124
- </button>
125
- ) : null}
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>
126
111
  </div>
127
112
  </div>
128
113
  <button
@@ -144,7 +129,7 @@ class Navbar extends Component {
144
129
  module.exports = cacheComponent(Navbar, "common.navbar", (props) => {
145
130
  const { config, helper, page } = props;
146
131
  const { url_for, _p, __ } = helper;
147
- const { logo, title, navbar, widgets, search } = config;
132
+ const { logo, title, navbar, widgets } = config;
148
133
 
149
134
  const hasTocWidget =
150
135
  Array.isArray(widgets) && widgets.find((widget) => widget.type === "toc");
@@ -182,7 +167,6 @@ module.exports = cacheComponent(Navbar, "common.navbar", (props) => {
182
167
  links,
183
168
  showToc,
184
169
  tocTitle: _p("widget.catalogue", Infinity),
185
- showSearch: search?.type,
186
170
  searchTitle: __("search.search"),
187
171
  };
188
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>
@@ -3,7 +3,6 @@ class ThemeSelector extends Component {
3
3
  render() {
4
4
  return (
5
5
  <div
6
- class="theme-selector-modal"
7
6
  id="theme-selector-modal"
8
7
  onclick="window.handleThemeModalClick?.(event)"
9
8
  >
@@ -29,7 +29,6 @@ class FloatingToc extends Component {
29
29
  stroke-width="2"
30
30
  stroke-linecap="round"
31
31
  stroke-linejoin="round"
32
- aria-label="Table of Contents"
33
32
  >
34
33
  <title>Table of Contents</title>
35
34
  <line x1="8" y1="6" x2="21" y2="6"></line>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-gnix",
3
- "version": "5.0.4",
3
+ "version": "5.0.6",
4
4
  "author": "Efterklang <gaojiaxing0220@gmail.com>",
5
5
  "license": "MIT",
6
6
  "description": "Second generation of Hexo theme Icarus, now with Catppuccin flavor and night mode support.",
@@ -425,7 +425,7 @@ body {
425
425
  top: env(safe-area-inset-top);
426
426
  left: 0;
427
427
  right: 0;
428
- transition: transform 0.3s ease-in-out;
428
+ /* transition: transform 0.3s ease-in-out; */
429
429
  z-index: 100;
430
430
  font-family: var(--font-sans-serif);
431
431
  border-bottom: 0.5px solid var(--surface0);
@@ -437,12 +437,11 @@ body {
437
437
  width: auto;
438
438
  display: flex;
439
439
  min-height: 4rem;
440
- }
441
-
442
- .navbar button {
443
- background: 0 0;
444
- border: none;
445
- cursor: pointer;
440
+ button {
441
+ background: none;
442
+ border: none;
443
+ cursor: pointer;
444
+ }
446
445
  }
447
446
 
448
447
  .navbar-main.navbar--hidden {
@@ -458,8 +457,18 @@ body {
458
457
  position: relative;
459
458
  flex-grow: 0;
460
459
  flex-shrink: 0;
460
+ }
461
+
462
+ .navbar-end {
461
463
  svg {
462
- width: 15px;
464
+ width: 1.2em;
465
+ }
466
+ .navbar-item {
467
+ &:hover {
468
+ scale: 1.1;
469
+ transition: all 0.2s ease;
470
+ color: var(--lavender);
471
+ }
463
472
  }
464
473
  }
465
474
 
@@ -467,7 +476,7 @@ body {
467
476
 
468
477
  /* #region Theme Selector */
469
478
 
470
- .theme-selector-modal {
479
+ #theme-selector-modal {
471
480
  position: fixed;
472
481
  inset: 0;
473
482
  z-index: 100;
@@ -495,7 +504,7 @@ body {
495
504
  opacity 0.2s ease;
496
505
  }
497
506
 
498
- .theme-selector-modal.is-active {
507
+ #theme-selector-modal.is-active {
499
508
  opacity: 1;
500
509
  visibility: visible;
501
510
  pointer-events: auto;
@@ -573,16 +582,6 @@ body {
573
582
  opacity: 1;
574
583
  }
575
584
 
576
- .theme-selector-trigger {
577
- cursor: pointer;
578
- transition: all 0.2s ease;
579
-
580
- &:hover {
581
- color: var(--blue);
582
- transform: scale(1.1);
583
- }
584
- }
585
-
586
585
  /* #endregion Theme Selector */
587
586
 
588
587
  /* #region Pagination */
@@ -1024,40 +1023,36 @@ body {
1024
1023
  }
1025
1024
 
1026
1025
  table {
1027
- table-layout: fixed;
1028
- word-wrap: break-word;
1029
1026
  width: 100%;
1030
- border-collapse: separate;
1027
+ border-collapse: collapse;
1031
1028
  border-spacing: 0;
1032
- border-radius: 8px;
1033
- overflow: hidden;
1029
+ overflow: auto;
1034
1030
  margin: 1rem 0;
1035
1031
  font-size: 1rem;
1036
- border: 1px solid var(--surface0);
1037
1032
  }
1038
1033
 
1039
- table td,
1040
- table th {
1034
+ td,
1035
+ th {
1041
1036
  vertical-align: middle;
1042
1037
  padding: 0.75em 1em;
1043
1038
  }
1044
1039
 
1045
- table thead th {
1040
+ thead th {
1046
1041
  font-weight: 700;
1047
1042
  border-bottom: 1px solid var(--surface0);
1048
1043
  padding: 1em;
1049
1044
  }
1050
1045
 
1051
- table td:not([align]),
1052
- table th:not([align]) {
1046
+ td:not([align]),
1047
+ th:not([align]) {
1053
1048
  text-align: left;
1054
1049
  }
1055
1050
 
1056
- table tbody tr td {
1051
+ tbody tr td {
1057
1052
  border-bottom: 1px solid var(--surface0);
1058
1053
  }
1059
1054
 
1060
- table tbody tr:last-child td {
1055
+ tbody tr:last-child td {
1061
1056
  border-bottom: none;
1062
1057
  }
1063
1058
 
@@ -13,7 +13,6 @@ span.year {
13
13
 
14
14
  table {
15
15
  font-size: 14px;
16
- word-wrap: break-word;
17
16
  }
18
17
 
19
18
  table th,
@@ -52,4 +51,4 @@ table td {
52
51
  .pagination-list li {
53
52
  flex-grow: 1;
54
53
  flex-shrink: 1;
55
- }
54
+ }
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
- const themeBtn = document.querySelector(
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
- // 先移除旧的滚动事件(防止PJAX重复绑定)
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 (typeof mediumZoom === "function") {
199
- mediumZoom(".article img", {
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
+ });