hexo-theme-gnix 9.0.0 → 10.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 (66) hide show
  1. package/README.md +4 -2
  2. package/include/hexo/feed.js +5 -5
  3. package/include/hexo/filter.js +25 -1
  4. package/include/hexo/generator/archive.js +116 -0
  5. package/include/hexo/generator/home.js +64 -0
  6. package/include/hexo/generator/index.js +82 -0
  7. package/include/hexo/generator/md_generator.js +87 -0
  8. package/include/hexo/generator/page.js +55 -0
  9. package/include/hexo/generator/tag.js +84 -0
  10. package/include/hexo/helper.js +38 -0
  11. package/include/hexo/i18n.js +183 -0
  12. package/include/util/article_font.js +132 -0
  13. package/include/util/i18n.js +280 -0
  14. package/include/util/theme.js +84 -0
  15. package/languages/en.yml +28 -0
  16. package/languages/zh-CN.yml +28 -0
  17. package/layout/archive.jsx +131 -127
  18. package/layout/common/article.jsx +283 -16
  19. package/layout/common/article_info.jsx +339 -0
  20. package/layout/common/article_media.jsx +11 -4
  21. package/layout/common/comment.jsx +15 -7
  22. package/layout/common/footer.jsx +6 -5
  23. package/layout/common/head.jsx +121 -32
  24. package/layout/common/navbar.jsx +195 -65
  25. package/layout/common/theme_selector.jsx +16 -14
  26. package/layout/layout.jsx +43 -5
  27. package/layout/misc/open_graph.jsx +162 -66
  28. package/layout/misc/paginator.jsx +2 -8
  29. package/layout/plugin/cookie_consent.jsx +252 -53
  30. package/layout/plugin/swup.jsx +1 -1
  31. package/layout/search/insight.jsx +1 -1
  32. package/layout/tag.jsx +3 -2
  33. package/layout/tags.jsx +81 -73
  34. package/package.json +5 -5
  35. package/scripts/index.js +1 -0
  36. package/source/css/archive.css +225 -180
  37. package/source/css/default.css +1162 -98
  38. package/source/css/responsive.css +426 -0
  39. package/source/css/shiki/shiki.css +12 -2081
  40. package/source/css/tags.css +183 -0
  41. package/source/css/twikoo.css +1049 -1045
  42. package/source/img/favicon.svg +1 -6
  43. package/source/img/og_image.webp +0 -0
  44. package/source/js/article-font-utils.js +99 -0
  45. package/source/js/busuanzi.js +91 -24
  46. package/source/js/components/chat.js +169 -50
  47. package/source/js/components/image-carousel.js +152 -108
  48. package/source/js/components/sidenote.js +210 -0
  49. package/source/js/components/text-image-section.js +78 -90
  50. package/source/js/components/theme-stacked.js +65 -33
  51. package/source/js/components/tree.js +30 -16
  52. package/source/js/decrypt.js +7 -2
  53. package/source/js/main.js +428 -5
  54. package/source/js/swup.js +39 -0
  55. package/source/js/theme-selector.js +26 -16
  56. package/include/hexo/generator.js +0 -53
  57. package/layout/misc/article_licensing.jsx +0 -99
  58. package/source/css/responsive/desktop.css +0 -36
  59. package/source/css/responsive/mobile.css +0 -29
  60. package/source/css/responsive/tablet.css +0 -43
  61. package/source/css/responsive/touch.css +0 -155
  62. package/source/img/logo.svg +0 -9
  63. package/source/js/archive-breadcrumb.js +0 -132
  64. package/source/js/host/cookieconsent/3.1.1/build/cookieconsent.min.css +0 -6
  65. package/source/js/host/cookieconsent/3.1.1/build/cookieconsent.min.js +0 -1
  66. package/source/js/swup.bundle.js +0 -1
package/layout/tags.jsx CHANGED
@@ -1,104 +1,112 @@
1
- const { Component, cacheComponent } = require("../include/util/common");
1
+ const { Component, Fragment, cacheComponent } = require("../include/util/common");
2
+ const { filterByLanguage } = require("../include/util/i18n");
3
+
4
+ function getTagSize(count, maxCount) {
5
+ const ratio = maxCount ? count / maxCount : 0;
6
+ return `${(0.95 + ratio * 0.35).toFixed(3)}rem`;
7
+ }
2
8
 
3
9
  class Tags extends Component {
4
10
  render() {
5
- const { tags, showCount } = this.props;
6
-
7
- const inlineCSS = `
8
- .tags {
9
- font-family: var(--font-mono);
10
- flex-wrap: wrap;
11
- justify-content: flex-start;
12
- padding: 0.5rem 0.5rem;
13
- display: inline-flex;
14
- align-items: center;
15
- transition: all 0.3s ease;
16
- }
17
-
18
- .tags:hover {
19
- transform: translateY(-2px);
20
- }
21
-
22
- .tag {
23
- color: var(--text);
24
- border-color: var(--surface0);
25
- padding: 0 0.75em;
26
- transition: all 0.3s ease;
27
- border-style: solid;
28
- align-items: center;
29
- border-radius: 5px;
30
- display: inline-flex;
31
- font-size: 0.75rem;
32
- height: 2em;
33
- white-space: nowrap;
34
- }
35
-
36
- .tag:first-child {
37
- border-width: 1px 0 1px 1px;
38
- border-radius: 5px 0 0 5px;
39
- background: var(--base);
40
- }
41
-
42
- .tag:first-child::before {
43
- content: "#";
44
- opacity: 0.7;
45
- margin-right: 0.25em;
46
- }
47
-
48
- .tag:last-child {
49
- background: var(--mantle);
50
- border-width: 1px 1px 1px 0;
51
- border-radius: 0 5px 5px 0;
52
- }
53
- `;
11
+ const { cssUrl, tags, title, showCount, totalPosts, topTag } = this.props;
54
12
 
55
13
  return (
56
- <div class="card widget" data-type="tags">
57
- <style>{inlineCSS}</style>
58
- <div class="card-content">
59
- <div class="menu">
14
+ <Fragment>
15
+ <link rel="stylesheet" href={cssUrl} data-page-head />
16
+ <main class="tags-page">
17
+ <header class="tags-hero">
18
+ <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."}
23
+ </p>
24
+ </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>
39
+ </header>
40
+
41
+ <nav class="tags-index" aria-label={title}>
60
42
  {tags.map((tag) => (
61
- <a class="tags" href={tag.url}>
62
- <span class="tag">{tag.name}</span>
63
- {showCount ? <span class="tag">{tag.count}</span> : null}
43
+ <a key={tag.url} class="tags-index__item" href={tag.url} style={`--tag-size:${tag.size};`}>
44
+ <span class="tags-index__name">{tag.name}</span>
45
+ {showCount ? <span class="tags-index__count">{tag.count}</span> : null}
64
46
  </a>
65
47
  ))}
66
- </div>
67
- </div>
68
- </div>
48
+ </nav>
49
+ </main>
50
+ </Fragment>
69
51
  );
70
52
  }
71
53
  }
72
54
 
73
- Tags.Cacheable = cacheComponent(Tags, "widget.tags", (props) => {
74
- const { helper, widget = {} } = props;
55
+ Tags.Cacheable = cacheComponent(Tags, "page.tags", (props) => {
56
+ const { helper, page, widget = {} } = props;
75
57
  const { order_by = "name", amount, show_count = true } = widget;
76
- let tags = props.tags || props.site.tags;
77
- const { url_for, _p } = helper;
58
+ let tags = props.tags || page?.tags || props.site.tags;
59
+ const { _p } = helper;
78
60
 
79
- if (!tags || !tags.length) {
61
+ if (!tags?.length) {
80
62
  return null;
81
63
  }
82
64
 
83
- tags = tags.sort(order_by).filter((tag) => tag.length);
65
+ if (Array.isArray(tags)) {
66
+ tags = tags
67
+ .filter((tag) => tag.length)
68
+ .sort((a, b) => {
69
+ const aValue = a[order_by] || a.name || "";
70
+ const bValue = b[order_by] || b.name || "";
71
+ return String(aValue).localeCompare(String(bValue));
72
+ });
73
+ } else {
74
+ tags = tags.sort(order_by).filter((tag) => tag.length);
75
+ }
84
76
  if (amount) {
85
- tags = tags.limit(amount);
77
+ tags = typeof tags.limit === "function" ? tags.limit(amount) : tags.slice(0, amount);
86
78
  }
87
79
 
80
+ const langKey = helper.language_key(page);
81
+ const mappedTags = tags.map((tag) => {
82
+ const posts = helper.is_i18n_enabled() ? filterByLanguage(tag.posts, langKey, props.config || {}, helper) : tag.posts;
83
+ return {
84
+ name: tag.name,
85
+ count: posts.length,
86
+ url: helper.localized_tag_url(tag, langKey),
87
+ };
88
+ });
89
+ 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
+
88
93
  return {
94
+ cssUrl: helper.url_for("/css/tags.css"),
89
95
  showCount: show_count,
90
96
  title: _p("common.tag", Infinity),
91
- tags: tags.map((tag) => ({
92
- name: tag.name,
93
- count: tag.length,
94
- url: url_for(tag.path),
97
+ totalPosts,
98
+ topTag,
99
+ tags: mappedTags.map((tag) => ({
100
+ ...tag,
101
+ size: getTagSize(tag.count, maxCount),
95
102
  })),
96
103
  };
97
104
  });
105
+
98
106
  module.exports = class extends Component {
99
107
  render() {
100
- const { site, helper } = this.props;
108
+ const { config, page, site, helper } = this.props;
101
109
 
102
- return <Tags.Cacheable site={site} helper={helper} />;
110
+ return <Tags.Cacheable config={config} page={page} site={site} helper={helper} />;
103
111
  }
104
112
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hexo-theme-gnix",
3
- "version": "9.0.0",
4
- "author": "Efterklang <gaojiaxing0220@gmail.com>",
3
+ "version": "10.0.0",
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.",
7
7
  "keywords": [
@@ -21,8 +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",
25
- "build:swup": "bun build src/swup.js --outfile source/js/swup.bundle.js --minify"
24
+ "test": "node test/md_generator.test.js",
25
+ "build:swup": "cp src/swup.js source/js/swup.js"
26
26
  },
27
27
  "files": [
28
28
  "include",
@@ -37,7 +37,7 @@
37
37
  "@swup/head-plugin": "^2.3.1",
38
38
  "@swup/scripts-plugin": "^2.1.0",
39
39
  "esbuild": "^0.28.0",
40
- "feedsmith": "^2.9.1",
40
+ "feedsmith": "^2.9.4",
41
41
  "hexo-pagination": "^4.0.0",
42
42
  "inferno": "^9.1.0",
43
43
  "inferno-create-element": "^9.1.0",
package/scripts/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ require("../include/hexo/i18n")(hexo);
1
2
  require("../include/hexo/filter")(hexo);
2
3
  require("../include/hexo/generator")(hexo);
3
4
  require("../include/hexo/feed")(hexo);