hexo-theme-stellar 1.11.0 → 1.12.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 (62) hide show
  1. package/_config.yml +15 -12
  2. package/_data/widgets.yml +30 -6
  3. package/languages/zh-CN.yml +4 -4
  4. package/languages/zh-TW.yml +4 -4
  5. package/layout/_partial/main/article/read_next.ejs +16 -17
  6. package/layout/_partial/main/navbar/breadcrumb.ejs +1 -1
  7. package/layout/_partial/main/post_list/post_card.ejs +21 -15
  8. package/layout/_partial/main/post_list/wiki_card.ejs +1 -1
  9. package/layout/_partial/sidebar/header.ejs +2 -26
  10. package/layout/_partial/sidebar/logo.ejs +2 -2
  11. package/layout/_partial/sidebar/menu.ejs +27 -0
  12. package/layout/_partial/sidebar/widgets/ghissues.ejs +46 -0
  13. package/layout/_partial/sidebar/widgets/ghrepo.ejs +3 -3
  14. package/layout/_partial/sidebar/widgets/ghuser.ejs +4 -0
  15. package/layout/_partial/sidebar/widgets/markdown.ejs +1 -1
  16. package/layout/_partial/sidebar/widgets/recent.ejs +8 -11
  17. package/layout/_partial/sidebar/widgets/{wiki_more.ejs → related.ejs} +7 -7
  18. package/layout/_partial/sidebar/widgets/tagcloud.ejs +24 -0
  19. package/layout/_partial/sidebar/widgets/timeline.ejs +27 -0
  20. package/layout/_partial/sidebar/widgets/toc.ejs +1 -5
  21. package/layout/index.ejs +1 -1
  22. package/package.json +1 -1
  23. package/scripts/events/lib/doc_tree.js +3 -0
  24. package/scripts/helpers/related_posts.js +11 -39
  25. package/scripts/tags/about.js +10 -7
  26. package/scripts/tags/{grid.js → border.js} +4 -4
  27. package/scripts/tags/link.js +11 -9
  28. package/scripts/tags/navbar.js +1 -1
  29. package/scripts/tags/sites.js +1 -1
  30. package/scripts/tags/split.js +51 -0
  31. package/source/css/_common/base.styl +2 -2
  32. package/source/css/_common/blur.styl +3 -0
  33. package/source/css/_common/device.styl +2 -0
  34. package/source/css/_common/highlight.styl +1 -1
  35. package/source/css/_common/loading.styl +16 -3
  36. package/source/css/_common/title.styl +0 -13
  37. package/source/css/_custom.styl +4 -4
  38. package/source/css/_layout/list.styl +40 -9
  39. package/source/css/_layout/md.styl +1 -1
  40. package/source/css/_layout/partial/related.styl +62 -93
  41. package/source/css/_layout/sidebar/footer.styl +4 -2
  42. package/source/css/_layout/sidebar/ghrepo.styl +11 -5
  43. package/source/css/_layout/sidebar/ghuser.styl +19 -1
  44. package/source/css/_layout/sidebar/sidebar.styl +4 -90
  45. package/source/css/_layout/sidebar/toc_common.styl +5 -3
  46. package/source/css/_layout/sidebar/widgets.styl +104 -0
  47. package/source/css/_layout/tag-plugins/about.styl +21 -18
  48. package/source/css/_layout/tag-plugins/common.styl +36 -31
  49. package/source/css/_layout/tag-plugins/link.styl +41 -27
  50. package/source/css/_layout/tag-plugins/navbar.styl +10 -4
  51. package/source/css/_layout/tag-plugins/quot.styl +1 -1
  52. package/source/css/_layout/tag-plugins/split.styl +28 -0
  53. package/source/css/_layout/tag-plugins/timeline.styl +18 -9
  54. package/source/css/_plugins/comments/twikoo.styl +11 -5
  55. package/source/css/_plugins/comments/valine.styl +4 -0
  56. package/source/css/_plugins/comments/waline.styl +1 -1
  57. package/source/js/main.js +14 -8
  58. package/source/js/plugins/friends.js +3 -2
  59. package/source/js/plugins/ghinfo.js +14 -2
  60. package/source/js/plugins/linkcard.js +124 -0
  61. package/source/js/plugins/sites.js +4 -3
  62. package/source/js/plugins/timeline.js +11 -6
@@ -77,6 +77,9 @@ module.exports = hexo => {
77
77
  if (proj.title == undefined || proj.title.length === 0) {
78
78
  proj.title = id;
79
79
  }
80
+ if (proj.name == undefined || proj.name.length == 0) {
81
+ proj.name = id;
82
+ }
80
83
  }
81
84
  // 补充 order
82
85
  wiki_pages.forEach((p, i) => {
@@ -25,58 +25,30 @@ hexo.extend.helper.register('popular_posts_wrapper', function(args){
25
25
 
26
26
  const posts = this.site.posts;
27
27
  const root = this.config.root;
28
- function generateHTML(list){
29
28
 
29
+ function listItem(obj){
30
30
  var el = '';
31
- el += '<a class="item" href="' + list.path + '" title="' + list.title + '">';
31
+ el += '<a class="item" href="' + obj.path + '" title="' + obj.title + '">';
32
32
  var p = posts.filter(function(p) {
33
- return root + p.path == list.path;
33
+ return root + p.path == obj.path;
34
34
  });
35
35
  if (p && p.length > 0) {
36
36
  p = p.data[0];
37
37
  }
38
- if (p) {
39
- if (p.cover) {
40
- if (p.cover.includes('/')) {
41
- list.img = p.cover;
42
- } else {
43
- list.img = 'https://source.unsplash.com/1280x640/?' + p.cover;
44
- }
45
- } else if (cfg.auto_cover && p.tags && p.tags.length > 0) {
46
- var params = '';
47
- p.tags.reverse().forEach((tag, i) => {
48
- if (i > 0) {
49
- params += ',';
50
- }
51
- params += tag.name;
52
- });
53
- list.img = 'https://source.unsplash.com/1280x640/?' + params;
54
- }
55
- }
56
- if (hexo.theme.config.default.cover) {
57
- el += '<div class="img">'
58
- if (list.img && list.img != "") {
59
- el += '<img src="' + list.img + '" />';
60
- } else {
61
- el += '<img src="' + hexo.theme.config.default.cover + '" />';
62
- }
63
- el += '</div>';
38
+ el += '<span class="title">' + obj.title + '</span>';
39
+ if (obj.excerpt && obj.excerpt.length > 0) {
40
+ el += '<span class="excerpt">' + util.truncate(util.stripHTML(obj.excerpt), {length: 120}) + '</span>';
64
41
  }
65
-
66
- el += '<span class="title">' + list.title + '</span>';
67
-
68
- if (list.excerpt && list.excerpt.length > 0) {
69
- el += '<span class="excerpt">' + util.truncate(util.stripHTML(list.excerpt), {length: 120}) + '</span>';
70
- }
71
-
72
42
  el += '</a>';
73
43
  return el;
74
44
  }
75
45
 
76
- for(var i = 0; i < json.length; i++) {
77
- returnHTML += generateHTML(json[i]);
46
+ if (json.length > 0) {
47
+ for(var i = 0; i < json.length; i++) {
48
+ returnHTML += listItem(json[i]);
49
+ }
78
50
  }
79
-
51
+
80
52
  if (returnHTML != "") returnHTML = "<div class=\"" + cls + "\">" + returnHTML + "</div>";
81
53
  div += returnHTML;
82
54
  div += '</section>';
@@ -8,21 +8,24 @@
8
8
  */
9
9
 
10
10
  'use strict';
11
+ const url_for = require('hexo-util').url_for.bind(hexo);
11
12
 
12
13
  hexo.extend.tag.register('about', function(args, content) {
13
- args = hexo.args.map(args, ['avatar', 'height', 'border']);
14
+ args = hexo.args.map(args, ['avatar', 'height', 'border', 'back']);
14
15
  var rows = hexo.render.renderSync({text: content, engine: 'markdown'}).split('\n');
15
16
  var el = '';
16
17
  // wrapper
17
18
  el += '<div class="tag-plugin about">';
18
- el += '<div class="about-header">';
19
+ if (args.back) {
20
+ el += '<a class="nav-back cap" href="' + url_for(hexo.config.root) + '">';
21
+ el += '<svg aria-hidden="true" viewBox="0 0 16 16" fill="currentColor"><path fill-rule="evenodd" d="M7.78 12.53a.75.75 0 01-1.06 0L2.47 8.28a.75.75 0 010-1.06l4.25-4.25a.75.75 0 011.06 1.06L4.81 7h7.44a.75.75 0 010 1.5H4.81l2.97 2.97a.75.75 0 010 1.06z"></path></svg>';
22
+ el += '</a>';
23
+ }
19
24
  // avatar
20
25
  var avatar_url = args.avatar;
21
- if (args.avatar === undefined) {
22
- avatar_url = hexo.config.avatar;
23
- }
24
26
  if (avatar_url) {
25
- el += '<div class="avatar">'
27
+ el += '<div class="about-header">';
28
+ el += '<div class="avatar">';
26
29
  el += '<img src="' + avatar_url + '"';
27
30
  if (args.border && args.border.length > 0) {
28
31
  el += ' style="border-radius:' + args.border + '"';
@@ -32,8 +35,8 @@ hexo.extend.tag.register('about', function(args, content) {
32
35
  }
33
36
  el += '/>';
34
37
  el += '</div>';
38
+ el += '</div>';
35
39
  }
36
- el += '</div>';
37
40
 
38
41
  // content
39
42
  el += '<div class="about-body fs14">';
@@ -1,15 +1,15 @@
1
1
  /**
2
- * grid.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/
2
+ * border.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/
3
3
  * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
4
4
  *
5
- * {% grid [color:color] [child:codeblock/tabs] title %}
5
+ * {% border [color:color] [child:codeblock/tabs] title %}
6
6
  * body
7
- * {% endgrid %}
7
+ * {% endborder %}
8
8
  */
9
9
 
10
10
  'use strict';
11
11
 
12
- hexo.extend.tag.register('grid', function(args, content) {
12
+ hexo.extend.tag.register('border', function(args, content) {
13
13
  args = hexo.args.map(args, ['color', 'child'], ['title']);
14
14
  const color = args.color;
15
15
  const title = args.title;
@@ -2,7 +2,7 @@
2
2
  * link.js v1.1 | https://github.com/xaoxuu/hexo-theme-stellar/
3
3
  * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
4
4
  *
5
- * {% link url title [description] [icon:src] %}
5
+ * {% link url [title] [desc:true/false] [icon:src] %}
6
6
  */
7
7
 
8
8
  'use strict';
@@ -11,11 +11,11 @@ var util = require('hexo-util');
11
11
  const full_url_for = require('hexo-util').full_url_for.bind(hexo);
12
12
 
13
13
  hexo.extend.tag.register('link', function(args) {
14
- args = hexo.args.map(args, ['icon'], ['url', 'title', 'description']);
14
+ args = hexo.args.map(args, ['icon', 'desc'], ['url', 'title']);
15
15
 
16
16
  var el = '';
17
17
  el += '<div class="tag-plugin link dis-select">';
18
- el += '<a class="link-card' + (args.description ? ' rich' : ' plain') + '" title="' + args.title + '" href="' + args.url + '"';
18
+ el += '<a class="link-card' + (args.desc ? ' rich' : ' plain') + '" title="' + args.title + '" href="' + args.url + '"';
19
19
  if (args.url.includes('://')) {
20
20
  el += ' target="_blank" rel="external nofollow noopener noreferrer"';
21
21
  }
@@ -31,17 +31,19 @@ hexo.extend.tag.register('link', function(args) {
31
31
  return el;
32
32
  }
33
33
  function loadTitle() {
34
- return '<span class="title">' + args.title + '</span>';
34
+ return '<span class="title">' + (args.title || args.url) + '</span>';
35
35
  }
36
36
  function loadDesc() {
37
- return '<span class="desc fs12">' + (args.description || full_url_for(args.url)) + '</span>';
37
+ return '<span class="cap desc fs12"></span>';
38
+ }
39
+ function loadLink() {
40
+ return '<span class="cap link fs12">' + full_url_for(args.url) + '</span>';
38
41
  }
39
42
 
40
- if (args.description) {
43
+ if (args.desc) {
41
44
  // top
42
45
  el += '<div class="top">';
43
- el += loadIcon();
44
- el += '<span class="desc fs12">' + full_url_for(args.url) + '</span>';
46
+ el += loadIcon() + loadLink();
45
47
  el += '</div>';
46
48
  // bottom
47
49
  el += '<div class="bottom">';
@@ -50,7 +52,7 @@ hexo.extend.tag.register('link', function(args) {
50
52
  } else {
51
53
  // left
52
54
  el += '<div class="left">';
53
- el += loadTitle() + loadDesc();
55
+ el += loadTitle() + loadLink();
54
56
  el += '</div>';
55
57
  // right
56
58
  el += '<div class="right">';
@@ -49,7 +49,7 @@ hexo.extend.tag.register('navbar', function(args) {
49
49
  el += '</a>';
50
50
  return el;
51
51
  }
52
- args.links.forEach((item, i) => {
52
+ (args.links || []).forEach((item, i) => {
53
53
  el += layoutItem(item, i);
54
54
  });
55
55
  el += '</nav></div>';
@@ -43,7 +43,7 @@ hexo.extend.tag.register('sites', function(args) {
43
43
  if (site.url && site.title) {
44
44
  var cell = '<div class="site-card">';
45
45
  cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + site.url + '">';
46
- cell += '<img src="' + (site.screenshot || ('https://image.thum.io/get/width/1024/crop/768/' + site.url)) + '" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;' + hexo.theme.config.default.cover + '&quot;;"/>';
46
+ cell += '<img src="' + (site.screenshot || ('https://screenshot-api.xaoxuu.com/api?url=' + site.url + '&width=1280&height=720')) + '" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;' + hexo.theme.config.default.cover + '&quot;;"/>';
47
47
  cell += '<div class="info">';
48
48
  cell += '<img src="' + (site.avatar || hexo.theme.config.default.link) + '" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;' + hexo.theme.config.default.link + '&quot;;"/>';
49
49
  cell += '<span class="title">' + site.title + '</span>';
@@ -0,0 +1,51 @@
1
+ /**
2
+ * split.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/
3
+ * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
4
+ *
5
+ * {% split [style:block/card] %}
6
+ * <!-- cell -->
7
+ * left body
8
+ * <!-- cell -->
9
+ * right body
10
+ * {% endsplit %}
11
+ */
12
+
13
+ 'use strict';
14
+
15
+ hexo.extend.tag.register('split', function(args, content) {
16
+ args = hexo.args.map(args, ['bg']);
17
+ var el = '';
18
+ el += '<div class="tag-plugin split"';
19
+ el += ' ' + hexo.args.joinTags(args, ['bg']).join(' ');
20
+ el += '>';
21
+
22
+ var arr = content.split(/<!--\s*(.*?)\s*-->/g).filter((item, i) => {
23
+ return item.trim().length > 0;
24
+ });
25
+ if (arr.length > 0) {
26
+ var nodes = [];
27
+ arr.forEach((item, i) => {
28
+ if (item == 'cell') {
29
+ nodes.push({
30
+ header: ''
31
+ });
32
+ } else if (nodes.length > 0) {
33
+ var node = nodes[nodes.length-1];
34
+ if (node.body == undefined) {
35
+ node.body = item;
36
+ } else {
37
+ node.body += '\n' + item;
38
+ }
39
+ }
40
+ });
41
+ nodes.forEach((node, i) => {
42
+ el += '<div class="cell" index="' + (i) + '">';
43
+ el += hexo.render.renderSync({text: node.body, engine: 'markdown'}).split('\n').join('');
44
+ el += '</div>';
45
+ });
46
+ }
47
+
48
+ el += '</div>';
49
+
50
+ return el;
51
+ }, {ends: true});
@@ -12,8 +12,8 @@ a
12
12
  &:hover
13
13
  color: $color-hover
14
14
 
15
- p:not([class])
16
- text-align: justify
15
+ .md p:not([class])
16
+ text-align: convert(hexo-config('style.text-align'))
17
17
 
18
18
  hr
19
19
  color: var(--text-meta)
@@ -5,6 +5,9 @@ if hexo-config('style.darkmode') == 'auto'
5
5
  @media (prefers-color-scheme: dark)
6
6
  :root
7
7
  --blur-bg: alpha(black, .5)
8
+ if hexo-config('style.darkmode') == 'always'
9
+ :root
10
+ --blur-bg: alpha(black, .5)
8
11
 
9
12
  .blur
10
13
  background: var(--blur-bg)
@@ -24,6 +24,8 @@
24
24
  if hexo-config('style.darkmode') == 'auto'
25
25
  @media (prefers-color-scheme: dark)
26
26
  --blur-bg: alpha(#555, .6)
27
+ if hexo-config('style.darkmode') == 'always'
28
+ --blur-bg: alpha(#555, .6)
27
29
 
28
30
  .sidebar-toggle.mobile
29
31
  cursor: pointer
@@ -20,7 +20,7 @@ article.md .highlight, pre:not([class]):has(>code)
20
20
  font-family: $ff-code
21
21
  box-sizing: border-box
22
22
  @media screen and (min-width: $device-mobile)
23
- min-width: 280px
23
+ min-width: 180px
24
24
 
25
25
  article.md .highlight
26
26
  position: relative
@@ -15,6 +15,19 @@ svg.loading
15
15
  transform:rotate(360deg)
16
16
 
17
17
  .loading-wrap
18
- min-height: 50px
19
- margin: 2rem 0
20
- text-align: center
18
+ margin: 0
19
+ text-align: center
20
+ background: var(--block)
21
+ border-radius: $border-card
22
+ position relative
23
+ padding: 2rem
24
+ svg
25
+ margin: 4px
26
+ &:after
27
+ content: hexo-config('style.loading.loading')
28
+ color: var(--text-p1)
29
+ display: block
30
+ font-size: 14px
31
+ &.error
32
+ &:after
33
+ content: hexo-config('style.loading.error')
@@ -25,19 +25,6 @@ h6
25
25
  .fs12
26
26
  font-size: $fs-12
27
27
 
28
- .post-list
29
- .post-title
30
- font-weight: 500
31
- margin: .75rem 0 .5rem
32
- line-height: 1.2
33
- font-size: $fs-h3
34
- border-bottom: none
35
- color: var(--text-p0)
36
- trans1 color
37
- .wiki .post-title
38
- margin-top: 0.5rem
39
- font-weight: 700
40
-
41
28
  .widgets
42
29
  .post-title
43
30
  margin: 0.75rem 0
@@ -69,14 +69,14 @@ $border-image = 6px
69
69
 
70
70
  // 可以动态变化的属性
71
71
  :root
72
- --width-left: 256px
72
+ --width-left: 288px
73
73
  --width-main: 720px
74
74
  --gap-l: 16px
75
75
  --gap-p: .75rem // gap for paragraph
76
76
  // desktop 2k or larger
77
77
  @media screen and (min-width: $device-2k)
78
78
  --gap-l: 32px
79
- --width-left: 320px
79
+ --width-left: 352px
80
80
  --width-main: 780px
81
81
  // desktop 4k or larger
82
82
  @media screen and (min-width: $device-4k)
@@ -84,10 +84,10 @@ $border-image = 6px
84
84
  --gap-l: 64px
85
85
  // iPad 竖屏
86
86
  @media screen and (max-width: $device-tablet)
87
- --width-left: 220px
87
+ --width-left: 252px
88
88
  // iPad 竖屏
89
89
  @media screen and (max-width: $device-mobile-max)
90
- --width-left: 256px
90
+ --width-left: 288px
91
91
 
92
92
 
93
93
 
@@ -1,6 +1,25 @@
1
1
  // list
2
2
  .post-list
3
3
  margin: 1rem
4
+ .post-title
5
+ margin-top: 1.5rem
6
+ .post-title:first-child
7
+ margin-top: .5rem
8
+
9
+ .post-list
10
+ .post-title
11
+ font-weight: 500
12
+ margin: .75rem 0
13
+ line-height: 1.2
14
+ font-size: $fs-h3
15
+ border-bottom: none
16
+ color: var(--text-p0)
17
+ trans1 color
18
+ @media screen and (max-width: $device-mobile)
19
+ font-size: $fs-h4
20
+ margin: 0.5rem 0
21
+ .wiki .post-title
22
+ margin-top: 0.5rem
4
23
 
5
24
  // card
6
25
  .post-list .post-card
@@ -14,14 +33,18 @@
14
33
  position: relative
15
34
  .excerpt
16
35
  margin: 1rem 0
36
+ @media screen and (max-width: $device-mobile)
37
+ margin: 0.5rem 0
17
38
  >p
18
39
  margin: 1rem 0
40
+ @media screen and (max-width: $device-mobile)
41
+ margin: 0.5rem 0
19
42
  line-height: 1.5
20
43
  .meta.cap
21
44
  display: flex
22
45
  flex-wrap: wrap
23
46
  align-items: center
24
- margin: .5rem 0
47
+ margin: 0.25rem 0
25
48
  line-height: 1.5
26
49
  span+span
27
50
  margin-left: 0.5rem
@@ -37,10 +60,11 @@
37
60
  // common article
38
61
  .post-list article.md
39
62
  padding: 1rem
63
+ @media screen and (max-width: $device-mobile)
64
+ padding: 0.5rem 1rem
40
65
  p
41
66
  color: var(--text-p2)
42
- @media screen and (min-width: $device-mobile)
43
- font-size: $fs-14
67
+ font-size: $fs-14
44
68
 
45
69
 
46
70
  // posts
@@ -51,6 +75,7 @@
51
75
  margin-left: -1rem
52
76
  margin-top: -1rem
53
77
  margin-right: -1rem
78
+ background: var(--block)
54
79
  &:not(.lazy)
55
80
  trans1: transform 1s
56
81
  img
@@ -76,7 +101,7 @@
76
101
  img
77
102
  width: 100%
78
103
  .cover-info
79
- padding: 1rem
104
+ padding: 1.5rem 1rem
80
105
  position: absolute
81
106
  line-height: 1.2
82
107
  width: 'calc(100% - %s * 2)' % 1rem
@@ -84,20 +109,26 @@
84
109
  color: white
85
110
  &[position=top]
86
111
  top: 0
87
- background-image: linear-gradient(rgba(0,0,0,0.4),rgba(0,0,0,0.3),rgba(0,0,0,0))
112
+ background-image: linear-gradient(rgba(0,0,0,0.3),rgba(0,0,0,0.2),rgba(0,0,0,0))
88
113
  &[position=bottom]
89
114
  bottom: 0
90
- background-image: linear-gradient(rgba(0,0,0,0),rgba(0,0,0,0.3),rgba(0,0,0,0.4))
115
+ background-image: linear-gradient(rgba(0,0,0,0),rgba(0,0,0,0.2),rgba(0,0,0,0.3))
91
116
  div+div
92
- margin-top: 8px
93
- @media screen and (max-width: $device-mobile)
94
- margin-top: 4px
117
+ margin-top: 4px
95
118
  .cap
96
119
  color: white
97
120
  font-size: $fs-13
98
121
  .title
99
122
  font-weight: 500
100
123
  font-size: $fs-h3
124
+ @media screen and (max-width: $device-mobile)
125
+ padding: 1rem
126
+ div+div
127
+ margin-top: 2px
128
+ .title
129
+ font-size: $fs-h4
130
+ .cap
131
+ font-size: $fs-12
101
132
  h2
102
133
  margin: .25rem 0
103
134
  font-size: $fs-h4
@@ -24,7 +24,7 @@ article.md.content
24
24
  &.indent
25
25
  >p:not([class])
26
26
  text-indent: 'calc(%s * 2)' % $fs-p
27
- text-align: justify
27
+ text-align: convert(hexo-config('style.text-align'))
28
28
  a
29
29
  text-indent: 0
30
30
  h1,h2,h3,h4,h5,h6