hexo-theme-gnix 6.2.0 → 8.0.0

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.
Files changed (59) hide show
  1. package/README.md +6 -2
  2. package/include/hexo/encrypt.js +42 -0
  3. package/include/hexo/feed.js +329 -0
  4. package/include/util/common.js +7 -9
  5. package/languages/en.yml +6 -3
  6. package/languages/zh-CN.yml +6 -3
  7. package/layout/archive.jsx +86 -65
  8. package/layout/comment/twikoo.jsx +2 -11
  9. package/layout/comment/waline.jsx +2 -2
  10. package/layout/common/article.jsx +5 -8
  11. package/layout/common/article_cover.jsx +11 -1
  12. package/layout/common/article_media.jsx +2 -4
  13. package/layout/common/footer.jsx +11 -31
  14. package/layout/common/head.jsx +6 -14
  15. package/layout/common/navbar.jsx +4 -4
  16. package/layout/common/scripts.jsx +6 -6
  17. package/layout/common/theme_selector.jsx +5 -6
  18. package/layout/common/toc.jsx +8 -14
  19. package/layout/index.jsx +2 -4
  20. package/layout/misc/article_licensing.jsx +4 -2
  21. package/layout/misc/open_graph.jsx +4 -4
  22. package/layout/misc/paginator.jsx +10 -4
  23. package/layout/misc/structured_data.jsx +3 -4
  24. package/layout/plugin/busuanzi.jsx +1 -1
  25. package/layout/plugin/cookie_consent.jsx +40 -31
  26. package/layout/plugin/swup.jsx +2 -22
  27. package/layout/search/insight.jsx +16 -3
  28. package/package.json +12 -8
  29. package/scripts/hot-reload.js +92 -0
  30. package/scripts/index.js +2 -0
  31. package/source/css/archive.css +251 -0
  32. package/source/css/default.css +250 -284
  33. package/source/css/encrypt.css +55 -0
  34. package/source/css/responsive/desktop.css +0 -119
  35. package/source/css/responsive/mobile.css +7 -23
  36. package/source/css/responsive/touch.css +9 -103
  37. package/source/css/shiki/shiki.css +7 -22
  38. package/source/css/twikoo.css +290 -830
  39. package/source/img/og_image.webp +0 -0
  40. package/source/js/archive-breadcrumb.js +132 -0
  41. package/source/js/busuanzi.js +1 -12
  42. package/source/js/components/accordion.js +192 -0
  43. package/source/js/components/chat.js +239 -0
  44. package/source/js/components/device-carousel.js +260 -0
  45. package/source/js/components/image-carousel.js +410 -0
  46. package/source/js/components/text-image-section.js +180 -0
  47. package/source/js/components/theme-stacked.js +526 -0
  48. package/source/js/components/tree.js +437 -0
  49. package/source/js/decrypt.js +112 -0
  50. package/source/js/insight.js +75 -65
  51. package/source/js/main.js +192 -99
  52. package/source/js/mdit/mermaid.js +12 -4
  53. package/source/js/swup.bundle.js +1 -0
  54. package/source/js/theme-selector.js +94 -113
  55. package/source/img/og_image.png +0 -0
  56. package/source/js/host/swup/Swup.umd.min.js +0 -1
  57. package/source/js/host/swup/head-plugin.umd.min.js +0 -1
  58. package/source/js/host/swup/scripts-plugin.umd.min.js +0 -2
  59. package/source/js/mdit/shiki.js +0 -158
@@ -1,6 +1,4 @@
1
- import { format } from "date-fns";
2
-
3
- const { Component, Fragment } = require("../../include/util/common");
1
+ const { Component, Fragment, dateFormatters } = require("../../include/util/common");
4
2
  const Comment = require("./comment");
5
3
  const ArticleLicensing = require("../misc/article_licensing");
6
4
  const ArticleCover = require("./article_cover");
@@ -50,14 +48,14 @@ module.exports = class extends Component {
50
48
  <div class="article-meta-info">
51
49
  {page.date && (
52
50
  <time class="article-date" datetime={page.date.toISOString()}>
53
- {format(page.date, "LLL dd")}
51
+ {dateFormatters.shortDay.format(page.date)}
54
52
  </time>
55
53
  )}
56
- {page.date && (wordCount > 0 || !index) && <span class="meta-separator">·</span>}
54
+ {page.date && (wordCount > 0 || !index) && <span class="meta-separator">/</span>}
57
55
  {wordCount > 0 && <span class="article-reading-time">{readTime} min</span>}
58
56
  {!index && (
59
57
  <Fragment>
60
- <span class="meta-separator">·</span>
58
+ <span class="meta-separator">/</span>
61
59
  <span
62
60
  class="article-visit-count"
63
61
  data-flag-title={page.title}
@@ -70,9 +68,8 @@ module.exports = class extends Component {
70
68
  </div>
71
69
  {page.tags?.length ? (
72
70
  <div class="article-tags-inline">
73
- {page.tags.map((tag, idx) => (
71
+ {page.tags.map((tag) => (
74
72
  <Fragment>
75
- {idx > 0 && <span class="meta-separator">,</span>}
76
73
  <a class="article-tag" rel="tag" href={url_for(tag.path)}>
77
74
  {tag.name}
78
75
  </a>
@@ -11,7 +11,17 @@ module.exports = class extends Component {
11
11
  return (
12
12
  <a href={url_for(page.link || page.path)} class="cover-image">
13
13
  <img class="cover-lqip" src={lqip_src} alt="placeholder" />
14
- <img class="cover-origin" src={cover} alt={page.title || cover} srcset={imageSrcset} referrerpolicy="no-referrer" decoding="async" loading={index ? "lazy" : "eager"} />
14
+ <img
15
+ class="cover-origin"
16
+ src={cover}
17
+ alt={page.title || cover}
18
+ srcset={imageSrcset}
19
+ sizes="(max-width: 768px) 100vw, (max-width: 1024px) 100vw, 960px"
20
+ referrerpolicy="no-referrer"
21
+ decoding="async"
22
+ loading={index ? "lazy" : "eager"}
23
+ fetchpriority={index ? undefined : "high"}
24
+ />
15
25
  </a>
16
26
  );
17
27
  }
@@ -1,14 +1,12 @@
1
1
  /**
2
2
  * Article media component, used in article lists such as archive page and recent posts widget
3
3
  */
4
- const { Component } = require("inferno");
5
- const { format, parseISO } = require("date-fns");
4
+ const { Component, dateFormatters, parseISO } = require("../../include/util/common");
6
5
 
7
6
  module.exports = class extends Component {
8
7
  render() {
9
8
  const { url, title, date } = this.props;
10
- // Formatted like May.15
11
- const formattedDate = format(parseISO(date), "MMM dd");
9
+ const formattedDate = dateFormatters.shortDay.format(parseISO(date));
12
10
 
13
11
  return (
14
12
  <article class="archive-item">
@@ -2,7 +2,7 @@ const { Component, cacheComponent } = require("../../include/util/common");
2
2
 
3
3
  class Footer extends Component {
4
4
  render() {
5
- const { siteTitle, siteYear, author, links, subdomains, archives, copyright, showVisitorCounter, visitorCounterTitle, ICPRecord } = this.props;
5
+ const { siteTitle, siteYear, author, links, subdomains, copyright, showVisitorCounter, visitorCounterTitle, ICPRecord } = this.props;
6
6
 
7
7
  const svg_line = (
8
8
  <svg aria-hidden="true" width="100%" height="8" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -25,10 +25,10 @@ class Footer extends Component {
25
25
  <p class="footer-meta">
26
26
  <span
27
27
  dangerouslySetInnerHTML={{
28
- __html: `&copy; ${siteYear} ${author || siteTitle}`,
28
+ __html: `&copy; 2022 - ${siteYear}`,
29
29
  }}
30
30
  ></span>
31
- &nbsp;Powered by Hexo&nbsp;& Icarus
31
+ &nbsp;Powered by Hexo
32
32
  {showVisitorCounter ? (
33
33
  <>
34
34
  <br />
@@ -72,7 +72,7 @@ class Footer extends Component {
72
72
  ? Object.keys(subdomains).map((name) => {
73
73
  const link = subdomains[name];
74
74
  return (
75
- <a class="footer-link" target="_blank" rel="noopener" title={name} href={link.url}>
75
+ <a class="footer-link" target="_self" rel="noopener" title={name} href={link.url}>
76
76
  {name}
77
77
  </a>
78
78
  );
@@ -82,34 +82,14 @@ class Footer extends Component {
82
82
  </div>
83
83
  );
84
84
 
85
- const footer_archives = (
86
- <div class="footer-column footer-archives">
87
- <p class="footer-heading">Archives</p>
88
- <div class="footer-links">
89
- {archives?.length
90
- ? archives.map((item) => (
91
- <a class="footer-link" href={item.url}>
92
- {item.year}
93
- </a>
94
- ))
95
- : null}
96
- </div>
97
- </div>
98
- );
99
-
100
85
  return (
101
- <>
102
- {" "}
103
- {svg_line}
104
- <footer class="footer">
105
- <div class="footer-grid">
106
- {footer_brand}
107
- {footer_subdomains}
108
- {footer_archives}
109
- {footer_social}
110
- </div>
111
- </footer>
112
- </>
86
+ <footer class="footer">
87
+ <div class="footer-grid">
88
+ {footer_brand}
89
+ {footer_subdomains}
90
+ {footer_social}
91
+ </div>
92
+ </footer>
113
93
  );
114
94
  }
115
95
  }
@@ -28,7 +28,7 @@ module.exports = class extends Component {
28
28
  const { site, config, helper, page } = this.props;
29
29
  const { url_for, is_post } = helper;
30
30
  const { url, head = {}, article } = config;
31
- const { meta = [], open_graph = {}, structured_data = {}, canonical_url = page.permalink, rss, favicon } = head;
31
+ const { meta = [], open_graph = {}, structured_data = {}, canonical_url = page.permalink, favicon } = head;
32
32
 
33
33
  const noIndex = helper.is_archive() || helper.is_tag();
34
34
 
@@ -51,15 +51,7 @@ module.exports = class extends Component {
51
51
  images.push(img[1]);
52
52
  }
53
53
  } else {
54
- images = [url_for("/img/og_image.png")];
55
- }
56
-
57
- let adsenseClientId = null;
58
- if (Array.isArray(config.widgets)) {
59
- const widget = config.widgets.find((widget) => widget.type === "adsense");
60
- if (widget) {
61
- adsenseClientId = widget.client_id;
62
- }
54
+ images = [url_for("/img/og_image.webp")];
63
55
  }
64
56
 
65
57
  let openGraphImages = images;
@@ -100,7 +92,7 @@ module.exports = class extends Component {
100
92
 
101
93
  return (
102
94
  <head>
103
- <script data-swup-ignore-script dangerouslySetInnerHTML={{ __html: themeInitScript }}></script>
95
+ <script dangerouslySetInnerHTML={{ __html: themeInitScript }}></script>
104
96
  <meta charset="utf-8" />
105
97
  <meta name="viewport" content="width=device-width, initial-scale=1" />
106
98
  {noIndex ? <meta name="robots" content="noindex" /> : null}
@@ -141,8 +133,8 @@ module.exports = class extends Component {
141
133
  />
142
134
  ) : null}
143
135
  {canonical_url ? <link rel="canonical" href={canonical_url} /> : null}
144
- {rss ? <link rel="alternate" href={url_for(rss)} title={config.title} type="application/atom+xml" /> : null}
145
136
  {favicon ? <link rel="icon" href={url_for(favicon)} /> : null}
137
+ <link rel="preload" href={url_for("/css/font/woff2/HomemadeApple.woff2")} as="font" type="font/woff2" crossorigin />
146
138
  <link rel="stylesheet" href={url_for("/css/default.css")} />
147
139
  <link rel="stylesheet" href={url_for("/css/responsive/mobile.css")} media="screen and (max-width:768px)" />
148
140
  <link rel="stylesheet" href={url_for("/css/responsive/tablet.css")} media="screen and (min-width:769px)" />
@@ -152,9 +144,9 @@ module.exports = class extends Component {
152
144
  {/* Maple Mono CN */}
153
145
  <link rel="preconnect" href="https://fontsapi.zeoseven.com" />
154
146
  <link rel="preload" as="style" href="https://fontsapi.zeoseven.com/442/main/result.css" onload="this.onload=null;this.rel='stylesheet'" />
155
- <link rel="stylesheet" href="/css/shiki/shiki.css" />
147
+ <link rel="preload" as="style" href="/css/shiki/shiki.css" onload="this.onload=null;this.rel='stylesheet'" />
148
+ {page.encrypt ? <link rel="stylesheet" href={url_for("/css/encrypt.css")} /> : null}
156
149
  <Plugins site={site} config={config} helper={helper} page={page} head={true} />
157
- {adsenseClientId ? <script data-swup-ignore-script data-ad-client={adsenseClientId} src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" async></script> : null}
158
150
  </head>
159
151
  );
160
152
  }
@@ -35,8 +35,8 @@ class Navbar extends Component {
35
35
  const { siteUrl, menu, links, searchTitle } = this.props;
36
36
 
37
37
  return (
38
- <nav class="navbar navbar-main" onclick="handleNavbarClick(event);">
39
- <div class="navbar-container">
38
+ <nav class="navbar navbar-main">
39
+ <div class="navbar-container" onclick="toggleNav(event)">
40
40
  <a href={siteUrl} style={"font-family: homemade-apple; color: var(--text); display: flex; align-items: center; padding: 0 1em;"}>
41
41
  GnixAij
42
42
  </a>
@@ -67,7 +67,7 @@ class Navbar extends Component {
67
67
  })}
68
68
  </Fragment>
69
69
  ) : null}
70
- <button type="button" class="navbar-item" id="theme-selector-trigger" title="Choose Theme" onclick="window.openThemeModal?.()">
70
+ <button type="button" class="navbar-item" title="Choose Theme" popovertarget="theme-selector-popover">
71
71
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
72
72
  <title>brightness_fill</title>
73
73
  <g id="brightness_fill" fill="currentColor">
@@ -75,7 +75,7 @@ class Navbar extends Component {
75
75
  </g>
76
76
  </svg>
77
77
  </button>
78
- <button type="button" class="navbar-item search" title={searchTitle}>
78
+ <button type="button" class="navbar-item search" popovertarget="searchbox" title={searchTitle}>
79
79
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
80
80
  <title>search_line</title>
81
81
  <g id="search_line" fill="currentColor">
@@ -10,12 +10,12 @@ module.exports = class extends Component {
10
10
  <Fragment>
11
11
  <Plugins site={site} config={config} page={page} helper={helper} head={false} />
12
12
  <Swup head={false} />
13
- <script data-swup-ignore-script defer src="/js/host/iconify-icon/3.0.2/iconify-icon.min.js"></script>
14
- <script data-swup-ignore-script defer src="/js/theme-selector.js"></script>
15
- <script data-swup-ignore-script defer src="/js/host/medium-zoom/dist/medium-zoom.min.js"></script>
16
- <script data-swup-ignore-script defer src="/js/mdit/shiki.js"></script>
17
- <script data-swup-ignore-script defer src="/js/main.js"></script>
18
- <script data-swup-ignore-script async src="/js/instant-page.min.js" type="module"></script>
13
+ <script defer src="/js/host/iconify-icon/3.0.2/iconify-icon.min.js"></script>
14
+ <script defer src="/js/theme-selector.js"></script>
15
+ <script defer src="/js/host/medium-zoom/dist/medium-zoom.min.js"></script>
16
+ <script defer src="/js/main.js"></script>
17
+ {page.encrypt ? <script src="/js/decrypt.js" type="module"></script> : null}
18
+ <script async src="/js/instant-page.min.js" type="module"></script>
19
19
  </Fragment>
20
20
  );
21
21
  }
@@ -13,13 +13,12 @@ const themes = [
13
13
  class ThemeSelector extends Component {
14
14
  render() {
15
15
  return (
16
- <div id="theme-selector-modal" onclick="window.handleThemeModalClick?.(event)">
17
- <div class="theme-selector-backdrop"></div>
18
- <div class="theme-selector-list">
16
+ <div id="theme-selector-popover" popover="auto" tabindex="-1">
17
+ <div class="theme-selector-list" role="listbox" aria-label="Select theme">
19
18
  {themes.map((theme, index) => (
20
- <div class="theme-option" data-theme-option={theme.value} data-index={index} onclick={`window.selectThemeOption?.(event, ${index})`}>
21
- <span class="theme-name">{theme.name}</span>
22
- </div>
19
+ <button class="theme-option" type="submit" data-theme-option={theme.value} data-index={index} onclick={`window.selectThemeOption?.(${index})`}>
20
+ {theme.name}
21
+ </button>
23
22
  ))}
24
23
  </div>
25
24
  </div>
@@ -8,25 +8,19 @@ class FloatingToc extends Component {
8
8
  list_number: false,
9
9
  });
10
10
 
11
- if (!tocContent) {
11
+ if (!tocContent && !page.encrypt) {
12
12
  return null;
13
13
  }
14
14
 
15
15
  return (
16
- <div class="toc-container" id="icarus-toc-container">
17
- <button class="toc-button" type="button" onclick="document.getElementById('icarus-toc-container').classList.toggle('is-open')">
18
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
19
- <title>Table of Contents</title>
20
- <line x1="8" y1="6" x2="21" y2="6"></line>
21
- <line x1="8" y1="12" x2="21" y2="12"></line>
22
- <line x1="8" y1="18" x2="21" y2="18"></line>
23
- <line x1="3" y1="6" x2="3.01" y2="6"></line>
24
- <line x1="3" y1="12" x2="3.01" y2="12"></line>
25
- <line x1="3" y1="18" x2="3.01" y2="18"></line>
26
- </svg>
16
+ <div class="toc-container" id="icarus-toc-container" style={page.encrypt ? "display:none" : null}>
17
+ <button class="toc-button" type="button" popovertarget="toc-body" aria-label="Table of Contents">
18
+ <span aria-hidden="true"></span>
19
+ <span aria-hidden="true"></span>
20
+ <span aria-hidden="true"></span>
27
21
  </button>
28
- <div class="toc-body" onclick="if(event.target === this || event.target.matches('.toc-link')) { document.getElementById('icarus-toc-container').classList.remove('is-open'); }">
29
- <div dangerouslySetInnerHTML={{ __html: tocContent }} />
22
+ <div id="toc-body" popover="auto" class="toc-body" onclick="if(event.target===this||event.target.closest('.toc-link'))this.hidePopover();">
23
+ <div id="toc-insert" dangerouslySetInnerHTML={{ __html: tocContent || "" }} />
30
24
  </div>
31
25
  </div>
32
26
  );
package/layout/index.jsx CHANGED
@@ -5,16 +5,14 @@ const Article = require("./common/article");
5
5
  module.exports = class extends Component {
6
6
  render() {
7
7
  const { config, page, helper } = this.props;
8
- const { __, url_for } = helper;
8
+ const { url_for } = helper;
9
9
 
10
10
  return (
11
11
  <Fragment>
12
12
  {page.posts.map((post) => (
13
13
  <Article config={config} page={post} helper={helper} index={true} />
14
14
  ))}
15
- {page.total > 1 ? (
16
- <Paginator current={page.current} total={page.total} baseUrl={page.base} path={config.pagination_dir} urlFor={url_for} prevTitle={__("common.prev")} nextTitle={__("common.next")} />
17
- ) : null}
15
+ {page.total > 1 ? <Paginator current={page.current} total={page.total} baseUrl={page.base} path={config.pagination_dir} urlFor={url_for} /> : null}
18
16
  </Fragment>
19
17
  );
20
18
  }
@@ -15,10 +15,12 @@ class ArticleLicensing extends Component {
15
15
  <div class="licensing-title">
16
16
  {title ? <p>{title}</p> : null}
17
17
  <p>
18
- <a href={link}>{link}</a>
18
+ <a style="text-decoration: none" href={link}>
19
+ {link}
20
+ </a>
19
21
  </p>
20
22
  </div>
21
- <div class="licensing-meta level is-mobile">
23
+ <div class="licensing-meta level">
22
24
  <div style="display: flex">
23
25
  {author ? (
24
26
  <div class="level-item">
@@ -1,6 +1,6 @@
1
- const { isDate, parseISO, isValid } = require("date-fns");
2
- const { Component } = require("inferno");
1
+ const { Component, isValidDate, parseISO } = require("../../include/util/common");
3
2
  const { encodeURL, stripHTML, escapeHTML } = require("hexo-util");
3
+
4
4
  const localeMap = {
5
5
  en: "en_US",
6
6
  de: "de_DE",
@@ -63,14 +63,14 @@ module.exports = class extends Component {
63
63
 
64
64
  if (date) {
65
65
  const d = typeof date === "string" ? parseISO(date) : date;
66
- if ((isDate(d) || d instanceof Date) && isValid(d)) {
66
+ if (isValidDate(d)) {
67
67
  htmlTags.push(<meta property="article:published_time" content={d.toISOString()} />);
68
68
  }
69
69
  }
70
70
 
71
71
  if (updated) {
72
72
  const u = typeof updated === "string" ? parseISO(updated) : updated;
73
- if ((isDate(u) || u instanceof Date) && isValid(u)) {
73
+ if (isValidDate(u)) {
74
74
  htmlTags.push(<meta property="article:modified_time" content={u.toISOString()} />);
75
75
  }
76
76
  }
@@ -2,7 +2,7 @@ const { Component } = require("inferno");
2
2
 
3
3
  module.exports = class extends Component {
4
4
  render() {
5
- const { current, total, baseUrl, path, urlFor, prevTitle, nextTitle } = this.props;
5
+ const { current, total, baseUrl, path, urlFor } = this.props;
6
6
 
7
7
  function getPageUrl(i) {
8
8
  return urlFor(i === 1 ? baseUrl : `${baseUrl + path}/${i}/`);
@@ -55,12 +55,18 @@ module.exports = class extends Component {
55
55
  }
56
56
 
57
57
  return (
58
- <nav class="pagination is-centered" aria-label="pagination" style="padding-top: 1.5em;">
58
+ <nav class="pagination card" aria-label="pagination">
59
59
  <a href={getPageUrl(current - 1)} class={`pagination-previous`} style={current > 1 ? {} : { visibility: "hidden" }}>
60
- {prevTitle}
60
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
61
+ <title>go to previous page</title>
62
+ <path fill="currentColor" d="m4 10l9 9l1.4-1.5L7 10l7.4-7.5L13 1z" />
63
+ </svg>
61
64
  </a>
62
65
  <a href={getPageUrl(current + 1)} class={`pagination-next`} style={current < total ? {} : { visibility: "hidden" }}>
63
- {nextTitle}
66
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
67
+ <title>go to next page</title>
68
+ <path fill="currentColor" d="M7 1L5.6 2.5L13 10l-7.4 7.5L7 19l9-9z" />
69
+ </svg>
64
70
  </a>
65
71
  <ul class="pagination-list is-hidden-mobile">{pagination(current, total)}</ul>
66
72
  </nav>
@@ -1,5 +1,4 @@
1
- const { isDate, parseISO, isValid } = require("date-fns");
2
- const { Component } = require("inferno");
1
+ const { Component, isValidDate, parseISO } = require("../../include/util/common");
3
2
  const { stripHTML, escapeHTML } = require("hexo-util");
4
3
 
5
4
  module.exports = class extends Component {
@@ -28,14 +27,14 @@ module.exports = class extends Component {
28
27
 
29
28
  if (date) {
30
29
  const d = typeof date === "string" ? parseISO(date) : date;
31
- if ((isDate(d) || d instanceof Date) && isValid(d)) {
30
+ if (isValidDate(d)) {
32
31
  date = d.toISOString();
33
32
  }
34
33
  }
35
34
 
36
35
  if (updated) {
37
36
  const u = typeof updated === "string" ? parseISO(updated) : updated;
38
- if ((isDate(u) || u instanceof Date) && isValid(u)) {
37
+ if (isValidDate(u)) {
39
38
  updated = u.toISOString();
40
39
  }
41
40
  }
@@ -4,7 +4,7 @@ class Busuanzi extends Component {
4
4
  render() {
5
5
  return (
6
6
  // busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js
7
- <script defer src="/js/busuanzi.js"></script>
7
+ <script data-swup-reload-script defer src="/js/busuanzi.js"></script>
8
8
  // <script src="https://vercount.one/js" defer={true}></script>
9
9
  );
10
10
  }
@@ -1,46 +1,55 @@
1
1
  const { Component, cacheComponent } = require("../../include/util/common");
2
2
 
3
3
  class CookieConsent extends Component {
4
+ // https://www.osano.com/cookieconsent/documentation/javascript-api/
4
5
  render() {
5
6
  const { head, text, jsUrl, cssUrl } = this.props;
6
7
  const { type, theme, position, policyLink } = this.props;
7
8
  const { message, dismiss, allow, deny, link, policy } = text;
8
9
 
9
- const js = `window.addEventListener("load", () => {
10
- window.cookieconsent.initialise({
11
- type: ${JSON.stringify(type)},
12
- theme: ${JSON.stringify(theme)},
13
- static: ${JSON.stringify(this.props.static)},
14
- position: ${JSON.stringify(position)},
15
- content: {
16
- message: ${JSON.stringify(message)},
17
- dismiss: ${JSON.stringify(dismiss)},
18
- allow: ${JSON.stringify(allow)},
19
- deny: ${JSON.stringify(deny)},
20
- link: ${JSON.stringify(link)},
21
- policy: ${JSON.stringify(policy)},
22
- href: ${JSON.stringify(policyLink)},
23
- },
24
- palette: {
25
- popup: {
26
- background: "var(--base)",
27
- text: "var(--text)"
28
- },
29
- button: {
30
- background: "var(--blue)"
31
- },
32
- },
33
- });
34
- });`;
35
-
36
10
  if (head) {
37
11
  return <link rel="preload" href={cssUrl} as="style" onload="this.onload=null;this.rel='stylesheet'" />;
38
12
  }
39
13
  return (
40
- <>
41
- <script src={jsUrl} defer={true} onLoad={js}></script>
42
- {/* <script dangerouslySetInnerHTML={{ __html: js }}></script> */}
43
- </>
14
+ <script
15
+ dangerouslySetInnerHTML={{
16
+ __html: `
17
+ (function() {
18
+ var s = document.createElement('script');
19
+ s.src = ${JSON.stringify(jsUrl)};
20
+ s.defer = true;
21
+ s.onload = function() {
22
+ window.cookieconsent.initialise(${JSON.stringify({
23
+ type,
24
+ theme,
25
+ static: this.props.static,
26
+ position,
27
+ content: {
28
+ message,
29
+ dismiss,
30
+ allow,
31
+ deny,
32
+ link,
33
+ policy,
34
+ href: policyLink,
35
+ },
36
+ palette: {
37
+ popup: {
38
+ background: "var(--base)",
39
+ text: "var(--text)",
40
+ },
41
+ button: {
42
+ background: "var(--lavender)",
43
+ text: "var(--base)",
44
+ },
45
+ },
46
+ })});
47
+ };
48
+ document.body.appendChild(s);
49
+ })();
50
+ `,
51
+ }}
52
+ />
44
53
  );
45
54
  }
46
55
  }
@@ -1,4 +1,4 @@
1
- const { Component, Fragment } = require("../../include/util/common");
1
+ const { Component } = require("../../include/util/common");
2
2
 
3
3
  class Swup extends Component {
4
4
  render() {
@@ -6,27 +6,7 @@ class Swup extends Component {
6
6
  return null;
7
7
  }
8
8
 
9
- const swupScript = `
10
- const swup = new Swup({
11
- containers: ["#swup"],
12
- cache: true,
13
- native: true,
14
- plugins: [
15
- new SwupHeadPlugin({
16
- persistTags: true
17
- }),
18
- new SwupScriptsPlugin()
19
- ]
20
- });
21
- `;
22
- return (
23
- <Fragment>
24
- <script src="/js/host/swup/Swup.umd.min.js"></script>
25
- <script src="/js/host/swup/head-plugin.umd.min.js"></script>
26
- <script src="/js/host/swup/scripts-plugin.umd.min.js"></script>
27
- <script data-swup-ignore-script dangerouslySetInnerHTML={{ __html: swupScript }}></script>
28
- </Fragment>
29
- );
9
+ return <script defer src="/js/swup.bundle.js"></script>;
30
10
  }
31
11
  }
32
12
 
@@ -13,12 +13,25 @@ class Insight extends Component {
13
13
 
14
14
  return (
15
15
  <>
16
- <div class="searchbox">
16
+ <div class="searchbox" id="searchbox" popover="auto">
17
17
  <div class="searchbox-container">
18
18
  <div class="searchbox-input-container">
19
- <input type="text" name="search-input" class="searchbox-input" placeholder={translation.hint} />
19
+ <input
20
+ type="text"
21
+ name="search-input"
22
+ class="searchbox-input"
23
+ placeholder={translation.hint}
24
+ autofocus
25
+ autocomplete="off"
26
+ role="combobox"
27
+ aria-haspopup="listbox"
28
+ aria-autocomplete="list"
29
+ aria-controls="searchbox-results"
30
+ aria-expanded="false"
31
+ aria-label={translation.hint}
32
+ />
20
33
  </div>
21
- <div class="searchbox-body"></div>
34
+ <div class="searchbox-body" id="searchbox-results" role="listbox"></div>
22
35
  </div>
23
36
  </div>
24
37
  <script defer src={jsUrl}></script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-gnix",
3
- "version": "6.2.0",
3
+ "version": "8.0.0",
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.",
@@ -21,7 +21,8 @@
21
21
  "lint": "biome check --write .",
22
22
  "format": "biome format .",
23
23
  "check": "biome check",
24
- "test": "echo \"No tests configured\" && exit 0"
24
+ "test": "echo \"No tests configured\" && exit 0",
25
+ "build:swup": "bun build src/swup.js --outfile source/js/swup.bundle.js --minify"
25
26
  },
26
27
  "files": [
27
28
  "include",
@@ -33,13 +34,16 @@
33
34
  "README.md"
34
35
  ],
35
36
  "dependencies": {
36
- "date-fns": "^4.1.0",
37
- "esbuild": "^0.27.2",
37
+ "@swup/head-plugin": "^2.3.1",
38
+ "@swup/scripts-plugin": "^2.1.0",
39
+ "esbuild": "^0.28.0",
40
+ "feedsmith": "^2.9.1",
38
41
  "hexo-pagination": "^4.0.0",
39
- "inferno": "^9.0.10",
40
- "inferno-create-element": "^9.0.10",
41
- "inferno-server": "^9.0.10",
42
- "js-yaml": "^4.1.1"
42
+ "inferno": "^9.1.0",
43
+ "inferno-create-element": "^9.1.0",
44
+ "inferno-server": "^9.1.0",
45
+ "js-yaml": "^4.1.1",
46
+ "swup": "^4.8.3"
43
47
  },
44
48
  "peerDependencies": {
45
49
  "hexo": "^8.1.1",