hexo-theme-stellar 1.22.1 → 1.24.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 (80) hide show
  1. package/_config.yml +21 -9
  2. package/_data/widgets.yml +3 -0
  3. package/languages/en.yml +1 -0
  4. package/languages/zh-CN.yml +1 -0
  5. package/languages/zh-TW.yml +1 -0
  6. package/layout/_partial/head.ejs +29 -19
  7. package/layout/_partial/main/article/article_footer.ejs +16 -5
  8. package/layout/_partial/main/footer.ejs +18 -24
  9. package/layout/_partial/main/navbar/author_banner.ejs +31 -0
  10. package/layout/_partial/main/navbar/breadcrumb.ejs +20 -4
  11. package/layout/_partial/main/post_list/post_card.ejs +13 -1
  12. package/layout/_partial/plugins/comments/giscus/script.ejs +0 -1
  13. package/layout/_partial/plugins/parser/head.ejs +3 -0
  14. package/layout/_partial/plugins/parser/katex/head.ejs +3 -0
  15. package/layout/_partial/plugins/parser/katex/script.ejs +4 -0
  16. package/layout/_partial/plugins/parser/mathjax/script.ejs +20 -0
  17. package/layout/_partial/plugins/parser/mermaid/script.ejs +29 -0
  18. package/layout/_partial/plugins/parser/script.ejs +9 -0
  19. package/layout/_partial/scripts/index.ejs +19 -5
  20. package/layout/_partial/sidebar/index.ejs +1 -1
  21. package/layout/_partial/widgets/markdown.ejs +7 -2
  22. package/layout/_partial/widgets/toc.ejs +1 -1
  23. package/layout/archive.ejs +54 -37
  24. package/layout/page.ejs +1 -4
  25. package/layout/post.ejs +1 -7
  26. package/layout/wiki.ejs +1 -4
  27. package/package.json +1 -1
  28. package/scripts/events/index.js +2 -0
  29. package/scripts/events/lib/authors.js +21 -0
  30. package/scripts/events/lib/doc_tree.js +1 -2
  31. package/scripts/events/lib/links.js +17 -0
  32. package/scripts/generators/author.js +22 -0
  33. package/scripts/tags/index.js +5 -0
  34. package/scripts/tags/lib/albums.js +47 -0
  35. package/scripts/tags/lib/audio.js +23 -0
  36. package/scripts/tags/lib/copy.js +11 -13
  37. package/scripts/tags/lib/friends.js +13 -24
  38. package/scripts/tags/lib/gallery.js +6 -5
  39. package/scripts/tags/lib/grid.js +30 -30
  40. package/scripts/tags/lib/md.js +20 -0
  41. package/scripts/tags/lib/posters.js +47 -0
  42. package/scripts/tags/lib/sites.js +15 -24
  43. package/scripts/tags/lib/swiper.js +1 -1
  44. package/scripts/tags/lib/video.js +23 -0
  45. package/source/css/_common/media.styl +9 -0
  46. package/source/css/_common/toast.styl +25 -5
  47. package/source/css/_custom.styl +2 -1
  48. package/source/css/_defines/func.styl +11 -0
  49. package/source/css/_defines/theme.styl +2 -2
  50. package/source/css/_layout/list.styl +10 -12
  51. package/source/css/_layout/main.styl +4 -0
  52. package/source/css/_layout/md.styl +3 -0
  53. package/source/css/_layout/pages/archives.styl +10 -10
  54. package/source/css/_layout/partial/bread-nav.styl +3 -5
  55. package/source/css/_layout/partial/cover.styl +1 -0
  56. package/source/css/_layout/partial/navbar.styl +5 -5
  57. package/source/css/_layout/tag-plugins/banner.styl +24 -10
  58. package/source/css/_layout/tag-plugins/copy.styl +16 -13
  59. package/source/css/_layout/tag-plugins/folding.styl +6 -0
  60. package/source/css/_layout/tag-plugins/friends.styl +10 -37
  61. package/source/css/_layout/tag-plugins/gallery.styl +32 -15
  62. package/source/css/_layout/tag-plugins/grid.styl +3 -10
  63. package/source/css/_layout/tag-plugins/link.styl +2 -5
  64. package/source/css/_layout/tag-plugins/note.styl +7 -0
  65. package/source/css/_layout/tag-plugins/sites.styl +11 -39
  66. package/source/css/_layout/tag-plugins/tabs.styl +2 -0
  67. package/source/css/_layout/widgets/ghrepo.styl +1 -4
  68. package/source/css/_layout/widgets/toc_common.styl +22 -8
  69. package/source/css/_plugins/copycode.styl +18 -16
  70. package/source/css/_plugins/fancybox.styl +1 -4
  71. package/source/css/_plugins/index.styl +1 -1
  72. package/source/css/_plugins/lazyload.styl +4 -4
  73. package/source/js/main.js +7 -9
  74. package/source/js/plugins/copycode.js +1 -1
  75. package/source/js/plugins/friends.js +11 -11
  76. package/source/js/plugins/marked.js +50 -0
  77. package/source/js/plugins/sites.js +13 -14
  78. package/_data/links.yml +0 -7
  79. package/layout/mathjax.ejs +0 -29
  80. package/layout/mermaid.ejs +0 -32
@@ -3,41 +3,58 @@ page.robots = 'noindex,follow';
3
3
  if (page.menu_id == undefined) {
4
4
  page.menu_id = 'post';
5
5
  }
6
+ if (page.author) {
7
+ page.header = 'auto';
8
+ }
9
+ function layoutArchiveList() {
10
+ var el = ''
11
+ if (page.author) {
12
+ page.title = page.author.name
13
+ el += partial('_partial/main/navbar/author_banner')
14
+ } else {
15
+ page.title = __('btn.archives')
16
+ el += partial('_partial/main/navbar/list_post')
17
+ }
18
+ el += `<div class="post-list archives">`
19
+ var years = []
20
+ site.posts.sort('date', -1).each(function(post) {
21
+ post.year = date(post.date, 'YYYY')
22
+ if (post.year && (years.includes(post.year) == false) && (post.title || post.date)) {
23
+ years.push(post.year)
24
+ }
25
+ })
26
+ for (let year of years) {
27
+ el += `<article class="${scrollreveal()}" id="archive">`
28
+ el += `<div class='archive-header h4'>${year}</div>`
29
+ site.posts.sort('date', -1).filter(function (post) {
30
+ post.year = date(post.date, 'YYYY')
31
+ return post.year == year
32
+ }).each(function(post) {
33
+ el += `<div class="archive-list">`
34
+ el +=`<a class='post fs14' href="${url_for(post.link || post.path)}">`
35
+ el += `<time>${date(post.date, 'MM-DD')}</time>`
36
+ el += `<span>`
37
+ if (post.title) {
38
+ el += post.title
39
+ } else if (post.date) {
40
+ el += date(post.date, config.date_format)
41
+ }
42
+ el += `</span>`
43
+ el += `</a>`
44
+ el += `</div>`
45
+ })
46
+ el += `</article>`
47
+ }
48
+ el += `</div>`
49
+ return el
50
+ }
51
+ function layoutDiv() {
52
+ if (page.posts && (is_category() || is_tag())) {
53
+ return partial('index')
54
+ } else {
55
+ return layoutArchiveList()
56
+ }
57
+ }
6
58
  %>
7
- <% if (page.posts && (is_category() || is_tag())) { %>
8
- <%- partial('index') %>
9
- <% } else { %>
10
- <% page.title = __('btn.archives'); %>
11
- <%- partial('_partial/main/navbar/list_post') %>
12
- <div class='post-list'>
13
- <% var years = []; %>
14
- <% site.posts.sort('date', -1).each(function(post) { %>
15
- <% post.year = date(post.date, 'YYYY'); %>
16
- <% if (post.year && (years.includes(post.year) == false) && (post.title || post.date)) { %>
17
- <% years.push(post.year); %>
18
- <% } %>
19
- <% }); %>
20
- <% years.forEach((year, i) => { %>
21
- <article class='<%- scrollreveal() %>' id='archive'>
22
- <div class='archive-header h4'><%= year %></div>
23
- <% site.posts.sort('date', -1).filter(function (post) { %>
24
- <% post.year = date(post.date, 'YYYY'); %>
25
- <% return post.year == year; %>
26
- <% }).each(function(post) { %>
27
- <div class='archive-list'>
28
- <a class='post fs14' href="<%= url_for(post.link || post.path) %>">
29
- <time><%= date(post.date, 'MM-DD') %></time>
30
- <span>
31
- <% if (post.title) { %>
32
- <%- post.title %>
33
- <% } else if (post.date) { %>
34
- <%= date(post.date, config.date_format) %>
35
- <% } %>
36
- </span>
37
- </a>
38
- </div>
39
- <% }); %>
40
- </article>
41
- <% }); %>
42
- </div>
43
- <% } %>
59
+
60
+ <%- layoutDiv() %>
package/layout/page.ejs CHANGED
@@ -1,6 +1,6 @@
1
1
  <%
2
2
  function layoutTitle() {
3
- const title = page.h1 || page.title;
3
+ const title = page.h1 != null ? page.h1 : page.title;
4
4
  if (title && title.length > 0) {
5
5
  return '<h1 class="article-title"><span>' + title + '</span></h1>';
6
6
  } else {
@@ -12,9 +12,6 @@ function layoutDiv() {
12
12
  if (page.post_list) {
13
13
  el += partial('_partial/main/navbar/list_post');
14
14
  }
15
- if (page.mermaid == true) {
16
- el += partial('mermaid');
17
- }
18
15
  if (page.h1 || page.title || (page.content && page.content.length > 0)) {
19
16
  el += partial('_partial/main/navbar/breadcrumb');
20
17
  }
package/layout/post.ejs CHANGED
@@ -6,7 +6,7 @@ if (page.header == undefined) {
6
6
  page.header = 'auto';
7
7
  }
8
8
  function layoutTitle() {
9
- const title = page.h1 || page.title;
9
+ const title = page.h1 != null ? page.h1 : page.title;
10
10
  if (title && title.length > 0) {
11
11
  return '<h1 class="article-title"><span>' + title + '</span></h1>';
12
12
  } else {
@@ -19,12 +19,6 @@ if (theme.plugins.heti && theme.plugins.heti.enable) {
19
19
  heti = ' heti';
20
20
  }
21
21
  %>
22
- <% if (page.mathjax == true){ %>
23
- <%- partial('mathjax') %>
24
- <% } %>
25
- <% if (page.mermaid == true){ %>
26
- <%- partial('mermaid') %>
27
- <% } %>
28
22
  <%- partial('_partial/main/navbar/breadcrumb') %>
29
23
  <article class='md-text content<%- heti %> <%- post.layout %><%- post.indent ? ' indent' : '' %><%- scrollreveal() %>'>
30
24
  <%- layoutTitle() %>
package/layout/wiki.ejs CHANGED
@@ -13,7 +13,7 @@ if (page.title == undefined) {
13
13
  }
14
14
  }
15
15
  function layoutTitle() {
16
- const title = page.h1 || page.title;
16
+ const title = page.h1 != null ? page.h1 : page.title;
17
17
  if (title && title.length > 0) {
18
18
  return '<h1 class="article-title"><span>' + title + '</span></h1>';
19
19
  } else {
@@ -29,9 +29,6 @@ function layoutTitle() {
29
29
  page.header = 'auto';
30
30
  }
31
31
  %>
32
- <% if (page.mermaid == true){ %>
33
- <%- partial('mermaid') %>
34
- <% } %>
35
32
  <%- partial('_partial/main/navbar/breadcrumb') %>
36
33
  <article class='md-text content <%- page.layout %><%- page.indent ? ' indent' : '' %><%- scrollreveal() %>'>
37
34
  <%- layoutTitle() %>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-stellar",
3
- "version": "1.22.1",
3
+ "version": "1.24.0",
4
4
  "description": "Elegant and powerful theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -5,6 +5,8 @@
5
5
  hexo.on('generateBefore', () => {
6
6
  // Merge config.
7
7
  require('./lib/config')(hexo);
8
+ require('./lib/links')(hexo);
9
+ require('./lib/authors')(hexo);
8
10
  require('./lib/doc_tree')(hexo);
9
11
  require('./lib/utils')(hexo);
10
12
  });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * authors.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/
3
+ */
4
+
5
+ 'use strict';
6
+
7
+ module.exports = ctx => {
8
+ var authors = ctx.locals.get('data').authors || {}
9
+ let basePath = ctx.config.author_dir || 'author'
10
+ // url
11
+ for (let key of Object.keys(authors)) {
12
+ let author = authors[key]
13
+ author.path = `${basePath}/${key}/index.html`
14
+ }
15
+ // default author
16
+ const keys = Object.keys(authors)
17
+ if (keys.length > 0) {
18
+ ctx.theme.config.default_author = authors[keys[0]]
19
+ }
20
+ ctx.theme.config.authors = authors
21
+ }
@@ -59,7 +59,7 @@ module.exports = ctx => {
59
59
  const wiki_pages = pages.filter(p => (p.layout === 'wiki')).map(p => new WikiPage(p))
60
60
  const wiki_list = Object.keys(wiki.tree)
61
61
  // 上架的项目列表
62
- wiki.shelf = ctx.locals.get('data').wiki
62
+ wiki.shelf = ctx.locals.get('data').wiki || []
63
63
 
64
64
  // 数据整合:项目标签
65
65
  var all_tag_name = []
@@ -202,7 +202,6 @@ module.exports = ctx => {
202
202
 
203
203
  wiki.all_tags = all_tags
204
204
  wiki.all_pages = wiki_pages
205
- wiki.shelf = ctx.locals.get('data').wiki
206
205
  ctx.theme.config.wiki = wiki
207
206
 
208
207
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * links.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
3
+ */
4
+
5
+ 'use strict';
6
+
7
+ module.exports = ctx => {
8
+ var allLinks = {}
9
+ const data = ctx.locals.get('data')
10
+ for (let key of Object.keys(data)) {
11
+ if (key.startsWith('links/')) {
12
+ let newKey = key.replace('links/', '')
13
+ allLinks[newKey] = data[key]
14
+ }
15
+ }
16
+ ctx.theme.config.links = allLinks
17
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * author v1 | https://github.com/xaoxuu/hexo-theme-stellar/
3
+ */
4
+
5
+ hexo.extend.generator.register('author', function (locals) {
6
+ const { authors } = hexo.theme.config
7
+ var pages = []
8
+ for (let key of Object.keys(authors)) {
9
+ const author = authors[key]
10
+ if (author.hidden) {
11
+ continue
12
+ }
13
+ pages.push({
14
+ path: author.path,
15
+ layout: ['archive'],
16
+ data: {
17
+ 'author': author
18
+ }
19
+ })
20
+ }
21
+ return pages
22
+ });
@@ -16,10 +16,13 @@ hexo.extend.tag.register('banner', require('./lib/banner')(hexo), true)
16
16
  // data
17
17
  hexo.extend.tag.register('users', require('./lib/friends')(hexo))
18
18
  hexo.extend.tag.register('friends', require('./lib/friends')(hexo))
19
+ hexo.extend.tag.register('albums', require('./lib/albums')(hexo))
20
+ hexo.extend.tag.register('posters', require('./lib/posters')(hexo))
19
21
  hexo.extend.tag.register('sites', require('./lib/sites')(hexo))
20
22
  hexo.extend.tag.register('ghcard', require('./lib/ghcard')(hexo))
21
23
  hexo.extend.tag.register('toc', require('./lib/toc')(hexo))
22
24
  hexo.extend.tag.register('timeline', require('./lib/timeline')(hexo), {ends: true})
25
+ hexo.extend.tag.register('md', require('./lib/md')(hexo))
23
26
 
24
27
  // express
25
28
  hexo.extend.tag.register('checkbox', require('./lib/checkbox')(hexo, 'checkbox'))
@@ -36,4 +39,6 @@ hexo.extend.tag.register('poetry', require('./lib/poetry')(hexo), true)
36
39
  hexo.extend.tag.register('quot', require('./lib/quot')(hexo))
37
40
  hexo.extend.tag.register('hashtag', require('./lib/hashtag')(hexo))
38
41
  hexo.extend.tag.register('okr', require('./lib/okr')(hexo), {ends: true})
42
+ hexo.extend.tag.register('audio', require('./lib/audio')(hexo))
43
+ hexo.extend.tag.register('video', require('./lib/video')(hexo))
39
44
  // others
@@ -0,0 +1,47 @@
1
+ /**
2
+ * albums.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
3
+ * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
4
+ *
5
+ * {% albums [group] [repo:owner/repo] [api:http] [size:s/m/l/xl/mix] %}
6
+ */
7
+
8
+ 'use strict'
9
+
10
+ module.exports = ctx => function(args) {
11
+ var args = ctx.args.map(args, ['repo', 'api', 'size'], ['group'])
12
+ if (args.size == null) {
13
+ args.size = 's'
14
+ }
15
+ var api
16
+ if (args.api) {
17
+ api = args.api
18
+ } else if (args.repo) {
19
+ api = 'https://api.vlts.cc/output_data/v2/' + args.repo
20
+ }
21
+
22
+ var el = ''
23
+ el += `<div class="tag-plugin albums-wrap">`
24
+ if (api) {
25
+ el += `<div class="stellar-friends-api" api="${api}"><div class="tag-plugin gallery grid-box" layout="grid" ratio="square" ${ctx.args.joinTags(args, ['size']).join(' ')}></div></div>`
26
+ } else if (args.group) {
27
+ const links = ctx.theme.config.links || {}
28
+ el += `<div class="tag-plugin gallery grid-box" layout="grid" ratio="square" ${ctx.args.joinTags(args, ['size']).join(' ')}>`
29
+ for (let item of (links[args.group] || [])) {
30
+ if (item?.url) {
31
+ el += `<div class="grid-cell album-card">`
32
+ el += `<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="${item.url}">`
33
+ el += `<img src="${item.icon || item.avatar || ctx.theme.config.default.cover}" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;${ctx.theme.config.default.cover}&quot;;"/>`
34
+ el += `<div class="image-meta">`
35
+ if (item.title) {
36
+ el += `<span class="image-caption">${item.title}</span>`
37
+ }
38
+ el += `</div>`
39
+ el += `</a>`
40
+ el += `</div>`
41
+ }
42
+ }
43
+ el += `</div>`
44
+ }
45
+ el += `</div>`
46
+ return el
47
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * audio.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/
3
+ * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
4
+ *
5
+ * {% audio src %}
6
+ *
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ module.exports = ctx => function(args) {
12
+ args = ctx.args.map(args, ['type'], ['src'])
13
+ if (args.type == null) {
14
+ args.type = 'audio/mp3'
15
+ }
16
+ return `
17
+ <div class="tag-plugin video">
18
+ <audio controls preload>
19
+ <source src="${args.src}" type="${args.type}">Your browser does not support the audio tag.
20
+ </audio>
21
+ </div>
22
+ `
23
+ }
@@ -12,7 +12,7 @@
12
12
  var copy_index = 0
13
13
 
14
14
  module.exports = ctx => function(args) {
15
- args = ctx.args.map(args, ['width', 'git'], ['text'])
15
+ args = ctx.args.map(args, ['git', 'prefix'], ['text'])
16
16
  if (args == undefined || args.text == undefined) {
17
17
  return ''
18
18
  }
@@ -31,19 +31,17 @@ module.exports = ctx => function(args) {
31
31
  }
32
32
 
33
33
  const copy_id = 'copy_' + ++copy_index
34
+ const toast = ctx.theme.config.tag_plugins.copy.toast
34
35
 
35
- var el = ''
36
- el += '<div class="tag-plugin copy"'
37
- if (args.width) {
38
- el += ' width="' + args.width + '"'
36
+ var el = ``
37
+ el += `<div class="tag-plugin copy">`
38
+ if (args.prefix?.length > 0) {
39
+ el += `<span>${args.prefix}</span>`
39
40
  }
40
- el += '>'
41
- el += '<input class="copy-area" readonly id="' + copy_id + '"'
42
- el += ' value="' + text + '">'
43
- el += '<button class="copy-btn" onclick="util.copy(&quot;' + copy_id + '&quot;,&quot;Copied!&quot;)">'
44
- el += '<svg class="icon copy-btn" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M5.75 1a.75.75 0 00-.75.75v3c0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75v-3a.75.75 0 00-.75-.75h-4.5zm.75 3V2.5h3V4h-3zm-2.874-.467a.75.75 0 00-.752-1.298A1.75 1.75 0 002 3.75v9.5c0 .966.784 1.75 1.75 1.75h8.5A1.75 1.75 0 0014 13.25v-9.5a1.75 1.75 0 00-.874-1.515.75.75 0 10-.752 1.298.25.25 0 01.126.217v9.5a.25.25 0 01-.25.25h-8.5a.25.25 0 01-.25-.25v-9.5a.25.25 0 01.126-.217z"></path></svg>'
45
- el += '</button>'
46
-
47
- el += '</div>'
41
+ el += `<input class="copy-area" id="${copy_id}" value="${text}">`
42
+ el += `<button class="copy-btn" onclick="util.copy(&quot;${copy_id}&quot;,&quot;${toast}&quot;)">`
43
+ el += `<svg class="icon copy-btn" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M5.75 1a.75.75 0 00-.75.75v3c0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75v-3a.75.75 0 00-.75-.75h-4.5zm.75 3V2.5h3V4h-3zm-2.874-.467a.75.75 0 00-.752-1.298A1.75 1.75 0 002 3.75v9.5c0 .966.784 1.75 1.75 1.75h8.5A1.75 1.75 0 0014 13.25v-9.5a1.75 1.75 0 00-.874-1.515.75.75 0 10-.752 1.298.25.25 0 01.126.217v9.5a.25.25 0 01-.25.25h-8.5a.25.25 0 01-.25-.25v-9.5a.25.25 0 01.126-.217z"></path></svg>`
44
+ el += `</button>`
45
+ el += `</div>`
48
46
  return el
49
47
  }
@@ -9,10 +9,6 @@
9
9
 
10
10
  module.exports = ctx => function(args) {
11
11
  args = ctx.args.map(args, ['repo', 'api'], ['group'])
12
- var links = ctx.locals.get('data').links
13
- if (links == undefined) {
14
- links = {}
15
- }
16
12
  var api
17
13
  if (args.api) {
18
14
  api = args.api
@@ -22,29 +18,22 @@ module.exports = ctx => function(args) {
22
18
 
23
19
  var el = '<div class="tag-plugin users-wrap">'
24
20
  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>'
21
+ el += `<div class="stellar-friends-api" ${ctx.args.joinTags(args, ['size']).join(' ')} api="${api}"><div class="grid-box"></div></div>`
30
22
  } 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 || ctx.theme.config.default.avatar) + '" onerror="javascript:this.removeAttribute(&quotdata-src&quot)this.src=&quot' + ctx.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 ''
23
+ const links = ctx.theme.config.links || {}
24
+ el += '<div class="grid-box">'
25
+ for (let item of (links[args.group] || [])) {
26
+ if (item?.url && item?.title) {
27
+ el += `<div class="grid-cell user-card">`
28
+ el += `<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="${item.url}">`
29
+ el += `<img src="${item.icon || item.avatar || ctx.theme.config.default.avatar}" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;${ctx.theme.config.default.avatar}&quot;;"/>`
30
+ el += `<div class="name">`
31
+ el += `<span>${item.title}</span>`
32
+ el += `</div>`
33
+ el += `</a>`
34
+ el += `</div>`
41
35
  }
42
36
  }
43
- el += '<div class="group-body">'
44
- const items = links[args.group] || []
45
- items.forEach((item, i) => {
46
- el += cell(item)
47
- })
48
37
  el += '</div>'
49
38
  }
50
39
 
@@ -33,9 +33,6 @@ function img(src, alt) {
33
33
 
34
34
  module.exports = ctx => function(args, content) {
35
35
  args = ctx.args.map(args, ['layout', 'size', 'ratio'])
36
- if (args.layout == null) {
37
- args.layout = ctx.theme.config.tag_plugins.gallery.layout
38
- }
39
36
  if (args.size == null) {
40
37
  args.size = ctx.theme.config.tag_plugins.gallery.size
41
38
  }
@@ -43,14 +40,18 @@ module.exports = ctx => function(args, content) {
43
40
  args.ratio = ctx.theme.config.tag_plugins.gallery.ratio
44
41
  }
45
42
  var el = ''
46
- el += `<div class="tag-plugin gallery" ${ctx.args.joinTags(args, ['layout', 'size', 'ratio']).join(' ')}>`
43
+ var layoutType = 'grid'
44
+ if (args.layout == 'flow') {
45
+ layoutType = 'flow'
46
+ }
47
+ el += `<div class="tag-plugin gallery fancybox ${layoutType}-box" ${ctx.args.joinTags(args, ['size', 'ratio']).join(' ')}>`
47
48
  const img_mds = content.split('\n').filter(item => item.trim().length > 0)
48
49
  for (let md of img_mds) {
49
50
  const matches = md.match(/\!\[(.*?)\]\((.*?)\)/i)
50
51
  if (matches?.length > 2) {
51
52
  let alt = matches[1]
52
53
  let src = matches[2]
53
- el += `<div class="cell">${img(src, alt)}</div>`
54
+ el += `<div class="${layoutType}-cell">${img(src, alt)}</div>`
54
55
  }
55
56
  }
56
57
  el += `</div>`
@@ -2,10 +2,10 @@
2
2
  * grid.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/
3
3
  * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
4
4
  *
5
- * {% grid [style:block/card] %}
6
- * <!-- cell left -->
5
+ * {% grid [bg:box/card] [w:240px] [c:2] [gap:16px] [br:12px] %}
6
+ * <!-- cell -->
7
7
  * left body
8
- * <!-- cell right -->
8
+ * <!-- cell -->
9
9
  * right body
10
10
  * {% endgrid %}
11
11
  */
@@ -13,37 +13,37 @@
13
13
  'use strict'
14
14
 
15
15
  module.exports = ctx => function(args, content) {
16
- args = ctx.args.map(args, ['bg'])
16
+ args = ctx.args.map(args, ['bg', 'w', 'c', 'gap', 'br'])
17
+ if (args.w == null && args.c == null) {
18
+ args.w = '240px'
19
+ }
17
20
  var el = ''
18
21
  el += '<div class="tag-plugin grid"'
19
- el += ' ' + ctx.args.joinTags(args, ['bg']).join(' ')
22
+ el += ' ' + ctx.args.joinTags(args, ['bg', 'columns']).join(' ')
23
+ el += ' style="'
24
+ if (args.w) {
25
+ el += `grid-template-columns: repeat(auto-fill, minmax(${args.w}, 1fr));`
26
+ } else if (args.c) {
27
+ el += `grid-template-columns: repeat(${args.c}, 1fr);`
28
+ }
29
+ if (args.gap) {
30
+ el += `grid-gap:${args.gap};`
31
+ }
32
+ el += '"'
20
33
  el += '>'
21
-
22
- var arr = content.split(/<!--\s*cell (.*?)\s*-->/g).filter(item => item.trim().length > 0)
23
- if (arr.length > 0) {
24
- var nodes = []
25
- arr.forEach((item, i) => {
26
- if (i % 2 == 0) {
27
- nodes.push({
28
- header: item
29
- })
30
- } else if (nodes.length > 0) {
31
- var node = nodes[nodes.length-1]
32
- if (node.body == undefined) {
33
- node.body = item
34
- } else {
35
- node.body += '\n' + item
36
- }
37
- }
38
- })
39
- nodes.forEach((node, i) => {
40
- el += '<div class="cell" index="' + (i) + '">'
41
- el += ctx.render.renderSync({text: (node.body || ''), engine: 'markdown'}).split('\n').join('')
42
- el += '</div>'
43
- })
34
+ // 分组
35
+ var cells = content.split(/<!--\s*cell(.*?)-->/g).filter(item => item.trim().length > 0)
36
+ for (let cell of cells) {
37
+ el += `<div class="cell" style="`
38
+ if (args.br) {
39
+ el += `border-radius:${args.br};`
40
+ }
41
+ el += `">`
42
+ el += `
43
+ ${ctx.render.renderSync({text: (cell || ''), engine: 'markdown'}).split('\n').join('')}
44
+ </div>
45
+ `
44
46
  }
45
-
46
47
  el += '</div>'
47
-
48
48
  return el
49
49
  }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * md.js v1.0 | https://github.com/volantis-x/hexo-theme-volantis/
3
+ * contributor: @MHuiG
4
+ *
5
+ * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
6
+ *
7
+ * {% md src %}
8
+ *
9
+ */
10
+ 'use strict'
11
+
12
+ var md_index = 0
13
+
14
+ module.exports = ctx => function(args) {
15
+ args = ctx.args.map(args, [''], ['src'])
16
+ const md_id = "md_" + ++md_index
17
+ return `
18
+ <div class="stellar-marked-api md-marked" src="${args.src}" id="${md_id}"></div>
19
+ `
20
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * posters.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
3
+ * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
4
+ *
5
+ * {% posters [group] [repo:owner/repo] [api:http] [size:s/m/l/xl/mix] %}
6
+ */
7
+
8
+ 'use strict'
9
+
10
+ module.exports = ctx => function(args) {
11
+ var args = ctx.args.map(args, ['repo', 'api', 'size'], ['group'])
12
+ if (args.size == null) {
13
+ args.size = 'm'
14
+ }
15
+ var api
16
+ if (args.api) {
17
+ api = args.api
18
+ } else if (args.repo) {
19
+ api = 'https://api.vlts.cc/output_data/v2/' + args.repo
20
+ }
21
+
22
+ var el = ''
23
+ el += `<div class="tag-plugin posters-wrap">`
24
+ if (api) {
25
+ el += `<div class="stellar-friends-api" api="${api}"><div class="tag-plugin gallery grid-box" layout="grid" ratio="square" ${ctx.args.joinTags(args, ['size']).join(' ')}></div></div>`
26
+ } else if (args.group) {
27
+ const links = ctx.theme.config.links || {}
28
+ el += `<div class="tag-plugin gallery grid-box" layout="grid" ratio="portrait" ${ctx.args.joinTags(args, ['size']).join(' ')}>`
29
+ for (let item of (links[args.group] || [])) {
30
+ if (item?.url) {
31
+ el += `<div class="grid-cell poster-card">`
32
+ el += `<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="${item.url}">`
33
+ el += `<img src="${item.icon || item.avatar || ctx.theme.config.default.cover}" onerror="javascript:this.removeAttribute(&quot;data-src&quot;);this.src=&quot;${ctx.theme.config.default.cover}&quot;;"/>`
34
+ el += `<div class="image-meta">`
35
+ if (item.title) {
36
+ el += `<span class="image-caption">${item.title}</span>`
37
+ }
38
+ el += `</div>`
39
+ el += `</a>`
40
+ el += `</div>`
41
+ }
42
+ }
43
+ el += `</div>`
44
+ }
45
+ el += `</div>`
46
+ return el
47
+ }