hexo-theme-stellar 1.17.2 → 1.18.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 (38) hide show
  1. package/_config.yml +20 -26
  2. package/_data/widgets.yml +0 -15
  3. package/layout/_partial/sidebar/header.ejs +4 -4
  4. package/layout/_partial/sidebar/index.ejs +4 -4
  5. package/layout/_partial/widgets/search.ejs +1 -0
  6. package/package.json +1 -1
  7. package/scripts/generators/search.js +2 -0
  8. package/scripts/tags/{border.js → ablock.js} +8 -10
  9. package/scripts/tags/{split.js → grid.js} +5 -5
  10. package/scripts/tags/note.js +5 -7
  11. package/scripts/tags/poetry.js +4 -5
  12. package/scripts/tags/quot.js +8 -4
  13. package/scripts/tags/tag.js +35 -0
  14. package/scripts/tags/toc.js +2 -2
  15. package/source/css/_common/highlight.styl +0 -3
  16. package/source/css/_custom.styl +13 -27
  17. package/source/css/_defines/theme.styl +47 -34
  18. package/source/css/_layout/md.styl +6 -4
  19. package/source/css/_layout/partial/paginator.styl +2 -1
  20. package/source/css/_layout/partial/related.styl +1 -1
  21. package/source/css/_layout/sidebar/header.styl +2 -2
  22. package/source/css/_layout/tag-plugins/common.styl +51 -65
  23. package/source/css/_layout/tag-plugins/folding.styl +10 -11
  24. package/source/css/_layout/tag-plugins/{split.styl → grid.styl} +4 -4
  25. package/source/css/_layout/tag-plugins/link.styl +1 -1
  26. package/source/css/_layout/tag-plugins/mark.styl +2 -2
  27. package/source/css/_layout/tag-plugins/navbar.styl +1 -1
  28. package/source/css/_layout/tag-plugins/note.styl +3 -1
  29. package/source/css/_layout/tag-plugins/poetry.styl +26 -25
  30. package/source/css/_layout/tag-plugins/quot.styl +47 -58
  31. package/source/css/_layout/tag-plugins/tag.styl +13 -0
  32. package/source/css/_layout/widgets/ghuser.styl +19 -15
  33. package/source/css/_layout/widgets/search.styl +101 -1
  34. package/source/css/_layout/widgets/toc_common.styl +1 -1
  35. package/source/css/_plugins/comments/twikoo.styl +0 -1
  36. package/source/css/_plugins/index.styl +0 -3
  37. package/source/js/plugins/weibo.js +116 -0
  38. package/source/css/_plugins/search/local-search.styl +0 -87
@@ -0,0 +1,116 @@
1
+ const weibojs = {
2
+ requestAPI: (url, callback, timeout) => {
3
+ let retryTimes = 5;
4
+ function request() {
5
+ return new Promise((resolve, reject) => {
6
+ let status = 0; // 0 等待 1 完成 2 超时
7
+ let timer = setTimeout(() => {
8
+ if (status === 0) {
9
+ status = 2;
10
+ timer = null;
11
+ reject('请求超时');
12
+ if (retryTimes == 0) {
13
+ timeout();
14
+ }
15
+ }
16
+ }, 5000);
17
+ fetch(url).then(function(response) {
18
+ if (status !== 2) {
19
+ clearTimeout(timer);
20
+ resolve(response);
21
+ timer = null;
22
+ status = 1;
23
+ }
24
+ if (response.ok) {
25
+ return response.json();
26
+ }
27
+ throw new Error('Network response was not ok.');
28
+ }).then(function(data) {
29
+ retryTimes = 0;
30
+ callback(data);
31
+ }).catch(function(error) {
32
+ if (retryTimes > 0) {
33
+ retryTimes -= 1;
34
+ setTimeout(() => {
35
+ request();
36
+ }, 5000);
37
+ } else {
38
+ timeout();
39
+ }
40
+ });
41
+ });
42
+ }
43
+ request();
44
+ },
45
+ layoutDiv: (cfg) => {
46
+ const el = $(cfg.el)[0];
47
+ $(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="2rem" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>');
48
+ weibojs.requestAPI(cfg.api, function(data) {
49
+ $(el).find('.loading-wrap').remove();
50
+ const arr = data.tweets || [];
51
+ const limit = el.getAttribute('limit');
52
+ arr.forEach((item, i) => {
53
+ if (limit && i >= limit) {
54
+ return;
55
+ }
56
+ var cell = '<div class="timenode" index="' + i + '">';
57
+ cell += '<div class="header">';
58
+ cell += '<div class="user-info">';
59
+ cell += '<img src="' + (data.user.avatar_hd || cfg.avatar) + '" onerror="javascript:this.src=\'' + cfg.avatar + '\';">';
60
+ cell += '<span>' + data.user.nick_name + '</span>';
61
+ cell += '</div>';
62
+ cell += '<p>' + item.created_at + '</p>';
63
+ cell += '</div>';
64
+ cell += '<div class="body">';
65
+ cell += '<a class="body" href="' + item.url + '" target="_blank" rel="external nofollow noopener noreferrer">';
66
+ cell += item.content;
67
+ cell += '</a>';
68
+ // cell += '</div>';
69
+ // 每条微博的右下角 转发 评论 点赞
70
+ cell += '<div class="footer">';
71
+ cell += '<div class="flex left">';
72
+ cell += '</div>';
73
+ cell += '<div class="flex right">';
74
+ cell += '<div class="item reaction repost">';
75
+ cell += '<a class="item comments last" href="' + item.url + '#issuecomment-new" target="_blank" rel="external nofollow noopener noreferrer">';
76
+ cell += '<span>' + '🔗' + ' ' + item.reposts_count + '</span>';
77
+ cell += '</a>';
78
+ cell += '</div>';
79
+ cell += '<a class="item comments last" href="' + item.url + '#issuecomment-new" target="_blank" rel="external nofollow noopener noreferrer">';
80
+ cell += '<span><svg t="1666270368054" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2528" width="200" height="200"><path d="M952 64H72C32.3 64 0 96.3 0 136v508c0 39.7 32.3 72 72 72h261l128 128c14 14 32.5 21.1 50.9 21.1s36.9-7 50.9-21.1l128-128h261c39.7 0 72-32.3 72-72V136c0.2-39.7-32.1-72-71.8-72zM222 462c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72-32.2 72-72 72z m290-7.7c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72c0 39.7-32.2 72-72 72z m290 8c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72c0 39.7-32.2 72-72 72z" p-id="2529"></path></svg> '
81
+ + (item.comments_count || 0) + '</span>';
82
+ cell += '</a>';
83
+ cell += '<div class="item reaction attitudes">';
84
+ cell += '<a class="item comments last" href="' + item.url + '#issuecomment-new" target="_blank" rel="external nofollow noopener noreferrer">';
85
+ cell += '<span>' + '👍' + ' ' + item.attitudes_count + '</span>';
86
+ cell += '</a>';
87
+ cell += '</div>';
88
+
89
+ cell += '</div>';
90
+ cell += '</div>';
91
+ // 右下角结束
92
+ $(el).append(cell);
93
+ });
94
+ }, function() {
95
+ $(el).find('.loading-wrap svg').remove();
96
+ $(el).find('.loading-wrap').append('<svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="2rem" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" d="M12 3L21 20H3L12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.5s" values="60;0"/></path><path stroke-dasharray="6" stroke-dashoffset="6" d="M12 10V14"><animate fill="freeze" attributeName="stroke-dashoffset" begin="0.6s" dur="0.2s" values="6;0"/></path></g><circle cx="12" cy="17" r="1" fill="currentColor" fill-opacity="0"><animate fill="freeze" attributeName="fill-opacity" begin="0.8s" dur="0.4s" values="0;1"/></circle></svg>');
97
+ $(el).find('.loading-wrap').addClass('error');
98
+ });
99
+ },
100
+ }
101
+
102
+ $(function () {
103
+ const els = document.getElementsByClassName('stellar-weibo-api');
104
+ for (var i = 0; i < els.length; i++) {
105
+ const el = els[i];
106
+ const api = el.getAttribute('api'); // 这个API可以返回微博的json文件
107
+ if (api == null) {
108
+ continue;
109
+ }
110
+ var cfg = new Object();
111
+ cfg.el = el;
112
+ cfg.api = api;
113
+ cfg.avatar = 'https://fastly.jsdelivr.net/gh/cdn-x/placeholder@1.0.1/avatar/round/3442075.svg';
114
+ weibojs.layoutDiv(cfg);
115
+ }
116
+ });
@@ -1,87 +0,0 @@
1
- .search-wrapper
2
- width: 100%
3
- >.search-form
4
- position: sticky
5
- top: 1rem
6
- .search-input
7
- width: 100%
8
- padding: 0.75rem 1rem
9
- line-height: 1
10
- box-sizing: border-box
11
- border-radius: $border-block
12
- background-color: var(--card)
13
- color: var(--text-p0)
14
- box-shadow: $boxshadow-button
15
- trans1 box-shadow
16
- &:hover
17
- box-shadow: 0 0 2px 0px rgba(0, 0, 0, 0.16), 0 0 8px 0px rgba(0, 0, 0, 0.08)
18
-
19
- &.noresult
20
- .search-input
21
- &:hover
22
- box-shadow: 0 0 2px 0px alpha($c-red, 0.2), 0 0 8px 0px alpha($c-red, 0.2)
23
- &:focus
24
- box-shadow: 0 0 2px 0px alpha($c-red, 0.5), 0 0 8px 0px alpha($c-red, 0.4)
25
-
26
- .search-no-result
27
- display: none
28
- margin: 1em auto
29
- color: var(--text-p1)
30
- text-align: center
31
- font-size: $fs-14
32
- padding: 2rem
33
- background: var(--block)
34
- border-radius: $border-block
35
-
36
- #search-result
37
- ul.search-result-list
38
- padding: 0
39
- margin: 0
40
- list-style-type: none
41
- li
42
- margin: 1em auto
43
- &:hover
44
- .search-result-title
45
- color: $color-hover
46
- .search-result-title
47
- color: var(--text-p1)
48
- font-weight: 700
49
- line-height: 1.2
50
-
51
- .search-result-content
52
- overflow: hidden
53
- color: var(--text-p3)
54
- margin: .4em auto
55
- max-height: 13em
56
- text-align: justify
57
- font-size: $fs-12
58
- line-height: 1.2
59
- display: -webkit-box
60
- -webkit-box-orient: vertical
61
- overflow: hidden
62
- -webkit-line-clamp: 3
63
-
64
- .search-keyword
65
- border-bottom: 1px dashed $color-hover
66
- color: $color-hover
67
- font-weight: bold
68
-
69
-
70
-
71
- .search-wrapper.noresult
72
- .search-no-result
73
- display: block
74
-
75
- .widget-wrapper
76
- .search-form
77
- top: 0
78
- background: var(--site-bg)
79
- .search-input
80
- margin-top: 1rem
81
- margin-bottom: -1rem
82
- #search-result,.search-no-result
83
- margin-top: 2rem
84
-
85
- .widget-wrapper:not(:first-child)
86
- .search-wrapper
87
- margin-top: -1rem