hexo-theme-stellar 1.23.0 → 1.24.1

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.23.0'
3
+ version: '1.24.1'
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
@@ -59,6 +59,8 @@ breadcrumb:
59
59
  article:
60
60
  # 如果没有指定封面,是否根据 tags 作为关键词搜索封面图片?
61
61
  auto_cover: false # search from https://source.unsplash.com/
62
+ # 封面图宽高比
63
+ cover_ratio: 2.4
62
64
  # 如果没有指定横幅,是否根据 tags 作为关键词搜索横幅图片?
63
65
  auto_banner: false # search from https://source.unsplash.com/
64
66
  # 如果没有指定 excerpt 和 description,将自动取多长的内容作为文章摘要?
@@ -213,7 +215,7 @@ footer:
213
215
  # - '[关于本站](/)'
214
216
  # - '[GitHub](/)'
215
217
  content: | # 支持 Markdown 格式
216
- 本站由 [${author}](/) 使用 [${theme.name} ${theme.version}](${theme.tree}) 主题创建。
218
+ 本站由 [${author.name}](/) 使用 [${theme.name} ${theme.version}](${theme.tree}) 主题创建。
217
219
  本博客所有文章除特别声明外,均采用 [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) 许可协议,转载请注明出处。
218
220
  # 主题用户越多,开发者维护和更新的积极性就越高,如果您喜欢本主题,请在适当的位置显示主题信息和仓库链接以表支持。
219
221
 
@@ -303,6 +305,7 @@ plugins:
303
305
  fcircle: /js/plugins/fcircle.js
304
306
  weibo: /js/plugins/weibo.js
305
307
  memos: /js/plugins/memos.js
308
+ marked: /js/plugins/marked.js
306
309
 
307
310
  marked: https://cdn.bootcdn.net/ajax/libs/marked/4.0.18/marked.min.js
308
311
 
@@ -40,25 +40,36 @@ function layoutDiv() {
40
40
  var license = ''
41
41
  if (page.layout == 'post') {
42
42
  if (theme.article.license && (page.license != false)) {
43
- license = markdown(page.license || theme.article.license)
43
+ license = page.license || theme.article.license
44
44
  }
45
45
  } else if (page.layout == 'wiki' && page.wiki) {
46
46
  let proj = theme.wiki.tree[page.wiki]
47
47
  if (page.license != null) {
48
- license = markdown(page.license || theme.article.license)
48
+ license = page.license || theme.article.license
49
49
  } else if (proj?.license != null) {
50
50
  if (proj.license == true) {
51
- license = markdown(theme.article.license)
51
+ license = theme.article.license
52
52
  } else {
53
- license = markdown(proj.license)
53
+ license = proj.license
54
54
  }
55
55
  }
56
56
  }
57
57
  if (license.length > 0) {
58
+ var author = null
59
+ if (theme.authors) {
60
+ if (page.author?.length > 0 && theme.authors[page.author] != null) {
61
+ author = theme.authors[page.author]
62
+ } else {
63
+ author = theme.default_author
64
+ }
65
+ }
66
+ if (author) {
67
+ license = license.replace('${author.name}', author.name).replace('${author.url}', author.url)
68
+ }
58
69
  el += `
59
70
  <section id="license">
60
71
  <div class="header"><span>${__('meta.license')}</span></div>
61
- <div class="body">${license}</div>
72
+ <div class="body">${markdown(license)}</div>
62
73
  </section>
63
74
  `
64
75
  }
@@ -1,41 +1,35 @@
1
1
  <%
2
- const content = theme.footer.content?.replace('${author}', config.author)?.replace('${theme.name}', stellar_info('name'))?.replace('${theme.version}', stellar_info('version'))?.replace('${theme.tree}', stellar_info('tree'))
2
+ const content = theme.footer.content?.replace('${author.name}', (config.author || 'Anonymity'))?.replace('${theme.name}', stellar_info('name'))?.replace('${theme.version}', stellar_info('version'))?.replace('${theme.tree}', stellar_info('tree'))
3
3
  function layoutDiv() {
4
- var el = '';
5
- el += '<footer class="page-footer reveal fs12">';
6
- el += '<hr>';
4
+ var el = ''
5
+ el += '<footer class="page-footer reveal fs12">'
6
+ el += '<hr>'
7
7
  // sitemap
8
8
  if (theme.footer.sitemap && Object.keys(theme.footer.sitemap).length > 0) {
9
- el += '<div class="sitemap">';
9
+ el += '<div class="sitemap">'
10
10
  for (let group of Object.keys(theme.footer.sitemap)) {
11
- let items = theme.footer.sitemap[group];
11
+ let items = theme.footer.sitemap[group]
12
12
  if (items == undefined || items.length == 0) {
13
- continue;
13
+ continue
14
14
  }
15
- el += '<div class="sitemap-group">';
16
- el += '<span class="fs14">' + group + '</span>';
15
+ el += '<div class="sitemap-group">'
16
+ el += '<span class="fs14">' + group + '</span>'
17
17
  items.forEach((item, i) => {
18
- el += '<a href="' + url_for(md_link(item)) + '">';
19
- el += __(md_text(item));
20
- el += '</a>';
18
+ el += '<a href="' + url_for(md_link(item)) + '">'
19
+ el += __(md_text(item))
20
+ el += '</a>'
21
21
  });
22
- el += '</div>';
22
+ el += '</div>'
23
23
  }
24
- el += '</div>';
24
+ el += '</div>'
25
25
  }
26
26
  // footer
27
- el += '<div class="text">';
27
+ el += '<div class="text">'
28
28
  if (content) {
29
- if ((typeof content == 'string') && content.constructor == String) {
30
- el += markdown(content);
31
- } else if ((typeof content == 'object') && content.constructor == Array) {
32
- content.forEach((item, i) => {
33
- el += markdown(item);
34
- });
35
- }
29
+ el += markdown(content)
36
30
  }
37
- el += '</div></footer>';
38
- return el;
31
+ el += '</div></footer>'
32
+ return el
39
33
  }
40
34
  %>
41
35
  <%- layoutDiv() %>
@@ -1,6 +1,6 @@
1
1
  <%
2
2
  function layoutDiv() {
3
- if (!item.content?.length) return ''
3
+ if (!item.content?.length && !item.src?.length) return ''
4
4
  var el = '';
5
5
  el += '<widget class="widget-wrapper markdown">';
6
6
  if (item.title?.length > 0) {
@@ -9,7 +9,12 @@ function layoutDiv() {
9
9
  el += '</div>';
10
10
  }
11
11
  el += '<div class="widget-body fs14">';
12
- el += markdown(item.content);
12
+ if (item.content) {
13
+ el += markdown(item.content);
14
+ }
15
+ if (item.src) {
16
+ el += `<div class="stellar-marked-api md-marked" src="${item.src}"></div>`
17
+ }
13
18
  el += '</div>';
14
19
  el += '</widget>';
15
20
  return el;
@@ -2,7 +2,7 @@
2
2
  function layoutDiv() {
3
3
  var el = '<widget class="widget-wrapper search">'
4
4
  el += '<div class="widget-body">'
5
- el += '<div class="search-wrapper" id="search">'
5
+ el += '<div class="search-wrapper" id="search-wrapper">'
6
6
  el += '<form class="search-form">'
7
7
  var filter = ''
8
8
  if (item.filter == 'auto') {
@@ -27,7 +27,7 @@ function layoutDiv() {
27
27
  } else {
28
28
  el += ' placeholder="' + (item.placeholder || __('search.search')) + '">'
29
29
  }
30
- el += '<svg t="1670596976048" class="icon search-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2676" width="200" height="200"><path d="M938.2 832.6L723.8 618.1c-2.5-2.5-5.3-4.4-7.9-6.4 36.2-55.6 57.3-121.8 57.3-193.1C773.3 222.8 614.6 64 418.7 64S64 222.8 64 418.6c0 195.9 158.8 354.6 354.6 354.6 71.3 0 137.5-21.2 193.2-57.4 2 2.7 3.9 5.4 6.3 7.8L832.5 938c14.6 14.6 33.7 21.9 52.8 21.9 19.1 0 38.2-7.3 52.8-21.8 29.2-29.1 29.2-76.4 0.1-105.5M418.7 661.3C284.9 661.3 176 552.4 176 418.6 176 284.9 284.9 176 418.7 176c133.8 0 242.6 108.9 242.6 242.7 0 133.7-108.9 242.6-242.6 242.6" p-id="2677"></path></svg>'
30
+ el += '<svg t="1705074644177" class="icon search-icon" viewBox="0 0 1025 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1560" width="200" height="200"><path d="M1008.839137 935.96571L792.364903 719.491476a56.783488 56.783488 0 0 0-80.152866 0 358.53545 358.53545 0 1 1 100.857314-335.166073 362.840335 362.840335 0 0 1-3.689902 170.145468 51.248635 51.248635 0 1 0 99.217358 26.444296 462.057693 462.057693 0 1 0-158.255785 242.303546l185.930047 185.725053a51.248635 51.248635 0 0 0 72.568068 0 51.248635 51.248635 0 0 0 0-72.978056z" fill="#111111" p-id="1561"></path><path d="M616.479587 615.969233a50.428657 50.428657 0 0 0-61.498362-5.534852 174.655348 174.655348 0 0 1-177.525271 3.484907 49.403684 49.403684 0 0 0-58.833433 6.76482l-3.074918 2.869923a49.403684 49.403684 0 0 0 8.609771 78.10292 277.767601 277.767601 0 0 0 286.992355-5.739847 49.403684 49.403684 0 0 0 8.404776-76.667958z" fill="#00C569" p-id="1562"></path></svg>'
31
31
  el += '</form>'
32
32
  el += '<div id="search-result"></div>'
33
33
  el += '<div class="search-no-result">' + __('search.no_results') + '</div>'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-stellar",
3
- "version": "1.23.0",
3
+ "version": "1.24.1",
4
4
  "description": "Elegant and powerful theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -22,6 +22,7 @@ hexo.extend.tag.register('sites', require('./lib/sites')(hexo))
22
22
  hexo.extend.tag.register('ghcard', require('./lib/ghcard')(hexo))
23
23
  hexo.extend.tag.register('toc', require('./lib/toc')(hexo))
24
24
  hexo.extend.tag.register('timeline', require('./lib/timeline')(hexo), {ends: true})
25
+ hexo.extend.tag.register('md', require('./lib/md')(hexo))
25
26
 
26
27
  // express
27
28
  hexo.extend.tag.register('checkbox', require('./lib/checkbox')(hexo, 'checkbox'))
@@ -38,4 +39,6 @@ hexo.extend.tag.register('poetry', require('./lib/poetry')(hexo), true)
38
39
  hexo.extend.tag.register('quot', require('./lib/quot')(hexo))
39
40
  hexo.extend.tag.register('hashtag', require('./lib/hashtag')(hexo))
40
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))
41
44
  // others
@@ -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 audio">
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
+ }
@@ -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,31 @@
1
+ /**
2
+ * video.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/
3
+ * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
4
+ *
5
+ * {% video src %}
6
+ *
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ module.exports = ctx => function(args) {
12
+ args = ctx.args.map(args, ['type', 'bilibili', 'ratio'], ['src'])
13
+ if (args.bilibili) {
14
+ return `
15
+ <div class="tag-plugin video" style="aspect-ratio:${args.ratio || 16/9}">
16
+ <iframe src="https://player.bilibili.com/player.html?bvid=${args.bilibili}" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true">
17
+ </iframe>
18
+ </div>
19
+ `
20
+ }
21
+ if (args.type == null) {
22
+ args.type = 'video/mp4'
23
+ }
24
+ return `
25
+ <div class="tag-plugin video">
26
+ <video controls preload>
27
+ <source src="${args.src}" type="${args.type}">Your browser does not support the video tag.
28
+ </video>
29
+ </div>
30
+ `
31
+ }
@@ -0,0 +1,4 @@
1
+ audio,video
2
+ max-width: 100%
3
+ video
4
+ z-index: 1
@@ -84,22 +84,16 @@
84
84
  object-fit: cover
85
85
  width: 100%
86
86
  border-radius: 0
87
- height: 280px
88
- @media screen and (max-width: 900px)
89
- height: 240px
90
- @media screen and (max-width: $device-tablet)
91
- height: 220px
92
- @media screen and (max-width: $device-mobile-425)
93
- height: 200px
94
- @media screen and (max-width: $device-mobile-375)
95
- height: 180px
96
-
87
+ aspect-ratio: hexo-config('article.cover_ratio')
88
+
97
89
  .post-list .post-card.post.photo
98
90
  .cover
99
91
  position: relative
100
92
  line-height: 0
101
93
  img
102
94
  width: 100%
95
+ object-fit: cover
96
+ aspect-ratio: hexo-config('article.cover_ratio')
103
97
  .cover-info
104
98
  padding: 1.5rem 1rem
105
99
  position: absolute
@@ -161,3 +161,6 @@ h1.article-title
161
161
  bottom: 0
162
162
  left: -2px
163
163
  right: -2px
164
+ &:has(img)
165
+ &:before
166
+ content: none
@@ -8,7 +8,7 @@
8
8
  margin-bottom: .5em
9
9
  position: relative
10
10
  padding: 4px 0
11
- color: var(--text-p3)
11
+ color: var(--text-p1)
12
12
  &:after
13
13
  content: ""
14
14
  position: absolute
@@ -18,7 +18,7 @@
18
18
  right: 0
19
19
  z-index: -1
20
20
  border-radius: 4px
21
- background: var(--block-border)
21
+ background: $color-theme
22
22
  a.post
23
23
  display: inline-flex
24
24
  align-items: baseline
@@ -34,13 +34,9 @@
34
34
  color: var(--text-p4)
35
35
  &:hover
36
36
  border-bottom: 1px solid $color-theme
37
+ color: var(--text-p0)
37
38
  time
38
39
  color: $color-theme
39
- &:hover
40
- .archive-header
41
- color: var(--text-p1)
42
- &:after
43
- background: $color-theme
44
40
 
45
41
 
46
42
 
@@ -21,6 +21,7 @@
21
21
  font-size: 1.5rem
22
22
  margin: 1rem 0
23
23
  line-height: 1.2
24
+ color: var(--text-p0)
24
25
  .description
25
26
  margin: 1rem 0
26
27
  .start-wrap
@@ -6,9 +6,9 @@
6
6
  flex-direction: column
7
7
  justify-content: flex-end
8
8
  align-items: flex-start
9
- height: 240px
9
+ height: 220px
10
10
  @media screen and (max-width: $device-mobile-max)
11
- height: 200px
11
+ height: 180px
12
12
  .bg
13
13
  z-index: 0
14
14
  .content
@@ -60,8 +60,14 @@ details.folding[child=codeblock]>div.body
60
60
  margin: 0
61
61
  figcaption
62
62
  display: none
63
+ span
64
+ background: var(--theme-block)
63
65
  .code:before
64
66
  content: none
67
+ .highlight+.highlight
68
+ border-top: 1px dashed var(--theme-border)
69
+ border-top-left-radius: 0
70
+ border-top-right-radius: 0
65
71
 
66
72
  details.folding[child=iframe]
67
73
  overflow: hidden
@@ -19,7 +19,10 @@
19
19
  padding: 1rem 0.5rem
20
20
  .name
21
21
  max-width: 100%
22
- txt-ellipsis()
22
+ display: -webkit-box
23
+ -webkit-box-orient: vertical
24
+ overflow: hidden
25
+ -webkit-line-clamp: 2
23
26
  img
24
27
  object-fit: cover
25
28
  display: block
@@ -1,11 +1,7 @@
1
1
  .tag-plugin.grid
2
2
  display: grid
3
3
  grid-gap: 16px
4
- grid-template-columns: repeat(auto-fill, "calc((100% - 1 * %s) / 2)" % 16px)
5
- >.cell
6
- p:first-child>strong:only-child
7
- font-size: 1rem
8
- >.cell>
4
+ &[bg]>.cell>
9
5
  p
10
6
  line-height: 1.5
11
7
  :first-child
@@ -21,7 +17,7 @@
21
17
  &[bg]>.cell
22
18
  padding: 1rem
23
19
  border-radius: $border-card
24
- &[bg='block']>.cell
20
+ &[bg='box']>.cell
25
21
  background: var(--block)
26
22
  &[bg='card']>.cell
27
23
  background: var(--card)
@@ -9,7 +9,7 @@
9
9
  justify-content: space-between
10
10
  align-items: center
11
11
  cursor: pointer
12
- width: 320px
12
+ width: 340px
13
13
  max-width: 100%
14
14
  box-shadow: $boxshadow-card
15
15
  border-radius: $border-bar
@@ -0,0 +1,11 @@
1
+ .tag-plugin.video
2
+ line-height: 0
3
+ text-align: center
4
+ video, iframe
5
+ border-radius: $border-card
6
+ box-shadow: $boxshadow-card-float
7
+ z-index 1
8
+ background: var(--block)
9
+ width: 100%
10
+ height: 100%
11
+ margin: 0
@@ -40,6 +40,13 @@
40
40
  margin: 0
41
41
  border: none
42
42
  background: none
43
+ figcaption
44
+ span
45
+ background: var(--theme-block)
46
+ .highlight+.highlight
47
+ border-top: 1px dashed var(--theme-border)
48
+ border-top-left-radius: 0
49
+ border-top-right-radius: 0
43
50
 
44
51
  .md-text .tag-plugin.note[child=tabs]
45
52
  >.body
@@ -1,5 +1,4 @@
1
1
  .widgets .widget-wrapper.search
2
- margin-top: 1rem
3
2
  margin-bottom: 0
4
3
 
5
4
  .search-wrapper
@@ -12,36 +11,21 @@
12
11
  align-items: center
13
12
  transition: 0.38s ease-out
14
13
  z-index: 0
15
- &:after
16
- content: ''
17
- position absolute
18
- left: 0
19
- right: 0
20
- bottom: 0
21
- height: 2px
22
- border-radius: 4px
23
- background: convert(hexo-config('style.gradient.search'))
24
- background-size: 200%
25
- animation: glow 10s linear infinite
26
- @keyframes glow {
27
- from {
28
- background-position: 0%
29
- }
30
- to {
31
- background-position: 200%
32
- }
33
- }
34
14
  .search-input
35
15
  width: 100%
36
16
  padding: 0.5rem 0
37
- line-height: 1
17
+ line-height: 1.5
38
18
  box-sizing: border-box
39
19
  font-family: $ff-body
20
+ font-size: $fs-13
40
21
  color: var(--text-p0)
22
+
41
23
 
42
- &.noresult
24
+ &.noresult[searching='true']
43
25
  .search-icon
44
26
  color: $c-red
27
+ .search-form
28
+ border: 1px solid $c-red
45
29
 
46
30
  .search-no-result
47
31
  display: none
@@ -88,22 +72,27 @@
88
72
 
89
73
 
90
74
 
91
- .search-wrapper.noresult
75
+ .search-wrapper.noresult[searching='true']
92
76
  .search-no-result
93
77
  display: block
94
78
 
95
79
  .widget-wrapper
96
80
  .search-form
97
81
  top: 0
98
- background: var(--site-bg)
82
+ background: var(--card)
83
+ border: 1px solid var(--block-border)
84
+ border-radius: $border-bar
99
85
  .search-input
100
- padding-left: 1.5rem
86
+ text-indent: 0.75rem
87
+ padding-right: 2rem
101
88
  .search-icon
102
- position: absolute
103
- margin-left: 0.25rem
104
- left: 0
89
+ margin: 2px
90
+ position absolute
91
+ right: 0
105
92
  pointer-events: none
106
93
  color: var(--text-p2)
94
+ padding: 0.5rem
95
+ border-radius: 'calc(%s - 2px)' % $border-bar
107
96
 
108
97
  #search-result,.search-no-result
109
98
  margin-top: 1rem
@@ -5,35 +5,36 @@
5
5
  position: absolute
6
6
  top: 0
7
7
  right: 0
8
- padding: 4px 0.5rem
9
- opacity: 0
8
+ padding: 0px 0.5rem
10
9
  font-weight: 700
11
- color: var(--text-p2)
10
+ visibility: hidden
12
11
  border-bottom-left-radius: $border-bar
13
12
  border-bottom-right-radius: $border-bar
14
- background: var(--block-hover)
13
+ background: var(--card)
15
14
  display: block
16
15
  cursor: pointer
17
- margin-right: 0.5rem
16
+ margin-right: 4px
17
+ margin-top: 4px
18
+ border-radius: 'calc(%s - 4px)' % $border-block
18
19
 
19
20
  .highlight:hover
20
21
  .code:before
21
- opacity: 0
22
+ visibility: hidden
22
23
  .copy-btn
23
- opacity: 0.75
24
-
25
- .highlight .code .copy-btn:hover
26
- opacity: 1
24
+ visibility: visible
27
25
 
28
26
  .highlight .code .copy-btn.success
29
- color: $c-green
30
- opacity: 0.75
27
+ background: $c-green
28
+ color: white
29
+ visibility: visible
31
30
 
32
31
  .highlight .code .copy-btn.warning
33
- color: $c-orange
34
- opacity: 0.75
32
+ background: $c-orange
33
+ color: white
34
+ visibility: visible
35
35
 
36
36
  .md-text .folding[child=codeblock]
37
- .highlight .code .copy-btn
38
- margin-top: 1rem
37
+ .code .copy-btn
38
+ z-index 1
39
+ margin-right: 1rem
39
40
  border-radius: $border-bar
package/source/js/main.js CHANGED
@@ -242,7 +242,7 @@ if (stellar.plugins.stellar) {
242
242
  const els = document.getElementsByClassName('stellar-' + key + '-api');
243
243
  if (els != undefined && els.length > 0) {
244
244
  stellar.jQuery(() => {
245
- if (key == 'timeline' || 'memos') {
245
+ if (key == 'timeline' || 'memos' || 'marked') {
246
246
  stellar.loadScript(stellar.plugins.marked).then(function () {
247
247
  stellar.loadScript(js, { defer: true });
248
248
  });
@@ -362,7 +362,7 @@ if (stellar.search.service) {
362
362
  }
363
363
  path = stellar.config.root + path;
364
364
  const filter = $inputArea.attr('data-filter') || '';
365
- searchFunc(path, filter, 'search-input', 'search-result');
365
+ searchFunc(path, filter, 'search-wrapper', 'search-input', 'search-result');
366
366
  });
367
367
  $inputArea.keydown(function(e) {
368
368
  if (e.which == 13) {
@@ -13,7 +13,7 @@ codeElementArr.forEach(code => {
13
13
 
14
14
  codeCopyBtn.innerText = stellar.plugins.copycode.success_text
15
15
  codeCopyBtn.classList.add('success')
16
- hud.toast(stellar.plugins.copycode.toast)
16
+ hud.toast(stellar.plugins.copycode.toast, 2500)
17
17
  setTimeout(() => {
18
18
  codeCopyBtn.innerText = stellar.plugins.copycode.default_text
19
19
  codeCopyBtn.classList.remove('success')
@@ -0,0 +1,50 @@
1
+ const loadMarkdown = (cfg) => {
2
+ if (!window.fetch) {
3
+ cfg.el.innerHTML =
4
+ '<div style="font-size: 24px"><p>Your browser outdated. Please use the latest version of Chrome or Firefox!</p><p>您的浏览器版本过低,请使用最新版的 Chrome 或 Firefox 浏览器!</p></div>';
5
+ } else {
6
+ cfg.el.innerHTML =
7
+ '<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>';
8
+ fetch(cfg.src, { method: "GET" })
9
+ .then((resp) => {
10
+ return Promise.all([
11
+ resp.ok,
12
+ resp.status,
13
+ resp.text(),
14
+ resp.headers,
15
+ ]);
16
+ })
17
+ .then(([ok, status, data, headers]) => {
18
+ if (ok) {
19
+ return {
20
+ ok,
21
+ status,
22
+ data,
23
+ headers,
24
+ };
25
+ } else {
26
+ throw new Error(JSON.stringify(json.error));
27
+ }
28
+ })
29
+ .then((resp) => {
30
+ let data = marked.parse(resp.data);
31
+ cfg.el.innerHTML = data;
32
+ })
33
+ .catch((error) => {
34
+ console.error(error);
35
+ cfg.el.innerHTML =
36
+ '<div class="loading-wrap error"><svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" d="M12 3L21 20H3L12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.5s" values="60;0"/></path><path stroke-dasharray="6" stroke-dashoffset="6" d="M12 10V14"><animate fill="freeze" attributeName="stroke-dashoffset" begin="0.6s" dur="0.2s" values="6;0"/></path></g><circle cx="12" cy="17" r="1" fill="currentColor" fill-opacity="0"><animate fill="freeze" attributeName="fill-opacity" begin="0.8s" dur="0.4s" values="0;1"/></circle></svg></div>';
37
+ });
38
+ };
39
+ };
40
+
41
+ $(function () {
42
+ const els = document.getElementsByClassName('stellar-marked-api');
43
+ for (var i = 0; i < els.length; i++) {
44
+ var cfg = new Object();
45
+ const el = els[i];
46
+ cfg.src = `${el.getAttribute('src')}?t=${new Date().getTime()}`;
47
+ cfg.el = el;
48
+ loadMarkdown(cfg);
49
+ }
50
+ });
@@ -22,7 +22,7 @@
22
22
  // Pieter Robberechts <http://github.com/probberechts>
23
23
 
24
24
  /*exported searchFunc*/
25
- var searchFunc = function(path, filter, searchId, contentId) {
25
+ var searchFunc = function(path, filter, wrapperId, searchId, contentId) {
26
26
 
27
27
  function getAllCombinations(keywords) {
28
28
  var i, j, result = [];
@@ -43,6 +43,7 @@ var searchFunc = function(path, filter, searchId, contentId) {
43
43
  var $input = document.getElementById(searchId);
44
44
  if (!$input) { return; }
45
45
  var $resultContent = document.getElementById(contentId);
46
+ var $wrapper = document.getElementById(wrapperId);
46
47
 
47
48
  $input.addEventListener("input", function(){
48
49
  var resultList = [];
@@ -50,8 +51,10 @@ var searchFunc = function(path, filter, searchId, contentId) {
50
51
  .sort(function(a,b) { return b.split(" ").length - a.split(" ").length; });
51
52
  $resultContent.innerHTML = "";
52
53
  if (this.value.trim().length <= 0) {
54
+ $wrapper.setAttribute('searching', 'false');
53
55
  return;
54
56
  }
57
+ $wrapper.setAttribute('searching', 'true');
55
58
  // perform local searching
56
59
  datas.forEach(function(data) {
57
60
  if (!data.content?.trim().length) { return }