hexo-theme-gnix 4.2.3 → 4.2.5

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.jsx CHANGED
@@ -21,6 +21,7 @@ module.exports = class extends Component {
21
21
  <section class="section">
22
22
  <div
23
23
  class="main-content"
24
+ data-pjax
24
25
  dangerouslySetInnerHTML={{ __html: body }}
25
26
  ></div>
26
27
  </section>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-gnix",
3
- "version": "4.2.3",
3
+ "version": "4.2.5",
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.",
@@ -277,15 +277,6 @@ blockquote::before {
277
277
  background: hsl(from var(--mantle) h s l / 0.95);
278
278
  }
279
279
 
280
- .navbar-item.is-active {
281
- color: var(--flamingo);
282
- }
283
-
284
- .navbar-item:focus,
285
- .navbar-item:hover {
286
- color: var(--lavender);
287
- }
288
-
289
280
  body {
290
281
  background: var(--mantle);
291
282
  color: var(--text);
@@ -566,16 +557,6 @@ body {
566
557
  flex-shrink: 0;
567
558
  }
568
559
 
569
- .navbar-start {
570
- justify-content: flex-start;
571
- margin-right: auto;
572
- }
573
-
574
- .navbar-end {
575
- justify-content: flex-end;
576
- margin-left: auto;
577
- }
578
-
579
560
  /* #endregion Navbar */
580
561
 
581
562
  /* #region Theme Selector */
@@ -161,4 +161,4 @@
161
161
  padding: 0;
162
162
  margin: 0;
163
163
  display: contents;
164
- }
164
+ }
package/source/js/pjax.js CHANGED
@@ -1,25 +1,19 @@
1
1
  (() => {
2
- // biome-ignore lint/correctness/noUnusedVariables: will be used
3
2
  let pjax;
4
3
 
5
4
  function initPjax() {
6
5
  try {
7
6
  const Pjax = window.Pjax || (() => {});
8
7
  pjax = new Pjax({
9
- selectors: [
10
- "[data-pjax]",
11
- ".pjax-reload",
12
- "head title",
13
- ".main-content",
14
- ".navbar-start",
15
- ".navbar-end",
16
- ".searchbox link",
17
- ".searchbox script",
18
- "#comments link",
19
- "#comments script",
20
- ],
8
+ selectors: ["[data-pjax]", ".pjax-reload", "head title"],
21
9
  cacheBust: false,
22
10
  });
11
+
12
+ window.addEventListener("popstate", () => {
13
+ if (pjax?.loadUrl) {
14
+ pjax.loadUrl(window.location.href);
15
+ }
16
+ });
23
17
  } catch (e) {
24
18
  console.warn(`PJAX error: ${e}`);
25
19
  }
@@ -56,58 +56,29 @@ const FeatureHandlers = {
56
56
  expandCode(figure) {
57
57
  const expandBtn = figure.querySelector(SELECTORS.expandBtn);
58
58
  const pre = figure.querySelector(SELECTORS.preShiki);
59
-
60
59
  const isExpanded = figure.classList.contains("expanded");
61
60
  const showLines = parseInt(figure.dataset.showLines || "10", 10);
62
61
 
63
62
  if (isExpanded) {
64
- // 记录折叠前的状态
65
- const beforeCollapseHeight = pre.scrollHeight;
66
-
67
- // 计算折叠后的目标高度
68
63
  const computedStyle = getComputedStyle(pre);
69
64
  const lineHeight = parseFloat(computedStyle.lineHeight) || 20;
70
65
  const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
71
66
  const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;
72
67
  const targetHeight = showLines * lineHeight + paddingTop + paddingBottom;
73
68
 
74
- // 首先设置当前完整高度作为起点
75
- pre.style.maxHeight = `${beforeCollapseHeight}px`;
76
-
77
- // 应用折叠状态
78
- requestAnimationFrame(() => {
79
- figure.classList.remove("expanded");
80
- pre.style.maxHeight = `${targetHeight}px`;
81
-
82
- // 延迟箭头旋转,等待折叠动画完成
83
- setTimeout(() => {
84
- expandBtn.classList.remove(CLASSES.expandDone);
85
- }, 300); // 与CSS transition时间同步
86
- });
69
+ figure.classList.remove("expanded");
70
+ pre.style.maxHeight = `${targetHeight}px`;
71
+ expandBtn.classList.remove(CLASSES.expandDone);
87
72
  } else {
88
- // 展开代码
89
- const currentHeight = pre.offsetHeight;
90
73
  const fullHeight = pre.scrollHeight;
91
74
 
92
- // 先设置当前高度作为起点
93
- pre.style.maxHeight = `${currentHeight}px`;
94
-
95
- // 应用展开状态
96
75
  figure.classList.add("expanded");
76
+ pre.style.maxHeight = `${fullHeight}px`;
77
+ expandBtn.classList.add(CLASSES.expandDone);
97
78
 
98
- requestAnimationFrame(() => {
99
- pre.style.maxHeight = `${fullHeight}px`;
100
-
101
- // 立即开始箭头旋转动画
102
- expandBtn.classList.add(CLASSES.expandDone);
103
-
104
- // 动画结束后清除max-height限制,允许内容自然增长
105
- setTimeout(() => {
106
- if (figure.classList.contains("expanded")) {
107
- pre.style.maxHeight = "none";
108
- }
109
- }, 300);
110
- });
79
+ setTimeout(() => {
80
+ pre.style.maxHeight = "none";
81
+ }, 300);
111
82
  }
112
83
  },
113
84
  };
@@ -117,7 +88,7 @@ function handleToolbarClick(event) {
117
88
  const classList = target.classList;
118
89
 
119
90
  const handlers = {
120
- expand: () => FeatureHandlers.shrink(this),
91
+ "expand": () => FeatureHandlers.expandCode(this),
121
92
  "copy-button": () => FeatureHandlers.copy(this, target),
122
93
  "toggle-wrap": () => FeatureHandlers.toggleWrap(this),
123
94
  };