hexo-theme-stellar 1.11.0 → 1.13.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 (78) hide show
  1. package/README.md +7 -7
  2. package/_config.yml +22 -37
  3. package/_data/links.yml +7 -0
  4. package/_data/widgets.yml +30 -6
  5. package/languages/zh-CN.yml +4 -4
  6. package/languages/zh-TW.yml +4 -4
  7. package/layout/_partial/head.ejs +2 -0
  8. package/layout/_partial/main/article/read_next.ejs +16 -17
  9. package/layout/_partial/main/navbar/breadcrumb.ejs +1 -1
  10. package/layout/_partial/main/navbar/list_post.ejs +57 -34
  11. package/layout/_partial/main/post_list/post_card.ejs +25 -15
  12. package/layout/_partial/main/post_list/wiki_card.ejs +1 -1
  13. package/layout/_partial/scripts/index.ejs +1 -0
  14. package/layout/_partial/sidebar/header.ejs +2 -26
  15. package/layout/_partial/sidebar/logo.ejs +2 -2
  16. package/layout/_partial/sidebar/menu.ejs +27 -0
  17. package/layout/_partial/sidebar/widgets/ghissues.ejs +45 -0
  18. package/layout/_partial/sidebar/widgets/ghrepo.ejs +3 -3
  19. package/layout/_partial/sidebar/widgets/ghuser.ejs +4 -0
  20. package/layout/_partial/sidebar/widgets/markdown.ejs +1 -1
  21. package/layout/_partial/sidebar/widgets/recent.ejs +8 -11
  22. package/layout/_partial/sidebar/widgets/{wiki_more.ejs → related.ejs} +7 -7
  23. package/layout/_partial/sidebar/widgets/tagcloud.ejs +24 -0
  24. package/layout/_partial/sidebar/widgets/timeline.ejs +27 -0
  25. package/layout/_partial/sidebar/widgets/toc.ejs +1 -5
  26. package/layout/index.ejs +1 -1
  27. package/layout/page.ejs +19 -10
  28. package/package.json +1 -1
  29. package/scripts/events/lib/config.js +1 -1
  30. package/scripts/events/lib/doc_tree.js +3 -0
  31. package/scripts/helpers/related_posts.js +11 -39
  32. package/scripts/tags/about.js +10 -7
  33. package/scripts/tags/{grid.js → border.js} +4 -4
  34. package/scripts/tags/friends.js +36 -75
  35. package/scripts/tags/link.js +11 -9
  36. package/scripts/tags/navbar.js +1 -1
  37. package/scripts/tags/sites.js +40 -79
  38. package/scripts/tags/split.js +51 -0
  39. package/scripts/tags/timeline.js +6 -4
  40. package/source/css/_common/base.styl +2 -2
  41. package/source/css/_common/blur.styl +3 -0
  42. package/source/css/_common/device.styl +2 -0
  43. package/source/css/_common/highlight.styl +1 -1
  44. package/source/css/_common/loading.styl +16 -3
  45. package/source/css/_common/title.styl +0 -13
  46. package/source/css/_custom.styl +4 -4
  47. package/source/css/_layout/list.styl +40 -12
  48. package/source/css/_layout/main.styl +1 -1
  49. package/source/css/_layout/md.styl +1 -4
  50. package/source/css/_layout/partial/navbar.styl +1 -1
  51. package/source/css/_layout/partial/related.styl +62 -93
  52. package/source/css/_layout/sidebar/footer.styl +4 -2
  53. package/source/css/_layout/sidebar/ghrepo.styl +11 -5
  54. package/source/css/_layout/sidebar/ghuser.styl +19 -1
  55. package/source/css/_layout/sidebar/sidebar.styl +11 -96
  56. package/source/css/_layout/sidebar/toc_common.styl +5 -3
  57. package/source/css/_layout/sidebar/widgets.styl +103 -0
  58. package/source/css/_layout/tag-plugins/about.styl +21 -18
  59. package/source/css/_layout/tag-plugins/common.styl +36 -31
  60. package/source/css/_layout/tag-plugins/link.styl +41 -27
  61. package/source/css/_layout/tag-plugins/navbar.styl +10 -4
  62. package/source/css/_layout/tag-plugins/quot.styl +1 -1
  63. package/source/css/_layout/tag-plugins/split.styl +32 -0
  64. package/source/css/_layout/tag-plugins/timeline.styl +40 -14
  65. package/source/css/_plugins/comments/twikoo.styl +11 -5
  66. package/source/css/_plugins/comments/waline.styl +5 -1
  67. package/source/css/_plugins/index.styl +0 -2
  68. package/source/js/main.js +15 -9
  69. package/source/js/plugins/fcircle.js +92 -0
  70. package/source/js/plugins/friends.js +3 -2
  71. package/source/js/plugins/ghinfo.js +14 -2
  72. package/source/js/plugins/linkcard.js +124 -0
  73. package/source/js/plugins/sites.js +4 -3
  74. package/source/js/plugins/timeline.js +58 -40
  75. package/layout/_partial/plugins/comments/valine/layout.ejs +0 -19
  76. package/layout/_partial/plugins/comments/valine/script.ejs +0 -48
  77. package/scripts/tags/issues.js +0 -30
  78. package/source/css/_plugins/comments/valine.styl +0 -218
@@ -26,7 +26,7 @@ function layoutDiv() {
26
26
  el += '<a class="repo" href="https://github.com/' + repo + '" target="_blank" rel="external nofollow noopener noreferrer">';
27
27
  el += '<div class="repo-name flex-row">';
28
28
  el += '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path></svg>';
29
- el += '<span>' + repo + '</span>';
29
+ el += repo;
30
30
  el += '</div>';
31
31
  el += '<div class="repo-desc"><span type="text" id="description">&nbsp;</span></div>';
32
32
  el += '<div class="grid">';
@@ -38,9 +38,9 @@ function layoutDiv() {
38
38
  el += '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"></path></svg>';
39
39
  el += '<span type="text" id="forks_count"></span>';
40
40
  el += '</div>';
41
- el += '<div class="flex-row stellar-ghinfo-api" api="https://api.github.xaoxuu.com/repos/' + repo + '/releases/latest">';
41
+ el += '<div class="flex-row stellar-ghinfo-api" index="0" api="https://api.github.xaoxuu.com/repos/' + repo + '/tags">';
42
42
  el += '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"></path></svg>';
43
- el += '<span type="text" id="tag_name"></span>';
43
+ el += '<span type="text" id="latest-tag-name">0</span>';
44
44
  el += '</div>';
45
45
  el += '</div>';
46
46
  el += '</a>';
@@ -45,6 +45,10 @@ function layoutDiv() {
45
45
  el += '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>';
46
46
  el += 'Follow';
47
47
  el += '</a>';
48
+ // menu
49
+ if (item.menu) {
50
+ el += partial('../menu', {where: 'sidebar'});
51
+ }
48
52
  el += '</div>';
49
53
  el += '</div>';
50
54
  return el;
@@ -5,7 +5,7 @@ function layoutDiv() {
5
5
  return el;
6
6
  }
7
7
  el += '<div class="widget-wrap" id="markdown">';
8
- el += '<div class="widget-header cap dis-select">';
8
+ el += '<div class="widget-header cap theme dis-select">';
9
9
  el += '<span class="name">' + item.title + '</span>';
10
10
  el += '</div>';
11
11
  el += '<div class="widget-body fs14">';
@@ -2,7 +2,7 @@
2
2
  function layoutDiv() {
3
3
  var el = '<div class="widget-wrap" id="recent">';
4
4
  // header
5
- el += '<div class="widget-header cap dis-select">';
5
+ el += '<div class="widget-header cap theme dis-select">';
6
6
  el += '<span class="name">' + __("meta.recent_update") + '</span>';
7
7
  if (item.rss) {
8
8
  el += '<a class="cap-action" id="rss" title="Subscribe" href="' + item.rss + '">';
@@ -25,23 +25,20 @@ function layoutDiv() {
25
25
  return p.title && p.title.length > 0;
26
26
  });
27
27
  }
28
- el += '<div class="widget-body fs14">';
28
+ el += '<div class="widget-body related-posts fs14">';
29
29
  arr.sort("updated", -1).limit(item.limit).each(function(post) {
30
- el += '<div class="more-item">';
31
- el += '<a class="title" href="' + url_for(post.link || post.path) + '">';
30
+ el += '<a class="item title" href="' + url_for(post.link || post.path) + '">';
31
+ el += '<span class="title">'
32
32
  if (post.layout == 'wiki') {
33
- el += '<span>';
34
33
  let proj = theme.wiki.projects[post.wiki];
35
- if (proj && proj.title) {
36
- el += proj.title + __('symbol.colon');
34
+ if (proj && proj.name) {
35
+ el += proj.name + ' / ';
37
36
  } else if (post.wiki) {
38
- el += post.wiki + __('symbol.colon');
37
+ el += post.wiki + ' / ';
39
38
  }
40
- el += '</span>';
41
39
  }
42
- el += post.title || post.seo_title || post.wiki;
40
+ el += (post.title || post.seo_title || post.wiki) + '</span>';
43
41
  el += '</a>';
44
- el += '</div>';
45
42
  el += '';
46
43
  });
47
44
  el += '</div>';
@@ -16,21 +16,21 @@ function layoutDiv() {
16
16
  var el = '';
17
17
  if (related.length > 0) {
18
18
  el += '<div class="widget-wrap" id="related">';
19
- el += '<div class="widget-header cap dis-select">';
19
+ el += '<div class="widget-header cap theme dis-select">';
20
20
  var title = __('btn.wiki');
21
21
  if (proj.tags && proj.tags[0]) {
22
22
  title = proj.tags[0];
23
23
  }
24
24
  el += '<span class="name">' + __('meta.more', title) + '</span>';
25
25
  el += '</div>';
26
- el += '<div class="widget-body fs14">';
26
+ el += '<div class="widget-body related-posts">';
27
27
  related.forEach((p, i) => {
28
28
  // 同一个分组中的其它项目
29
- el += '<a class="more-item wiki" href="' + url_for(p.homepage.path) + '">';
30
- el += p.title;
31
- el += '<div class="excerpt">';
32
- el += p.description;
33
- el += '</div>';
29
+ el += '<a class="item wiki" href="' + url_for(p.homepage.path) + '">';
30
+ el += '<span class="title">' + p.title + '</span>';
31
+ if (p.description && p.description.length > 0) {
32
+ el += '<span class="excerpt">' + p.description + '</span>';
33
+ }
34
34
  el += '</a>';
35
35
  });
36
36
  el += '</div>';
@@ -0,0 +1,24 @@
1
+ <%
2
+ function layoutDiv() {
3
+ var el = '';
4
+ if (site.tags == undefined || site.tags.length == 0) {
5
+ return el;
6
+ }
7
+ var opts = Object.assign({}, item);
8
+ delete opts['title'];
9
+ delete opts['layout'];
10
+ opts.class = 'tag ';
11
+ el += '<div class="widget-wrap" id="tagcloud">';
12
+ if (item.title) {
13
+ el += '<div class="widget-header cap theme dis-select">';
14
+ el += '<span class="name">' + item.title + '</span>';
15
+ el += '</div>';
16
+ }
17
+ el += '<div class="widget-body fs14">';
18
+ el += tagcloud(site.tags, opts);
19
+ el += '</div>';
20
+ el += '</div>';
21
+ return el;
22
+ }
23
+ %>
24
+ <%- layoutDiv() %>
@@ -0,0 +1,27 @@
1
+ <%
2
+ function layoutDiv() {
3
+ var el = '';
4
+ if (item.api == undefined) {
5
+ return el;
6
+ }
7
+ el += '<div class="widget-wrap" id="timeline">';
8
+ if (item.title) {
9
+ el += '<div class="widget-header cap theme dis-select">';
10
+ el += '<span class="name">' + item.title + '</span>';
11
+ el += '</div>';
12
+ }
13
+ el += '<div class="widget-body fs14">';
14
+ el += '<div class="tag-plugin timeline stellar-timeline-api"';
15
+ ['api', 'user', 'hide'].forEach(key => {
16
+ if (item[key]) {
17
+ el += ' ' + key + '="' + item[key] + '"';
18
+ }
19
+ });
20
+ el += '>';
21
+ el += '</div>';
22
+ el += '</div>';
23
+ el += '</div>';
24
+ return el;
25
+ }
26
+ %>
27
+ <%- layoutDiv() %>
@@ -15,11 +15,7 @@ function layoutToc() {
15
15
  function layoutTocHeader(title) {
16
16
  var el = '';
17
17
  el += '<div class="widget-header cap dis-select">';
18
- if (title) {
19
- el += '<span class="name">' + title + '</span>';
20
- } else {
21
- el += '<span class="name">' + __("meta.toc") + '</span>';
22
- }
18
+ el += '<span class="name">' + (title || page.title || __("meta.toc")) + '</span>';
23
19
  el += '</div>';
24
20
  return el;
25
21
  }
package/layout/index.ejs CHANGED
@@ -13,7 +13,7 @@ if (page.title && page.wiki) {
13
13
  function layout_post_card(layout, post, content) {
14
14
  var el = '';
15
15
  var layout = layout;
16
- if (layout == 'post' && post.cover != undefined && post.cover_info != undefined) {
16
+ if (layout == 'post' && post['cover'] != undefined && post['cover-title'] != undefined) {
17
17
  layout += ' photo';
18
18
  }
19
19
  el += '<a class="post-card ' + layout + ' ' + scrollreveal() + '" href="' + url_for(post.link || post.path) + '">';
package/layout/page.ejs CHANGED
@@ -7,14 +7,23 @@ function layoutTitle() {
7
7
  return '';
8
8
  }
9
9
  }
10
+ function layoutDiv() {
11
+ var el = '';
12
+ if (page.post_list) {
13
+ el += partial('_partial/main/navbar/list_post');
14
+ }
15
+ if (page.h1 || page.title || (page.content && page.content.length > 0)) {
16
+ el += partial('_partial/main/navbar/breadcrumb');
17
+ }
18
+ el += '<article class="content md ' + page.layout + (page.indent ? ' indent' : '') + scrollreveal() + '">';
19
+ el += layoutTitle();
20
+ if (page.content && page.content.length > 0) {
21
+ el += page.content;
22
+ }
23
+ el += '</article>';
24
+ el += partial('_partial/plugins/comments/layout');
25
+ return el;
26
+ }
10
27
  %>
11
- <% if (page.h1 || page.title || (page.content && page.content.length > 0)) { %>
12
- <%- partial('_partial/main/navbar/breadcrumb') %>
13
- <article class='content md <%- page.layout %><%- page.indent ? ' indent' : '' %><%- scrollreveal() %>'>
14
- <%- layoutTitle() %>
15
- <% if (page.content && page.content.length > 0) { %>
16
- <%- page.content %>
17
- <% } %>
18
- </article>
19
- <% } %>
20
- <%- partial('_partial/plugins/comments/layout') %>
28
+
29
+ <%- layoutDiv() %>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-stellar",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "Elegant and powerful theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -25,7 +25,7 @@ module.exports = hexo => {
25
25
  warning('caching', '`relative_link` option in Hexo `_config.yml`');
26
26
  hexo.config.relative_link = false;
27
27
  }
28
- hexo.config.meta_generator = false;
28
+ // hexo.config.meta_generator = false;
29
29
 
30
30
  // merge data
31
31
  const data = hexo.locals.get('data');
@@ -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;
@@ -1,92 +1,53 @@
1
1
  /**
2
- * friends.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
2
+ * friends.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/
3
3
  * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
4
4
  *
5
- * {% friends [only:group1] [not:group2] %}
5
+ * {% friends [group] [repo:owner/repo] [api:http] %}
6
6
  */
7
7
 
8
8
  'use strict';
9
9
 
10
10
  hexo.extend.tag.register('friends', function(args) {
11
- args = hexo.args.map(args, ['only', 'not', 'repo', 'api']);
12
- if (args.only) {
13
- args.only = args.only.split(',');
11
+ args = hexo.args.map(args, ['repo', 'api'], ['group']);
12
+ var links = hexo.locals.get('data').links;
13
+ if (links == undefined) {
14
+ links = {};
14
15
  }
15
- if (args.not) {
16
- args.not = args.not.split(',');
17
- }
18
- var friends = hexo.locals.get('data').friends;
19
- if (friends == undefined) {
20
- friends = {};
21
- }
22
- if (args.repo) {
23
- friends = {
24
- group: {
25
- api: args.api,
26
- repo: args.repo
27
- }
28
- }
16
+ var api;
17
+ if (args.api) {
18
+ api = args.api;
19
+ } else if (args.repo) {
20
+ api = 'https://raw.github.xaoxuu.com/' + args.repo + '/output/v2/data.json';
29
21
  }
22
+
30
23
  var el = '<div class="tag-plugin users-wrap">';
31
- function groupHeader(group) {
32
- var header = '<div class="group-header">';
33
- if (group.title) {
34
- header += hexo.render.renderSync({text: group.title, engine: 'markdown'}).split('\n').join('');
35
- }
36
- if (group.description) {
37
- header += hexo.render.renderSync({text: group.description, engine: 'markdown'}).split('\n').join('');
38
- }
39
- header += '</div>';
40
- return header;
41
- }
42
- function cell(friend) {
43
- if (friend.url && friend.title) {
44
- var cell = '<div class="user-card">';
45
- cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + friend.url + '">';
46
- cell += '<img src="' + (friend.avatar || hexo.theme.config.default.avatar) + '" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;' + hexo.theme.config.default.avatar + '&quot;;"/>';
47
- cell += '<div class="name"><span>' + friend.title + '</span></div>';
48
- cell += '</a></div>'
49
- return cell;
50
- } else {
51
- return '';
52
- }
53
- }
54
- for (let groupId of Object.keys(friends)) {
55
- function f() {
56
- if (args.not && args.not.includes(groupId)) {
57
- return;
58
- }
59
- if (groupId in friends) {
60
- let group = friends[groupId];
61
- if ((typeof group == 'object') && group.constructor == Array) {
62
- group = {items: group};
63
- }
64
- if (group.title || group.description) {
65
- el += groupHeader(group);
66
- }
67
- if (group.repo) {
68
- el += '<div class="stellar-friends-api"';
69
- el += ' api="' + (group.api || 'https://issues-api.xaoxuu.com') + '/v1/' + group.repo + '"';
70
- el += '>';
71
- el += '<div class="group-body"></div>';
72
- el += '</div>';
73
- } else if (group.items) {
74
- el += '<div class="group-body">';
75
- group.items.forEach((friend, i) => {
76
- el += cell(friend);
77
- });
78
- el += '</div>';
79
- }
80
- }
81
- }
82
- if (args.only) {
83
- if (args.only.includes(groupId)) {
84
- f();
24
+ if (api) {
25
+ el += '<div class="stellar-friends-api"';
26
+ el += ' api="' + api + '"';
27
+ el += '>';
28
+ el += '<div class="group-body"></div>';
29
+ el += '</div>';
30
+ } else if (args.group) {
31
+ function cell(item) {
32
+ if (item.url && item.title) {
33
+ var cell = '<div class="user-card">';
34
+ cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + item.url + '">';
35
+ cell += '<img src="' + (item.avatar || hexo.theme.config.default.avatar) + '" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;' + hexo.theme.config.default.avatar + '&quot;;"/>';
36
+ cell += '<div class="name"><span>' + item.title + '</span></div>';
37
+ cell += '</a></div>'
38
+ return cell;
39
+ } else {
40
+ return '';
85
41
  }
86
- } else {
87
- f();
88
42
  }
43
+ el += '<div class="group-body">';
44
+ const items = links[args.group] || [];
45
+ items.forEach((item, i) => {
46
+ el += cell(item);
47
+ });
48
+ el += '</div>';
89
49
  }
50
+
90
51
  el += '</div>';
91
52
  return el;
92
53
  });
@@ -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>';