hexo-theme-gnix 13.0.0 → 14.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.
@@ -13,7 +13,6 @@ const renderLinkIcon = (link) => {
13
13
  </svg>
14
14
  );
15
15
  }
16
- return <iconify-icon icon={link.icon}></iconify-icon>;
17
16
  };
18
17
 
19
18
  function getTargetLanguageKey(config, currentLanguageKey) {
@@ -57,8 +56,7 @@ function getLanguageSwitch(site, page, config, helper) {
57
56
  const mode = !url && isDocumentPage ? "missing" : "link";
58
57
 
59
58
  if (!url && mode === "link") {
60
- const targetPath = page?.current > 1 ? "/" : (page?.path || "/");
61
- url = helper.localized_url_for(targetPath, targetLanguageKey);
59
+ url = helper.localized_url_for(page?.path || "/", targetLanguageKey);
62
60
  }
63
61
 
64
62
  return {
@@ -89,7 +87,7 @@ class Navbar extends Component {
89
87
  <Fragment>
90
88
  <nav class="navbar navbar-main">
91
89
  <div class="navbar-container" onclick="toggleNav(event)">
92
- <a id="navbar-logo-link" href={siteUrl} style={"font-family: homemade-apple; color: var(--text); display: flex; align-items: center; padding: 0 1em;"}>
90
+ <a id="navbar-logo-link" class="navbar-logo" href={siteUrl}>
93
91
  GnixAij
94
92
  </a>
95
93
  <div class="navbar-menu">
@@ -119,14 +117,19 @@ class Navbar extends Component {
119
117
  </Fragment>
120
118
  ) : null}
121
119
  {languageSwitch ? (
122
- <Fragment>
123
- <a id="language-switch-link" class="navbar-item" href={languageSwitch.url || '#'} title={languageSwitch.title} aria-label={languageSwitch.title} lang={languageSwitch.locale} hreflang={languageSwitch.locale} style={languageSwitch.mode === 'link' ? '' : 'display:none'}>
124
- {languageIcon}
125
- </a>
126
- <button id="language-switch-button" type="button" class="navbar-item" title={languageSwitch.title} aria-label={languageSwitch.title} lang={languageSwitch.locale} data-toast-message={languageSwitch.unavailableMessage} onclick="window.showSiteToast?.(this.dataset.toastMessage); return false;" style={languageSwitch.mode === 'missing' ? '' : 'display:none'}>
127
- {languageIcon}
128
- </button>
129
- </Fragment>
120
+ <a
121
+ id="language-switch"
122
+ class="navbar-item"
123
+ href={languageSwitch.url || "#"}
124
+ title={languageSwitch.title}
125
+ aria-label={languageSwitch.title}
126
+ lang={languageSwitch.locale}
127
+ hreflang={languageSwitch.locale}
128
+ data-mode={languageSwitch.mode}
129
+ data-toast-message={languageSwitch.unavailableMessage}
130
+ >
131
+ {languageIcon}
132
+ </a>
130
133
  ) : null}
131
134
  <button type="button" class="navbar-item" title="Choose Theme" popovertarget="theme-selector-popover">
132
135
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
@@ -10,9 +10,9 @@ 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 defer src="/js/host/iconify-icon/3.0.2/iconify-icon.min.js"></script>
14
13
  <script defer src="/js/theme-selector.js"></script>
15
14
  <script defer src="/js/host/medium-zoom/dist/medium-zoom.min.js"></script>
15
+ <script defer src="/js/components/archive-popup.js"></script>
16
16
  <script defer src="/js/main.js"></script>
17
17
  {page.encrypt ? <script src="/js/decrypt.js" type="module"></script> : null}
18
18
  <script async src="/js/instant-page.min.js" type="module"></script>
package/layout/layout.jsx CHANGED
@@ -25,22 +25,23 @@ function buildLangSwitchScript(site, page, config, helper) {
25
25
  mode: lswitch.mode,
26
26
  url: lswitch.url || "",
27
27
  locale: lswitch.locale,
28
+ title: lswitch.title,
29
+ unavailableMessage: lswitch.unavailableMessage,
28
30
  })
29
31
  : "null";
30
32
 
31
33
  return `<script data-swup-reload-script>
32
34
  (function() {
33
35
  var d = ${payload};
34
- var l = document.getElementById('language-switch-link');
35
- var b = document.getElementById('language-switch-button');
36
- if (l || b) {
37
- if (d && d.mode === 'link' && d.url) {
38
- if (l) { l.href = d.url; l.style.display = ''; l.setAttribute('lang', d.locale); l.setAttribute('hreflang', d.locale); }
39
- if (b) b.style.display = 'none';
40
- } else {
41
- if (l) l.style.display = 'none';
42
- if (b) { b.style.display = ''; b.setAttribute('lang', d.locale); }
43
- }
36
+ var el = document.getElementById('language-switch');
37
+ if (el && d) {
38
+ el.href = d.mode === 'link' && d.url ? d.url : '#';
39
+ el.title = d.title;
40
+ el.setAttribute('aria-label', d.title);
41
+ el.setAttribute('lang', d.locale);
42
+ el.setAttribute('hreflang', d.locale);
43
+ el.dataset.mode = d.mode;
44
+ el.dataset.toastMessage = d.unavailableMessage;
44
45
  }
45
46
  var menu = ${JSON.stringify(menu)};
46
47
  Object.keys(menu).forEach(function(name) {
@@ -51,7 +52,7 @@ function buildLangSwitchScript(site, page, config, helper) {
51
52
  var logo = document.getElementById('navbar-logo-link');
52
53
  if (logo) logo.href = ${JSON.stringify(siteUrl)};
53
54
  })();
54
- <\/script>`;
55
+ </script>`;
55
56
  }
56
57
 
57
58
  module.exports = class extends Component {
package/layout/tag.jsx CHANGED
@@ -1,75 +1,8 @@
1
- const { Component, Fragment } = require("../include/util/common");
2
- const Index = require("./index");
3
-
4
- const breadcrumb_css = `
5
- /* 定义闪烁动画 */
6
- @keyframes blink {
7
- 0%, 100% { opacity: 1; }
8
- 50% { opacity: 0; }
9
- }
10
-
11
- .breadcrumb {
12
- color: var(--blue);
13
- white-space: nowrap;
14
- font-family: var(--font-mono);
15
-
16
- a {
17
- align-items: center;
18
- display: flex;
19
- justify-content: center;
20
- padding: 0 0.1em;
21
- }
22
-
23
- ul {
24
- padding-inline-start: 1em;
25
- align-items: flex-start;
26
- display: flex;
27
- flex-wrap: wrap;
28
- justify-content: flex-start;
29
- }
30
-
31
- li {
32
- align-items: center;
33
- display: flex;
34
- a {
35
- color: var(--yellow);
36
- }
37
- }
38
-
39
- .cursor {
40
- display: inline-block;
41
- color: var(--mauve);
42
- font-weight: bold;
43
- margin-left: 2px;
44
- animation: blink 1s step-end infinite;
45
- }
46
- }`;
1
+ const { Component } = require("../include/util/common");
2
+ const Archive = require("./archive");
47
3
 
48
4
  module.exports = class extends Component {
49
5
  render() {
50
- const { config, page, helper } = this.props;
51
- const { _p } = helper;
52
- const langKey = helper.language_key(page);
53
-
54
- return (
55
- <Fragment>
56
- <style>{breadcrumb_css}</style>
57
- <nav class="breadcrumb" aria-label="breadcrumbs">
58
- <ul>
59
- <li>
60
- <font style="color: var(--green)">$</font>&nbsp;ls&nbsp;
61
- <a href={helper.localized_url_for("/tags/", langKey)}>{_p("common.tag", Infinity)}/</a>
62
- </li>
63
- <li>
64
- <a href="#" aria-current="page" style="cursor: default; pointer-events: none; color: var(--mauve);">
65
- {page.tag}
66
- </a>
67
- <span class="cursor">_</span>
68
- </li>
69
- </ul>
70
- </nav>
71
- <Index config={config} page={page} helper={helper} />
72
- </Fragment>
73
- );
6
+ return <Archive {...this.props} />;
74
7
  }
75
8
  };
package/layout/tags.jsx CHANGED
@@ -1,6 +1,23 @@
1
1
  const { Component, Fragment, cacheComponent } = require("../include/util/common");
2
2
  const { filterByLanguage } = require("../include/util/i18n");
3
3
 
4
+ function toRoman(num) {
5
+ const map = [
6
+ [1000, "M"], [900, "CM"], [500, "D"], [400, "CD"],
7
+ [100, "C"], [90, "XC"], [50, "L"], [40, "XL"],
8
+ [10, "X"], [9, "IX"], [5, "V"], [4, "IV"], [1, "I"],
9
+ ];
10
+ let n = num;
11
+ let out = "";
12
+ for (const [value, sym] of map) {
13
+ while (n >= value) {
14
+ out += sym;
15
+ n -= value;
16
+ }
17
+ }
18
+ return out;
19
+ }
20
+
4
21
  function getTagSize(count, maxCount) {
5
22
  const ratio = maxCount ? count / maxCount : 0;
6
23
  return `${(0.95 + ratio * 0.35).toFixed(3)}rem`;
@@ -8,7 +25,7 @@ function getTagSize(count, maxCount) {
8
25
 
9
26
  class Tags extends Component {
10
27
  render() {
11
- const { cssUrl, tags, title, showCount, totalPosts, topTag } = this.props;
28
+ const { cssUrl, tags, title, showCount } = this.props;
12
29
 
13
30
  return (
14
31
  <Fragment>
@@ -16,26 +33,16 @@ class Tags extends Component {
16
33
  <main class="tags-page">
17
34
  <header class="tags-hero">
18
35
  <div>
19
- <p class="tags-eyebrow">Topic Index</p>
20
- <h1>{title}</h1>
21
- <p class="tags-hero__summary">
22
- {tags.length ? `Browse ${tags.length} topics across ${totalPosts} tagged ${totalPosts === 1 ? "post" : "posts"}.` : "No tagged posts are available yet."}
36
+ <p class="tags-eyebrow">
37
+ <span>Topic Index</span>
38
+ <span class="tags-hero__sep" aria-hidden="true">·</span>
39
+ <span>{tags.length} {tags.length === 1 ? "topic" : "topics"}</span>
23
40
  </p>
41
+ <h1>{title}</h1>
24
42
  </div>
25
- <dl class="tags-stats" aria-label="Tags summary">
26
- <div>
27
- <dt>Tags</dt>
28
- <dd>{tags.length}</dd>
29
- </div>
30
- <div>
31
- <dt>Posts</dt>
32
- <dd>{totalPosts}</dd>
33
- </div>
34
- <div>
35
- <dt>Largest</dt>
36
- <dd>{topTag ? topTag.name : "None"}</dd>
37
- </div>
38
- </dl>
43
+ {tags.length > 0 && (
44
+ <span class="tags-hero__roman" aria-hidden="true">{toRoman(tags.length)}</span>
45
+ )}
39
46
  </header>
40
47
 
41
48
  <nav class="tags-index" aria-label={title}>
@@ -87,15 +94,11 @@ Tags.Cacheable = cacheComponent(Tags, "page.tags", (props) => {
87
94
  };
88
95
  });
89
96
  const maxCount = mappedTags.reduce((max, tag) => Math.max(max, tag.count), 0);
90
- const totalPosts = mappedTags.reduce((total, tag) => total + tag.count, 0);
91
- const topTag = mappedTags.reduce((top, tag) => (tag.count > top.count ? tag : top), mappedTags[0]);
92
97
 
93
98
  return {
94
99
  cssUrl: helper.url_for("/css/tags.css"),
95
100
  showCount: show_count,
96
101
  title: _p("common.tag", Infinity),
97
- totalPosts,
98
- topTag,
99
102
  tags: mappedTags.map((tag) => ({
100
103
  ...tag,
101
104
  size: getTagSize(tag.count, maxCount),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-gnix",
3
- "version": "13.0.0",
3
+ "version": "14.0.0",
4
4
  "author": "Efterklang <gaojiaxing0220@gmail.com> (https://vluv.space)",
5
5
  "license": "MIT",
6
6
  "description": "Second generation of Hexo theme Icarus, now with Catppuccin flavor and night mode support.",
@@ -43,9 +43,9 @@
43
43
  "markdown-exit": "^1.0.0-beta.9",
44
44
  "markdown-exit-mermaid": "^2.2.3",
45
45
  "markdown-exit-ratex": "^0.2.2",
46
- "@shikijs/colorized-brackets": "^4.0.2",
47
- "@shikijs/transformers": "^4.0.2",
48
- "shiki": "^4.0.2",
46
+ "@shikijs/colorized-brackets": "^4.1.0",
47
+ "@shikijs/transformers": "^4.1.0",
48
+ "shiki": "^4.1.0",
49
49
  "markdown-it-anchor": "^9.2.0",
50
50
  "markdown-it-footnote": "^4.0.0",
51
51
  "markdown-it-mark": "^4.0.0",