hexo-theme-fluid 1.9.5 → 1.9.7

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/README.md CHANGED
@@ -135,7 +135,7 @@ layout: about
135
135
 
136
136
  英文文档翻译:[@EatRice](https://eatrice.top/) [@橙子杀手](https://ruru.eatrice.top) [@Sinetian](https://sinetian.github.io/)
137
137
 
138
- 其他贡献:[@zhugaoqi](https://github.com/zhugaoqi) [@julydate](https://github.com/julydate)
138
+ 其他贡献:[@zhugaoqi](https://github.com/zhugaoqi) [@julydate](https://github.com/julydate) [@xiyuvi](https://xiyu.pro/)
139
139
 
140
140
  如你也想贡献代码,可参照[贡献指南](https://hexo.fluid-dev.com/docs/contribute/)
141
141
 
package/_config.yml CHANGED
@@ -1098,3 +1098,5 @@ static_prefix:
1098
1098
  discuss: https://lib.baomitu.com/discuss/1.2.1/
1099
1099
 
1100
1100
  hint: https://lib.baomitu.com/hint.css/2.7.0/
1101
+
1102
+ moment: https://lib.baomitu.com/moment.js/2.29.4/
@@ -42,7 +42,7 @@ post:
42
42
  toc: '目录'
43
43
  prev_post: '上一篇'
44
44
  next_post: '下一篇'
45
- updated: '本文最后更新于:%s'
45
+ updated: '本文最后更新于 %s'
46
46
  meta:
47
47
  wordcount: '%s 字'
48
48
  min2read: '%s 分钟'
@@ -33,7 +33,7 @@
33
33
  <% if (subText.indexOf('.title') !== -1) {
34
34
  subText = subEach.key
35
35
  } %>
36
- <a class="dropdown-item" href="<%= url_for(subEach.link) %>">
36
+ <a class="dropdown-item" href="<%= url_for(subEach.link) %>" target="<%= subEach.target || '_self' %>">
37
37
  <%- subEach.icon ? '<i class="' + subEach.icon + '"></i>' : '' %>
38
38
  <span><%- subText %></span>
39
39
  </a>
@@ -42,7 +42,7 @@
42
42
  </li>
43
43
  <% } else { %>
44
44
  <li class="nav-item">
45
- <a class="nav-link" href="<%= url_for(each.link) %>">
45
+ <a class="nav-link" href="<%= url_for(each.link) %>" target="<%= each.target || '_self' %>">
46
46
  <%- each.icon ? '<i class="' + each.icon + '"></i>' : '' %>
47
47
  <span><%- text %></span>
48
48
  </a>
@@ -0,0 +1,30 @@
1
+ <%
2
+ var lang = (config.language || 'zh-cn').toLowerCase();
3
+
4
+ import_script(`
5
+ <script>
6
+ var relativeDate = function() {
7
+ var updatedTime = document.getElementById('updated-time');
8
+ if (updatedTime) {
9
+ var text = updatedTime.textContent;
10
+ var reg = /\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:Z|[+-]\\d{2}:\\d{2})/;
11
+ var matchs = text.match(reg);
12
+ if (matchs) {
13
+ var relativeTime = moment(matchs[0]).fromNow();
14
+ updatedTime.textContent = text.replace(reg, relativeTime);
15
+ }
16
+ updatedTime.style.display = '';
17
+ }
18
+ };
19
+ Fluid.utils.createScript('${url_join(theme.static_prefix.moment, 'moment.min.js')}', function() {
20
+ if (!'${lang}'.startsWith('en')) {
21
+ Fluid.utils.createScript('${url_join(theme.static_prefix.moment, 'locale/' + lang + '.min.js')}', function() {
22
+ relativeDate();
23
+ });
24
+ } else {
25
+ relativeDate();
26
+ }
27
+ });
28
+ </script>
29
+ `)
30
+ %>
package/layout/index.ejs CHANGED
@@ -27,7 +27,7 @@ page.banner_mask_alpha = theme.index.banner_mask_alpha
27
27
  </a>
28
28
  </h2>
29
29
 
30
- <% var excerpt = post.description || post.excerpt || (theme.index.auto_excerpt.enable && post.content) %>
30
+ <% var excerpt = post.description || post.excerpt || (theme.index.auto_excerpt.enable && !post.encrypt && post.content) %>
31
31
  <a class="index-excerpt <%= index_img ? '' : 'index-excerpt__noimg' %>" href="<%= post_url %>" target="<%- theme.index.post_url_target %>">
32
32
  <div>
33
33
  <%- strip_html(excerpt).substring(0, 200).trim().replace(/\n/g, ' ') %>
package/layout/post.ejs CHANGED
@@ -16,14 +16,15 @@ page.banner_mask_alpha = page.banner_mask_alpha || theme.post.banner_mask_alpha
16
16
  <article class="post-content mx-auto">
17
17
  <h1 id="seo-header"><%= page.subtitle || page.title %></h1>
18
18
  <% if (theme.post.updated.enable && theme.post.updated && compare_date(page.date, page.updated)) { %>
19
- <p class="note note-<%= theme.post.updated.note_class || 'info' %>">
19
+ <p id="updated-time" class="note note-<%= theme.post.updated.note_class || 'info' %>" style="<%= theme.post.updated.relative ? 'display: none' : '' %>">
20
20
  <% if (theme.post.updated.relative) { %>
21
21
  <% if (theme.post.updated.content) { %>
22
22
  <!-- compatible with older versions-->
23
- <%- theme.post.updated.content %><%- relative_date(page.updated, theme.post.updated.date_format) %>
23
+ <%- theme.post.updated.content %><%- date(page.updated, 'YYYY-MM-DDTHH:mm:ssZ') %>
24
24
  <% } else { %>
25
- <%- __('post.updated', relative_date(page.updated, theme.post.updated.date_format)) %>
25
+ <%- __('post.updated', date(page.updated, 'YYYY-MM-DDTHH:mm:ssZ')) %>
26
26
  <% } %>
27
+ <%- partial('_partials/plugins/moment.ejs') %>
27
28
  <% } else { %>
28
29
  <% if (theme.post.updated.content) { %>
29
30
  <!-- compatible with older versions-->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-fluid",
3
- "version": "1.9.5",
3
+ "version": "1.9.7",
4
4
  "description": "An elegant Material-Design theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "files": [
@@ -94,7 +94,7 @@ module.exports = (hexo) => {
94
94
  html += '<li><span id="fn:' + item.index + '" class="footnote-text">';
95
95
  html += '<span>';
96
96
  const fn = hexo.render.renderSync({ text: item.content, engine: 'markdown' });
97
- html += fn.replace(/(<p>)|(<\/p>)/g, '');
97
+ html += fn.replace(/(<p>)|(<\/p>)/g, '').replace(/<br>/g, '');
98
98
  html += '<a href="#fnref:' + item.index + '" rev="footnote" class="footnote-backref"> ↩</a></span></span></li>';
99
99
  });
100
100
 
@@ -16,7 +16,7 @@ module.exports = (hexo) => {
16
16
  | _| |_ | | | \\_/ |, | || \\__/ | |
17
17
  | |_____| [___]'.__.'_/[___]'.__.;__] |
18
18
  | |
19
- | 感谢使用 Fluid 主题 ! |
19
+ | 感谢使用 Fluid 主题 |
20
20
  | 文档: https://hexo.fluid-dev.com/docs/ |
21
21
  | |
22
22
  ------------------------------------------------
@@ -32,7 +32,7 @@ module.exports = (hexo) => {
32
32
  | _| |_ | | | \\_/ |, | || \\__/ | |
33
33
  | |_____| [___]'.__.'_/[___]'.__.;__] |
34
34
  | |
35
- | Thank you for using Fluid theme ! |
35
+ | Thank you for using Fluid theme |
36
36
  | Docs: https://hexo.fluid-dev.com/docs/en/ |
37
37
  | |
38
38
  ------------------------------------------------
@@ -85,6 +85,7 @@ module.exports = (hexo) => {
85
85
  auto_detect: true,
86
86
  line_number: config.code.highlight.line_number || false
87
87
  });
88
+ hexo.config.syntax_highlighter = 'highlight.js'; // hexo v7.0.0+ config
88
89
  hexo.theme.config.code.highlight.highlightjs = objUtil.merge({}, hexo.theme.config.code.highlight.highlightjs, {
89
90
  light: resolveHighlight(hexo.theme.config.code.highlight.highlightjs.style),
90
91
  dark : hexo.theme.config.dark_mode.enable && resolveHighlight(hexo.theme.config.code.highlight.highlightjs.style_dark)
@@ -124,6 +125,7 @@ module.exports = (hexo) => {
124
125
  preprocess : config.code.highlight.prismjs.preprocess || false,
125
126
  line_number: config.code.highlight.line_number || false
126
127
  });
128
+ hexo.config.syntax_highlighter = 'prismjs'; // hexo v7.0.0+ config
127
129
  hexo.theme.config.code.highlight.prismjs = objUtil.merge({}, hexo.theme.config.code.highlight.prismjs, {
128
130
  light: resolvePrism(hexo.theme.config.code.highlight.prismjs.style),
129
131
  dark : hexo.theme.config.dark_mode.enable && resolvePrism(hexo.theme.config.code.highlight.prismjs.style_dark)
@@ -49,5 +49,7 @@ hexo.extend.generator.register('post', function(locals) {
49
49
  hexo.extend.filter.register('after_post_render', (page) => {
50
50
  // 移除 hexo-renderer-pandoc 生成的 <colgroup>
51
51
  page.content = page.content.replace(/<colgroup>.+?<\/colgroup>/gims, '');
52
+ // 移除 hexo-renderer-pandoc 生成的 <span class="footnote-text">...<br>...</span>
53
+ page.content = page.content.replace(/(class="footnote-text".+?)<br.+?>(.+?rev="footnote")/gims, '$1$2');
52
54
  return page;
53
55
  });
@@ -2,12 +2,12 @@
2
2
 
3
3
  'use strict';
4
4
 
5
- const crypto = require('crypto');
5
+ const md5 = require('../utils/crypto');
6
6
  const { decodeURL } = require('hexo-util');
7
7
  const compareVersions = require('../../scripts/utils/compare-versions');
8
8
 
9
9
  hexo.extend.helper.register('md5', function(string) {
10
- return crypto.createHash('md5').update(string).digest('hex');
10
+ return md5(string);
11
11
  });
12
12
 
13
13
  hexo.extend.helper.register('require_version', function(current, require) {
@@ -5,8 +5,13 @@
5
5
  const { stripHTML } = require('hexo-util');
6
6
 
7
7
  const getWordCount = (post) => {
8
+ // post.origin is the original post content of hexo-blog-encrypt
9
+ const content = stripHTML(post.origin || post.content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '');
10
+
8
11
  if (!post.wordcount) {
9
- post.wordcount = stripHTML(post.content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '').length;
12
+ const zhCount = (content.match(/[\u4E00-\u9FA5]/g) || []).length;
13
+ const enCount = (content.replace(/[\u4E00-\u9FA5]/g, '').match(/[a-zA-Z0-9_\u0392-\u03c9\u0400-\u04FF]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|[\u00E4\u00C4\u00E5\u00C5\u00F6\u00D6]+|\w+/g) || []).length;
14
+ post.wordcount = zhCount + enCount
10
15
  }
11
16
  return post.wordcount;
12
17
  };
@@ -16,14 +16,14 @@ const checkbox = (args) => {
16
16
 
17
17
  const checked = (args[1] || '').length > 0 && args[1].trim() !== 'false';
18
18
  const inline = (args[2] || '').length > 0 && args[2].trim() !== 'false';
19
- const enabled = (args[3] || '').length > 0 && args[3].trim() === 'false';
19
+ const disabled = (args[3] || '').length > 0 && args[3].trim() !== 'false';
20
20
 
21
21
  return `${!inline ? '<div>' : ''}
22
- <input type="checkbox" ${enabled ? '' : 'disabled'} ${checked ? 'checked="checked"' : ''}>${text}
22
+ <input type="checkbox" ${disabled ? 'disabled' : ''} ${checked ? 'checked="checked"' : ''}>${text}
23
23
  ${!inline ? '</div>' : ''}`;
24
24
 
25
25
  };
26
26
 
27
- // {% cb text, checked?, inline? %}
27
+ // {% cb text, checked?, inline?, disabled? %}
28
28
  hexo.extend.tag.register('checkbox', checkbox, { ends: false });
29
29
  hexo.extend.tag.register('cb', checkbox, { ends: false });
@@ -0,0 +1,22 @@
1
+ const md5 = require('../utils/crypto');
2
+
3
+ hexo.extend.tag.register('fold', (args, content) => {
4
+ args = args.join(' ').split('@');
5
+ const classes = args[0] || 'default';
6
+ const text = args[1] || '';
7
+ const id = 'collapse-' + md5(content).slice(0, 8);
8
+
9
+ return `
10
+ <div class="fold">
11
+ <div class="fold-title fold-${classes.trim()} collapsed" data-toggle="collapse" href="#${id}" role="button" aria-expanded="false" aria-controls="${id}">
12
+ <div class="fold-arrow">▶</div>${text}
13
+ </div>
14
+ <div class="fold-collapse collapse" id="${id}">
15
+ <div class="fold-content">
16
+ ${hexo.render.renderSync({ text: content, engine: 'markdown' }).split('\n').join('')}
17
+ </div>
18
+ </div>
19
+ </div>`;
20
+ }, {
21
+ ends: true
22
+ });
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ const crypto = require('crypto');
4
+
5
+ const md5 = (content) => {
6
+ return crypto.createHash('md5').update(content).digest('hex');
7
+ }
8
+
9
+ module.exports = md5;
@@ -19,6 +19,8 @@
19
19
  --button-hover-bg-color $button-hover-bg-color
20
20
  --highlight-bg-color $highlight-bg-color
21
21
  --inlinecode-bg-color $inlinecode-bg-color
22
+ --fold-title-color $text-color
23
+ --fold-border-color $line-color
22
24
 
23
25
  dark-colors()
24
26
  --body-bg-color $body-bg-color-dark
@@ -40,6 +42,8 @@ dark-colors()
40
42
  --button-hover-bg-color $button-hover-bg-color-dark
41
43
  --highlight-bg-color $highlight-bg-color-dark
42
44
  --inlinecode-bg-color $inlinecode-bg-color-dark
45
+ --fold-title-color $text-color-dark
46
+ --fold-border-color $line-color-dark
43
47
 
44
48
  img
45
49
  -webkit-filter brightness(.9)
@@ -59,7 +63,7 @@ dark-colors()
59
63
  transition background-color .2s ease-in-out
60
64
 
61
65
  if (hexo-config("dark_mode.enable"))
62
- @media not print and (prefers-color-scheme: dark)
66
+ @media (prefers-color-scheme: dark)
63
67
  :root
64
68
  --color-mode "dark"
65
69
 
@@ -69,3 +73,7 @@ if (hexo-config("dark_mode.enable"))
69
73
  @media not print
70
74
  [data-user-color-scheme="dark"]
71
75
  dark-colors()
76
+
77
+ @media print
78
+ :root
79
+ --color-mode "light"
@@ -41,7 +41,7 @@
41
41
 
42
42
  .index-excerpt
43
43
  color var(--sec-text-color)
44
- margin 0.5rem 0 0.5rem 0
44
+ margin 0.5rem 0
45
45
  height calc(1.4rem * 3)
46
46
  overflow hidden
47
47
  display flex
@@ -73,3 +73,8 @@
73
73
 
74
74
  .index-pin
75
75
  font-size 1.25rem
76
+
77
+ .index-excerpt
78
+ height auto
79
+ max-height calc(1.4rem * 3)
80
+ margin 0.25rem 0
@@ -20,7 +20,7 @@
20
20
  strong
21
21
  font-weight bold
22
22
 
23
- & > *:first-child
23
+ & > *:nth-child(2)
24
24
  margin-top 0
25
25
 
26
26
  img
@@ -1,3 +1,54 @@
1
+ // fold
2
+ .fold
3
+ margin 1rem 0
4
+ border 0.5px solid var(--fold-border-color)
5
+ position relative
6
+ clear both
7
+ border-radius 0.125rem
8
+
9
+ .fold-title
10
+ color var(--fold-title-color)
11
+ padding 0.5rem 0.75rem
12
+ font-size 0.9rem
13
+ font-weight bold
14
+ border-radius 0.125rem
15
+
16
+ &:not(.collapsed) > .fold-arrow
17
+ transform rotate(90deg)
18
+ transform-origin center center
19
+
20
+ .fold-arrow
21
+ display inline-block
22
+ margin-right 0.35rem
23
+ transition transform .3s ease-out
24
+
25
+ .fold-content
26
+ padding 1rem 1rem
27
+
28
+ & > *:last-child
29
+ margin-bottom 0
30
+
31
+ .fold-default, .fold-secondary
32
+ background-color rgba(#bbbbbb, 0.25)
33
+
34
+ .fold-primary
35
+ background-color rgba(#b7a0e0, 0.25)
36
+
37
+ .fold-info
38
+ background-color rgba(#a0c5e4, 0.25)
39
+
40
+ .fold-success
41
+ background-color rgba(#aedcae, 0.25)
42
+
43
+ .fold-warning
44
+ background-color rgba(#f8d6a6, 0.25)
45
+
46
+ .fold-danger
47
+ background-color rgba(#eca9a7, 0.25)
48
+
49
+ .fold-light
50
+ background-color rgba(#fefefe, 0.25)
51
+
1
52
  // note
2
53
  .note
3
54
  padding 0.75rem
@@ -15,14 +66,14 @@
15
66
  *:last-child
16
67
  margin-bottom 0
17
68
 
69
+ .note-default, .note-secondary
70
+ background-color rgba(#bbbbbb, 0.25)
71
+ border-color #777
72
+
18
73
  .note-primary
19
74
  background-color rgba(#b7a0e0, 0.25)
20
75
  border-color #6f42c1
21
76
 
22
- .note-secondary, note-default
23
- background-color rgba(#bbbbbb, 0.25)
24
- border-color #777
25
-
26
77
  .note-success
27
78
  background-color rgba(#aedcae, 0.25)
28
79
  border-color #5cb85c
@@ -53,23 +104,23 @@
53
104
  color var(--text-color)
54
105
  transition color .2s ease-in-out
55
106
 
56
- .label-default
57
- background rgba(#bbbbbb, 0.25)
107
+ .label-default, .label-secondary
108
+ background-color rgba(#bbbbbb, 0.25)
58
109
 
59
110
  .label-primary
60
- background rgba(#b7a0e0, 0.25)
111
+ background-color rgba(#b7a0e0, 0.25)
61
112
 
62
113
  .label-info
63
- background rgba(#a0c5e4, 0.25)
114
+ background-color rgba(#a0c5e4, 0.25)
64
115
 
65
116
  .label-success
66
- background rgba(#aedcae, 0.25)
117
+ background-color rgba(#aedcae, 0.25)
67
118
 
68
119
  .label-warning
69
- background rgba(#f8d6a6, 0.25)
120
+ background-color rgba(#f8d6a6, 0.25)
70
121
 
71
122
  .label-danger
72
- background rgba(#eca9a7, 0.25)
123
+ background-color rgba(#eca9a7, 0.25)
73
124
 
74
125
  // button
75
126
  .markdown-body .btn
@@ -11,6 +11,7 @@
11
11
  var defaultColorSchemaAttributeName = 'data-default-color-scheme';
12
12
  var colorToggleButtonSelector = '#color-toggle-btn';
13
13
  var colorToggleIconSelector = '#color-toggle-icon';
14
+ var iframeSelector = 'iframe';
14
15
 
15
16
  function setLS(k, v) {
16
17
  try {
@@ -247,6 +248,7 @@
247
248
  theme: giscusTheme,
248
249
  }
249
250
  };
251
+ giscus.style.cssText += 'color-scheme: normal;';
250
252
  giscus.contentWindow.postMessage({ 'giscus': message }, 'https://giscus.app');
251
253
  }
252
254
  }
@@ -276,4 +278,9 @@
276
278
  }
277
279
  }
278
280
  });
281
+
282
+ Fluid.utils.waitElementLoaded(iframeSelector, function() {
283
+ applyCustomColorSchemaSettings();
284
+ });
285
+
279
286
  })(window, document);
@@ -166,19 +166,19 @@ Fluid.events = {
166
166
  }
167
167
  // eslint-disable-next-line no-console
168
168
  console.log(`
169
- ------------------------------------------------
170
- | |
171
- | ________ __ _ __ |
172
- | |_ __ |[ | (_) | ] |
173
- | | |_ \\_| | | __ _ __ .--.| | |
174
- | | _| | |[ | | | [ |/ /'\`\\' | |
175
- | _| |_ | | | \\_/ |, | || \\__/ | |
176
- | |_____| [___]'.__.'_/[___]'.__.;__] |
177
- | |
178
- | Powered by Hexo x Fluid |
179
- | GitHub: https://git.io/JqpVD |
180
- | |
181
- ------------------------------------------------
169
+ -------------------------------------------------
170
+ | |
171
+ | ________ __ _ __ |
172
+ | |_ __ |[ | (_) | ] |
173
+ | | |_ \\_| | | __ _ __ .--.| | |
174
+ | | _| | |[ | | | [ |/ /'\`\\' | |
175
+ | _| |_ | | | \\_/ |, | || \\__/ | |
176
+ | |_____| [___]'.__.'_/[___]'.__.;__] |
177
+ | |
178
+ | Powered by Hexo x Fluid |
179
+ | https://github.com/fluid-dev/hexo-theme-fluid |
180
+ | |
181
+ -------------------------------------------------
182
182
  `);
183
183
  }
184
184
  };
package/layout/.DS_Store DELETED
Binary file
package/scripts/.DS_Store DELETED
Binary file
Binary file
Binary file
package/source/.DS_Store DELETED
Binary file
Binary file