hexo-theme-stellar 1.29.1 → 1.30.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.
Files changed (54) hide show
  1. package/_config.yml +29 -7
  2. package/_data/chat_users.yml +0 -0
  3. package/_data/icons.yml +3 -1
  4. package/_data/widgets.yml +7 -0
  5. package/layout/_partial/head.ejs +2 -1
  6. package/layout/_partial/main/navbar/nav_tabs_blog.ejs +10 -10
  7. package/layout/_partial/main/post_list/post_card.ejs +15 -11
  8. package/layout/_partial/scripts/defines.ejs +3 -0
  9. package/layout/_partial/scripts/services.ejs +91 -0
  10. package/layout/_partial/scripts/theme.ejs +5 -0
  11. package/layout/_partial/scripts/utils.ejs +67 -7
  12. package/layout/_partial/scripts.ejs +1 -1
  13. package/layout/_plugins/mermaid.ejs +1 -1
  14. package/layout/_plugins/scrollreveal.ejs +1 -0
  15. package/layout/_plugins/search/algolia_search.ejs +11 -12
  16. package/layout/layout.ejs +1 -1
  17. package/package.json +1 -1
  18. package/scripts/events/lib/config.js +3 -0
  19. package/scripts/events/lib/doc_tree.js +1 -6
  20. package/scripts/filters/index.js +26 -0
  21. package/scripts/generators/notebooks.js +1 -1
  22. package/scripts/generators/search.js +21 -2
  23. package/scripts/helpers/dynamic_color.js +138 -0
  24. package/scripts/tags/index.js +1 -0
  25. package/scripts/tags/lib/box.js +1 -1
  26. package/scripts/tags/lib/chat.js +515 -0
  27. package/scripts/tags/lib/folders.js +1 -1
  28. package/scripts/tags/lib/folding.js +2 -2
  29. package/scripts/tags/lib/friends.js +4 -4
  30. package/scripts/tags/lib/sites.js +1 -1
  31. package/scripts/tags/lib/video.js +7 -2
  32. package/source/css/_components/list.styl +41 -12
  33. package/source/css/_components/partial/article-banner.styl +23 -9
  34. package/source/css/_components/tag-plugins/chat.styl +621 -0
  35. package/source/css/_components/tag-plugins/friends.styl +9 -0
  36. package/source/css/_components/tag-plugins/friends_posts.styl +160 -0
  37. package/source/css/_components/tag-plugins/sites.styl +25 -0
  38. package/source/css/_components/tag-plugins/tabs.styl +5 -2
  39. package/source/css/_custom.styl +1 -0
  40. package/source/css/_defines/func.styl +7 -6
  41. package/source/css/_defines/theme.styl +38 -0
  42. package/source/css/_plugins/katex.styl +0 -1
  43. package/source/js/plugins/download-file.js +198 -0
  44. package/source/js/plugins/video.js +65 -0
  45. package/source/js/plugins/voice.js +438 -0
  46. package/source/js/search/algolia-search.js +63 -61
  47. package/source/js/services/artalk_latest_comment.js +33 -0
  48. package/source/js/services/friends.js +4 -0
  49. package/source/js/services/friends_and_posts.js +57 -0
  50. package/source/js/services/giscus_latest_comment.js +36 -0
  51. package/source/js/services/memos.js +91 -69
  52. package/source/js/services/sites.js +12 -1
  53. package/source/js/services/twikoo_latest_comment.js +47 -0
  54. package/source/js/services/waline_latest_comment.js +32 -0
@@ -31,11 +31,13 @@ hexo.extend.generator.register('search_json_generator', function (locals) {
31
31
  temp_post.path = root + post.path
32
32
  }
33
33
  if (cfg.content != false && post.content) {
34
- var content = stripHTML(post.content).trim()
34
+ var content = stripHTML(post.content.replace(/<span class="line">\d+<\/span>/g, '')).trim()
35
35
  // 部分HTML标签
36
36
  content = content.replace(/<iframe[\s|\S]+iframe>/g, '')
37
37
  content = content.replace(/<hr>/g, '')
38
38
  content = content.replace(/<br>/g, '')
39
+ // 去除HTML实体
40
+ content = content.replace(/&[^\s;]+;/g, "")
39
41
  // 换行符换成空格
40
42
  content = content.replace(/\\n/g, ' ')
41
43
  content = content.replace(/\n/g, ' ')
@@ -60,8 +62,22 @@ hexo.extend.generator.register('search_json_generator', function (locals) {
60
62
  return temp_post
61
63
  }
62
64
 
65
+ function matchAndExit(path, patterns) {
66
+ for (let pattern of patterns) {
67
+ const regexPattern = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$');
68
+ if (path.match(regexPattern)) {
69
+ // console.log("Matched pattern:", pattern);
70
+ return true;
71
+ }
72
+ }
73
+ return false;
74
+ }
75
+
63
76
  if (posts) {
64
77
  posts.each(function(post) {
78
+ var layout_list = ["post"]
79
+ if (!layout_list.includes(post.layout)) return
80
+ if (cfg.skip_search && matchAndExit(post.path, cfg.skip_search)) return
65
81
  if (post.indexing == false) return
66
82
  let temp_post = generateJson(post)
67
83
  res.push(temp_post)
@@ -69,6 +85,9 @@ hexo.extend.generator.register('search_json_generator', function (locals) {
69
85
  }
70
86
  if (pages) {
71
87
  pages.each(function(page) {
88
+ var layout_list = ["page", "wiki"]
89
+ if (!layout_list.includes(page.layout)) return
90
+ if (cfg.skip_search && matchAndExit(page.path, cfg.skip_search)) return
72
91
  if (page.indexing == false) return
73
92
  let temp_post = generateJson(page)
74
93
  res.push(temp_post)
@@ -78,4 +97,4 @@ hexo.extend.generator.register('search_json_generator', function (locals) {
78
97
  path: cfg.path,
79
98
  data: JSON.stringify(res)
80
99
  }
81
- })
100
+ })
@@ -0,0 +1,138 @@
1
+ 'use strict';
2
+
3
+ // 判断颜色是否合法 rgb rgba hex hsl hsla
4
+ function CheckIsColor(bgVal) {
5
+ var type='';
6
+ var color_mode = '';
7
+ if(/^rgb\(/.test(bgVal)){
8
+ //如果是rgb开头,200-249,250-255,0-199
9
+ type = "^[rR][gG][Bb][\(]([\\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\\s]*,){2}[\\s]*(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)[\\s]*[\)]{1}$";
10
+ color_mode = 'rgb';
11
+ }else if(/^rgba\(/.test(bgVal)){
12
+ //如果是rgba开头,判断0-255:200-249,250-255,0-199 判断0-1:0 1 1.0 0.0-0.9
13
+ type = "^[rR][gG][Bb][Aa][\(]([\\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\\s]*,){3}[\\s]*(1|1.0|0|0.[0-9])[\\s]*[\)]{1}$";
14
+ color_mode = 'rgba';
15
+ }else if(/^#/.test(bgVal)){
16
+ //六位或者三位
17
+ type = "^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$"
18
+ color_mode = 'hex';
19
+ }else if(/^hsl\(/.test(bgVal)){
20
+ //判断0-360 判断0-100%(0可以没有百分号)
21
+ type = "^[hH][Ss][Ll][\(]([\\s]*(2[0-9][0-9]|360|3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*)[\)]$";
22
+ color_mode = 'hsl';
23
+ }else if(/^hsla\(/.test(bgVal)){
24
+ type = "^[hH][Ss][Ll][Aa][\(]([\\s]*(2[0-9][0-9]|360|3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,){2}([\\s]*(1|1.0|0|0.[0-9])[\\s]*)[\)]$";
25
+ color_mode = 'hsla';
26
+ }
27
+ var re = new RegExp(type);
28
+ if (bgVal.match(re) == null){
29
+ return null
30
+ }else{
31
+ return color_mode
32
+ }
33
+ }
34
+
35
+ // 颜色格式转换:hex ==> rgb
36
+ //使用
37
+ // hexToRGB("#27ae60ff"); // 'rgba(39, 174, 96, 255)'
38
+ // hexToRGB("27ae60"); // 'rgb(39, 174, 96)'
39
+ // hexToRGB("#fff"); // 'rgb(255, 255, 255)'
40
+ function hexToRgba(hex) {
41
+ let alpha = false,
42
+ h = hex.slice(hex.startsWith("#") ? 1 : 0);
43
+ if (h.length === 3) h = [...h].map((x) => x + x).join("");
44
+ else if (h.length === 8) alpha = true;
45
+ h = parseInt(h, 16);
46
+ let r = h >>> (alpha ? 24 : 16);
47
+ let g = (h & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8);
48
+ let b = (h & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0);
49
+ let a = alpha ? h & 0x000000ff : 1;
50
+ return {r, g, b, a}
51
+ }
52
+
53
+ function getRgbaValue(rgba_color) {
54
+ if (rgba_color.indexOf('rgb') === 0) {
55
+ if (rgba_color.indexOf('rgba') === -1)
56
+ rgba_color += ',1'; // convert 'rgb(R,G,B)' to 'rgb(R,G,B)A' which looks awful but will pass the regxep below
57
+ let [r,g,b,a] = rgba_color.match(/[\.\d]+/g).map(function (a) {
58
+ return +a
59
+ });
60
+ return {
61
+ r,
62
+ g,
63
+ b,
64
+ a
65
+ }
66
+ } else {
67
+ return {}
68
+ }
69
+ }
70
+
71
+ function getHslaValue(hsla_color) {
72
+ if (hsla_color.indexOf('hsl') === 0) {
73
+ if (hsla_color.indexOf('hsla') === -1)
74
+ hsla_color += ',1'; // convert 'hsl(R,G,B)' to 'hsl(R,G,B)A' which looks awful but will pass the regxep below
75
+ let [h, s, l, a] = hsla_color.match(/[\.\d]+/g).map(function (a) {
76
+ return +a
77
+ });
78
+ return {
79
+ h,
80
+ s,
81
+ l,
82
+ a
83
+ }
84
+ } else {
85
+ return {}
86
+ }
87
+ }
88
+
89
+ // 颜色格式转换:rgb ==> hsl
90
+ function rgbToHsl(r, g, b) {
91
+ r /= 255;
92
+ g /= 255;
93
+ b /= 255;
94
+ let l = Math.max(r, g, b);
95
+ let s = l - Math.min(r, g, b);
96
+ let h = s
97
+ ? l === r
98
+ ? (g - b) / s
99
+ : l === g
100
+ ? 2 + (b - r) / s
101
+ : 4 + (r - g) / s
102
+ : 0;
103
+ h = 60 * h < 0 ? 60 * h + 360 : 60 * h;
104
+ s = 100 * (s ? (l <= 0.5 ? s / (2 * l - s) : s / (2 - (2 * l - s))) : 0);
105
+ l = (100 * (2 * l - s)) / 2;
106
+ return { h, s, l };
107
+ }
108
+
109
+ function dynamic_color(color, index, mark) {
110
+ var colorType = CheckIsColor(color);
111
+ if (colorType) {
112
+ if (colorType == 'hex') {
113
+ var {r,g,b,a} = hexToRgba(color);
114
+ var {h,s,l} = rgbToHsl(r,g,b);
115
+ } else if (colorType == 'rgb' || colorType == 'rgba') {
116
+ var {r,g,b,a} = getRgbaValue(color);
117
+ var {h,s,l} = rgbToHsl(r,g,b);
118
+ } else if (colorType == 'hsl' || colorType == 'hsla') {
119
+ var {h,s,l,a} = getHslaValue(color);
120
+ }
121
+ let light_bg = `hsl(${h}deg, 55%, 75%)`;
122
+ let light_bg_2 = `hsl(${h}deg, 55%, 60%)`;
123
+ let light_text_color = `hsl(${h}deg, 50%, 40%)`;
124
+ let dark_bg = `hsl(${h}deg, 40%, 26%)`;
125
+ let dark_bg_2 = `hsl(${h}deg, 40%, 40%)`;
126
+ let dark_text_color = `hsl(${h}deg, 60%, 60%)`;
127
+ let style_light = `--${mark}-label-bg-${index}: ${light_bg};--${mark}-label-bg-2-${index}: ${light_bg_2};--${mark}-label-text-color-${index}: ${light_text_color};`;
128
+ let style_dark = `--${mark}-label-bg-${index}: ${dark_bg};--${mark}-label-bg-2-${index}: ${dark_bg_2};--${mark}-label-text-color-${index}: ${dark_text_color};`;
129
+ let style_hover = `.${mark}-label-hover-${index}{color: var(--${mark}-label-text-color-${index}) !important;background: var(--${mark}-label-bg-${index}) !important;transition: all .2s ease-out;}.${mark}-label-hover-${index}:hover{background: var(--${mark}-label-bg-2-${index}) !important;}`;
130
+ return {
131
+ style_light: style_light,
132
+ style_dark: style_dark,
133
+ style_hover: style_hover
134
+ }
135
+ }
136
+ }
137
+
138
+ hexo.extend.helper.register("dynamic_color", dynamic_color);
@@ -23,6 +23,7 @@ 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
25
  hexo.extend.tag.register('md', require('./lib/md')(hexo))
26
+ hexo.extend.tag.register('chat', require('./lib/chat')(hexo), {ends: true})
26
27
 
27
28
  // express
28
29
  hexo.extend.tag.register('checkbox', require('./lib/checkbox')(hexo, 'checkbox'))
@@ -22,7 +22,7 @@ module.exports = ctx => function(args, content) {
22
22
  el += '>'
23
23
  // title
24
24
  if (title && title.length > 0) {
25
- el += '<div class="title"><strong>' + title + '</strong></div>'
25
+ el += '<div class="title"><strong>' + ctx.render.renderSync({text: title, engine: 'markdown'}) + '</strong></div>'
26
26
  }
27
27
  // content
28
28
  el += '<div class="body">'