hexo-theme-stellar 1.10.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 (73) hide show
  1. package/_config.yml +39 -56
  2. package/_data/widgets.yml +70 -0
  3. package/languages/en.yml +0 -1
  4. package/languages/zh-CN.yml +4 -5
  5. package/languages/zh-TW.yml +4 -5
  6. package/layout/_partial/main/article/read_next.ejs +16 -17
  7. package/layout/_partial/main/navbar/breadcrumb.ejs +1 -1
  8. package/layout/_partial/main/navbar/list_post.ejs +2 -2
  9. package/layout/_partial/main/post_list/post_card.ejs +21 -15
  10. package/layout/_partial/main/post_list/wiki_card.ejs +1 -1
  11. package/layout/_partial/sidebar/header.ejs +2 -26
  12. package/layout/_partial/sidebar/index.ejs +6 -6
  13. package/layout/_partial/sidebar/logo.ejs +3 -3
  14. package/layout/_partial/sidebar/menu.ejs +27 -0
  15. package/layout/_partial/sidebar/widgets/ghissues.ejs +46 -0
  16. package/layout/_partial/sidebar/widgets/ghrepo.ejs +53 -0
  17. package/layout/_partial/sidebar/widgets/ghuser.ejs +9 -11
  18. package/layout/_partial/sidebar/widgets/markdown.ejs +1 -1
  19. package/layout/_partial/sidebar/widgets/recent.ejs +8 -11
  20. package/layout/_partial/sidebar/widgets/{wiki_more.ejs → related.ejs} +7 -7
  21. package/layout/_partial/sidebar/widgets/tagcloud.ejs +24 -0
  22. package/layout/_partial/sidebar/widgets/timeline.ejs +27 -0
  23. package/layout/_partial/sidebar/widgets/toc.ejs +2 -6
  24. package/layout/index.ejs +1 -1
  25. package/package.json +1 -1
  26. package/scripts/events/lib/config.js +26 -10
  27. package/scripts/events/lib/doc_tree.js +3 -0
  28. package/scripts/helpers/related_posts.js +11 -39
  29. package/scripts/tags/about.js +10 -7
  30. package/scripts/tags/{grid.js → border.js} +4 -4
  31. package/scripts/tags/folders.js +55 -0
  32. package/scripts/tags/link.js +11 -9
  33. package/scripts/tags/navbar.js +1 -1
  34. package/scripts/tags/sites.js +1 -1
  35. package/scripts/tags/split.js +51 -0
  36. package/scripts/tags/timeline.js +4 -2
  37. package/source/css/_common/base.styl +5 -2
  38. package/source/css/_common/blur.styl +3 -0
  39. package/source/css/_common/device.styl +2 -0
  40. package/source/css/_common/highlight.styl +1 -1
  41. package/source/css/_common/loading.styl +16 -3
  42. package/source/css/_common/title.styl +0 -13
  43. package/source/css/_custom.styl +23 -26
  44. package/source/css/_defines/theme.styl +12 -12
  45. package/source/css/_layout/list.styl +40 -9
  46. package/source/css/_layout/md.styl +2 -2
  47. package/source/css/_layout/partial/related.styl +62 -93
  48. package/source/css/_layout/sidebar/footer.styl +4 -2
  49. package/source/css/_layout/sidebar/ghrepo.styl +36 -0
  50. package/source/css/_layout/sidebar/ghuser.styl +19 -1
  51. package/source/css/_layout/sidebar/sidebar.styl +4 -91
  52. package/source/css/_layout/sidebar/toc_common.styl +5 -3
  53. package/source/css/_layout/sidebar/widgets.styl +104 -0
  54. package/source/css/_layout/tag-plugins/about.styl +21 -17
  55. package/source/css/_layout/tag-plugins/common.styl +36 -31
  56. package/source/css/_layout/tag-plugins/folders.styl +62 -0
  57. package/source/css/_layout/tag-plugins/link.styl +41 -27
  58. package/source/css/_layout/tag-plugins/navbar.styl +10 -4
  59. package/source/css/_layout/tag-plugins/poetry.styl +1 -1
  60. package/source/css/_layout/tag-plugins/quot.styl +8 -7
  61. package/source/css/_layout/tag-plugins/split.styl +28 -0
  62. package/source/css/_layout/tag-plugins/timeline.styl +69 -41
  63. package/source/css/_plugins/comments/twikoo.styl +12 -6
  64. package/source/css/_plugins/comments/valine.styl +4 -0
  65. package/source/css/_plugins/comments/waline.styl +2 -2
  66. package/source/js/main.js +14 -8
  67. package/source/js/plugins/friends.js +3 -2
  68. package/source/js/plugins/ghinfo.js +14 -2
  69. package/source/js/plugins/linkcard.js +124 -0
  70. package/source/js/plugins/sites.js +4 -3
  71. package/source/js/plugins/timeline.js +60 -33
  72. package/layout/_partial/sidebar/widgets/repo_info.ejs +0 -91
  73. package/source/css/_layout/sidebar/repo_info.styl +0 -31
@@ -3,17 +3,17 @@ var btns = [];
3
3
  btns.push({
4
4
  key: 'followers',
5
5
  desc: 'followers',
6
- href: '?tab=followers'
6
+ tab: 'followers'
7
7
  });
8
8
  btns.push({
9
9
  key: 'following',
10
10
  desc: 'following',
11
- href: '?tab=following'
11
+ tab: 'following'
12
12
  });
13
13
  btns.push({
14
14
  key: 'public_repos',
15
15
  desc: 'repos',
16
- href: '?tab=repositories'
16
+ tab: 'repositories'
17
17
  });
18
18
 
19
19
  function layoutDiv() {
@@ -23,24 +23,18 @@ function layoutDiv() {
23
23
  }
24
24
 
25
25
  el += '<div class="widget-wrap" id="github-user">';
26
- // header
27
- if (item.header && item.header.length > 0) {
28
- el += '<div class="widget-header cap dis-select">';
29
- el += '<span class="name">' + item.header + '</span>';
30
- el += '</div>';
31
- }
32
26
  // body
33
27
  el += '<div class="widget-body stellar-ghinfo-api" api="' + item.api + '/users/' + item.username + '">';
34
28
  if (item.avatar) {
35
29
  el += '<div class="avatar" ><img no-lazy type="img" id="avatar_url" src="' + config.avatar + '"></div>';
36
30
  }
37
31
  // username
38
- el += '<p class="username" type="text" id="name" href="https://github.com/' + item.username + '">&nbsp;</p>';
32
+ el += '<p class="username" ff="title" type="text" id="name">&nbsp;</p>';
39
33
  el += '<p class="bio" type="text" id="bio">&nbsp;</p>';
40
34
 
41
35
  el += '<div class="buttons">';
42
36
  btns.forEach((btn, i) => {
43
- el += '<a class="btn" href="https://github.com/' + item.username + '' + btn.href + '">';
37
+ el += '<a class="btn" href="https://github.com/' + item.username + '?tab=' + btn.tab + '">';
44
38
  el += '<span class="title" type="text" id="' + btn.key + '">0</span>';
45
39
  el += '<span class="desc">' + btn.desc + '</span>';
46
40
  el += '</a>';
@@ -51,6 +45,10 @@ function layoutDiv() {
51
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>';
52
46
  el += 'Follow';
53
47
  el += '</a>';
48
+ // menu
49
+ if (item.menu) {
50
+ el += partial('../menu', {where: 'sidebar'});
51
+ }
54
52
  el += '</div>';
55
53
  el += '</div>';
56
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'].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
  }
@@ -92,7 +88,7 @@ function layoutDiv(fallback) {
92
88
  }
93
89
  el += '</div>';
94
90
  } else if (item.fallback) {
95
- el += partial(item.fallback, {item: theme.sidebar.widgets[item.fallback]});
91
+ el += partial(item.fallback, {item: theme.data.widgets[item.fallback]});
96
92
  }
97
93
  return el;
98
94
  }
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-stellar",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "Elegant and powerful theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -1,10 +1,14 @@
1
1
  /**
2
2
  * 部分代码借鉴自 NexT:
3
3
  * https://github.com/next-theme/hexo-theme-next/blob/master/scripts/events/lib/config.js
4
+ * Volantis:
5
+ * https://github.com/volantis-x/hexo-theme-volantis/blob/master/scripts/events/lib/cdn.js
4
6
  */
5
7
 
6
8
  'use strict';
7
9
 
10
+ const path = require('path');
11
+
8
12
  module.exports = hexo => {
9
13
 
10
14
  const { cache, language_switcher } = hexo.theme.config;
@@ -25,23 +29,35 @@ module.exports = hexo => {
25
29
 
26
30
  // merge data
27
31
  const data = hexo.locals.get('data');
32
+ // merge widgets
33
+ var widgets = hexo.render.renderSync({ path: path.join(hexo.theme_dir, '_data/widgets.yml'), engine: 'yaml' });
28
34
  if (data.widgets) {
29
- for (let id of Object.keys(data.widgets)) {
30
- hexo.theme.config.sidebar.widgets[id] = data.widgets[id];
35
+ for (let i of Object.keys(data.widgets)) {
36
+ let widget = data.widgets[i];
37
+ if (widget == null || widget.length == 0) {
38
+ // delete
39
+ delete widgets[i];
40
+ } else {
41
+ // create
42
+ if (widgets[i] == null) {
43
+ widgets[i] = widget;
44
+ } else {
45
+ // merge
46
+ for (let j of Object.keys(widget)) {
47
+ widgets[i][j] = widget[j];
48
+ }
49
+ }
50
+ }
31
51
  }
32
52
  }
53
+ if (hexo.theme.config.data == undefined) {
54
+ hexo.theme.config.data = {};
55
+ }
56
+ hexo.theme.config.data['widgets'] = widgets;
33
57
 
34
58
  // default menu
35
59
  if (hexo.theme.config.sidebar.menu == undefined) {
36
60
  hexo.theme.config.sidebar.menu = [];
37
61
  }
38
- // default widgets
39
- if (hexo.theme.config.sidebar.widgets.repo_info == undefined) {
40
- hexo.theme.config.sidebar.widgets.repo_info = {layout: 'repo_info'};
41
- }
42
- if (hexo.theme.config.sidebar.widgets.wiki_more == undefined) {
43
- hexo.theme.config.sidebar.widgets.wiki_more = {layout: 'wiki_more'};
44
- }
45
-
46
62
 
47
63
  };
@@ -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;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * folders.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
3
+ * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
4
+ *
5
+ * {% folders [color:white] %}
6
+ * <!-- folder title 1 -->
7
+ * body 1
8
+ * <!-- folder title 2 -->
9
+ * body 2
10
+ * {% endtable %}
11
+ */
12
+
13
+ 'use strict';
14
+
15
+ hexo.extend.tag.register('folders', function(args, content) {
16
+ args = hexo.args.map(args, ['color']);
17
+ var el = '';
18
+ el += '<div class="tag-plugin folders"';
19
+ el += ' ' + hexo.args.joinTags(args, ['color']).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.startsWith('folder ')) {
29
+ nodes.push({
30
+ header: item.substring(7)
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 += '<details class="folder" index="' + (i) + '">';
43
+ // summary
44
+ el += '<summary><span>' + (node.header || '') + '</span></summary>';
45
+ // content
46
+ el += '<div class="body">';
47
+ el += hexo.render.renderSync({text: node.body, engine: 'markdown'}).split('\n').join('');
48
+ el += '</div></details>';
49
+ });
50
+ }
51
+
52
+ el += '</div>';
53
+
54
+ return el;
55
+ }, {ends: true});
@@ -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});
@@ -36,11 +36,13 @@ function layoutNodeContent(content) {
36
36
 
37
37
 
38
38
  function postTimeline(args, content) {
39
- args = hexo.args.map(args, ['api']);
39
+ args = hexo.args.map(args, ['api', 'user']);
40
40
  var el = '';
41
41
 
42
42
  if (args.api && args.api.length > 0) {
43
- el += '<div class="tag-plugin timeline stellar-timeline-api" api="' + args.api + '">';
43
+ el += '<div class="tag-plugin timeline stellar-timeline-api"';
44
+ el += ' ' + hexo.args.joinTags(args, ['api', 'user']).join(' ');
45
+ el += '>';
44
46
  } else {
45
47
  el += '<div class="tag-plugin timeline">';
46
48
  }