hexo-theme-stellar 1.21.0 → 1.22.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.
package/_config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  ######## Stellar info ########
2
2
  stellar:
3
- version: '1.21.0'
3
+ version: '1.22.0'
4
4
  homepage: 'https://xaoxuu.com/wiki/stellar/'
5
5
  repo: 'https://github.com/xaoxuu/hexo-theme-stellar'
6
6
  cdn_css: # Use cdn links instead of /css/main.css
@@ -171,8 +171,8 @@ comments:
171
171
  # Artalk
172
172
  # https://artalk.js.org/
173
173
  artalk:
174
- css: https://unpkg.com/artalk@2.4.3/dist/Artalk.css
175
- js: https://unpkg.com/artalk@2.4.3/dist/Artalk.js
174
+ css: https://unpkg.com/artalk@2.7/dist/Artalk.css
175
+ js: https://unpkg.com/artalk@2.7/dist/Artalk.js
176
176
  server: # 后端服务地址
177
177
  placeholder: ''
178
178
  darkMode: auto
@@ -272,6 +272,12 @@ tag_plugins:
272
272
  unfinished:
273
273
  color: red
274
274
  label: 未完成
275
+ # {% gallery %}
276
+ gallery:
277
+ layout: grid # grid / flow
278
+ size: mix # s / m / l / xl / mix
279
+ ratio: square # origin / square
280
+
275
281
 
276
282
 
277
283
 
@@ -8,7 +8,7 @@
8
8
  if (!path) {
9
9
  path = decodeURI(window.location.pathname);
10
10
  }
11
- var artalk = new Artalk({
11
+ var artalk = Artalk.init({
12
12
  el: '#artalk_container',
13
13
  pageKey: path,
14
14
  pageTitle: '<%= page.title || page.seo_title %>',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-stellar",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
4
  "description": "Elegant and powerful theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -10,7 +10,6 @@
10
10
  'use strict';
11
11
 
12
12
  module.exports = ctx => function(args, content) {
13
- const url_for = require('hexo-util').url_for.bind(ctx)
14
13
  args = ctx.args.map(args, ['bg', 'avatar', 'link'], ['title', 'subtitle'])
15
14
  var el = ''
16
15
  el += `<div class="tag-plugin banner">`
@@ -1,13 +1,16 @@
1
1
  /**
2
- * gallery.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/
2
+ * gallery.js v2.1 | https://github.com/xaoxuu/hexo-theme-stellar/
3
3
  * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
4
4
  *
5
- * {% gallery size:small/medium/large %}
6
- * /xxx.png
7
- * /xxx.png
8
- * /xxx.png
9
- * /xxx.png
5
+ * {% gallery [layout:grid/flow] [size:mix/s/m/l/xl] [ratio:origin/square] %}
6
+ * ![title](/xxx.png)
7
+ * ![title](/xxx.png)
8
+ * ![title](/xxx.png)
9
+ * ![title](/xxx.png)
10
10
  * {% endgallery %}
11
+ *
12
+ * layout:grid 网格布局,支持通过 size/ratio 设置尺寸和长宽比
13
+ * layout:flow 瀑布流布局,竖排,适合图片量大的时候使用(体验不佳请慎用)
11
14
  */
12
15
 
13
16
  'use strict'
@@ -29,23 +32,27 @@ function img(src, alt) {
29
32
  }
30
33
 
31
34
  module.exports = ctx => function(args, content) {
32
- args = ctx.args.map(args, ['size'])
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
+ if (args.size == null) {
40
+ args.size = ctx.theme.config.tag_plugins.gallery.size
41
+ }
42
+ if (args.ratio == null) {
43
+ args.ratio = ctx.theme.config.tag_plugins.gallery.ratio
44
+ }
33
45
  var el = ''
34
- el += '<div class="tag-plugin gallery"'
35
- el += ' ' + ctx.args.joinTags(args, ['size']).join(' ')
36
- el += '>'
37
- const rows = content.split(/<!--\s*row(.*?)\s*-->/g).filter(item => item.trim().length > 0)
38
- for (let row of rows) {
39
- const img_mds = row.split('\n').filter(item => item.trim().length > 0)
40
- for (let md of img_mds) {
41
- const matches = md.match(/\!\[(.*?)\]\((.*?)\)/i)
42
- if (matches?.length > 2) {
43
- let alt = matches[1]
44
- let src = matches[2]
45
- el += `<div class="cell">${img(src, alt)}</div>`
46
- }
46
+ el += `<div class="tag-plugin gallery" ${ctx.args.joinTags(args, ['layout', 'size', 'ratio']).join(' ')}>`
47
+ const img_mds = content.split('\n').filter(item => item.trim().length > 0)
48
+ for (let md of img_mds) {
49
+ const matches = md.match(/\!\[(.*?)\]\((.*?)\)/i)
50
+ if (matches?.length > 2) {
51
+ let alt = matches[1]
52
+ let src = matches[2]
53
+ el += `<div class="cell">${img(src, alt)}</div>`
47
54
  }
48
55
  }
49
- el += '</div>'
56
+ el += `</div>`
50
57
  return el
51
58
  }
@@ -100,7 +100,8 @@
100
100
  .subtitle
101
101
  font-size: $fs-14
102
102
 
103
- .tag-plugin.banner:hover
104
- img.bg
105
- transform: scale(1.01)
106
- trans1(transform, 2s)
103
+ .tag-plugin.banner
104
+ trans1(transform, 2s)
105
+ &:hover
106
+ img.bg
107
+ transform: scale(1.01)
@@ -1,12 +1,6 @@
1
1
  .tag-plugin.gallery
2
- border-radius: 8px
3
- column-count: 4
4
- column-gap: 0
5
- margin-left: -4px
6
- margin-right: -4px
7
2
  .cell
8
3
  display: block
9
- padding: 4px
10
4
  overflow hidden
11
5
  z-index 0
12
6
  position: relative
@@ -18,19 +12,16 @@
18
12
  img
19
13
  object-fit: cover
20
14
  max-height: 100%
21
- overflow: hidden
22
15
  display: block
23
16
  .image-meta
24
17
  position: absolute
25
18
  z-index: 1
26
- margin: 4px
27
19
  top: 0
28
20
  left: 0
29
21
  right: 0
30
22
  bottom: 0
31
23
  pointer-events: none
32
24
  background: transparent
33
- border-radius: 8px
34
25
  trans1(background)
35
26
  display: flex
36
27
  flex-direction: column
@@ -40,7 +31,65 @@
40
31
  font-size: $fs-13
41
32
  color: transparent
42
33
  line-height: 1.2
43
- margin: 4px
34
+ margin: 0.5rem
44
35
  trans1(color)
45
36
  &:empty
46
37
  display: none
38
+
39
+ .tag-plugin.gallery[layout='grid'] .cell
40
+ trans1(transform, 0.5s)
41
+ &:hover
42
+ img
43
+ transform: scale(1.1)
44
+
45
+
46
+ // 网格布局
47
+ .tag-plugin.gallery[layout='grid']
48
+ display: grid
49
+ &[size='s']
50
+ grid-template-columns: repeat(auto-fill, minmax(100px, 1fr))
51
+ grid-gap: 2px
52
+ .cell,img
53
+ border-radius: 2px
54
+ &[size='m']
55
+ grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))
56
+ grid-gap: 4px
57
+ .cell,img
58
+ border-radius: 4px
59
+ &[size='l']
60
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr))
61
+ grid-gap: 8px
62
+ .cell,img
63
+ border-radius: 8px
64
+ &[size='xl'] // 2列
65
+ grid-template-columns: repeat(2, 1fr)
66
+ grid-gap: 16px
67
+ .cell,img
68
+ border-radius: 16px
69
+ &[size='mix'] // 1张大图+2张小图
70
+ grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))
71
+ grid-gap: 4px
72
+ .cell,img
73
+ border-radius: 4px
74
+ .cell
75
+ &:nth-child(3n+1)
76
+ grid-column: auto / span 2
77
+ grid-row: auto / span 2
78
+ &[ratio='square']
79
+ .cell
80
+ aspect-ratio: 1
81
+ .cell
82
+ background: var(--block)
83
+ img
84
+ width: 100%
85
+ height: 100%
86
+ // 瀑布流布局
87
+ .tag-plugin.gallery[layout='flow']
88
+ column-count: 3
89
+ column-gap: 8px
90
+ .cell
91
+ border-radius: 8px
92
+ padding-bottom: 8px
93
+ .image-meta
94
+ border-radius: 8px
95
+ margin-bottom: 8px
@@ -24,7 +24,7 @@
24
24
  padding: 0.5rem
25
25
  font-weight: 500
26
26
  font-size: $fs-13
27
- color: var(--text-p2)
27
+ color: var(--text-p1)
28
28
  .toc-child .toc-item .toc-link
29
29
  padding: 0.25rem 0.5rem 0.25rem 1.3rem
30
30
  font-weight: 400
@@ -69,3 +69,14 @@
69
69
  color: $color-theme !important
70
70
  &:before
71
71
  visibility: visible
72
+
73
+
74
+ // 激活上级目录时显示子目录
75
+ .toc-item a.toc-link+ol
76
+ display: none
77
+ .toc a.toc-link.active+ol
78
+ display: block
79
+ ol:has(> .toc-item a.active)
80
+ display: block
81
+ .doc-tree:hover a.toc-link+ol
82
+ display: block
package/source/js/main.js CHANGED
@@ -244,9 +244,12 @@ if (stellar.plugins.stellar) {
244
244
  const els = document.getElementsByClassName('stellar-' + key + '-api');
245
245
  if (els != undefined && els.length > 0) {
246
246
  stellar.jQuery(() => {
247
- stellar.loadScript(js, { defer: true });
248
247
  if (key == 'timeline' || 'memos') {
249
- stellar.loadScript(stellar.plugins.marked);
248
+ stellar.loadScript(stellar.plugins.marked).then(function () {
249
+ stellar.loadScript(js, { defer: true });
250
+ });
251
+ } else {
252
+ stellar.loadScript(js, { defer: true });
250
253
  }
251
254
  })
252
255
  }