hexo-theme-stellar 1.29.0 → 1.30.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 (48) hide show
  1. package/_config.yml +29 -9
  2. package/_data/chat_users.yml +0 -0
  3. package/_data/widgets.yml +7 -0
  4. package/languages/zh-TW.yml +2 -2
  5. package/layout/_partial/head.ejs +2 -1
  6. package/layout/_partial/main/navbar/nav_tabs_blog.ejs +10 -10
  7. package/layout/_partial/scripts/defines.ejs +3 -0
  8. package/layout/_partial/scripts/services.ejs +91 -0
  9. package/layout/_partial/scripts/theme.ejs +5 -0
  10. package/layout/_partial/scripts/utils.ejs +67 -7
  11. package/layout/_partial/scripts.ejs +1 -1
  12. package/layout/_plugins/mermaid.ejs +1 -1
  13. package/layout/_plugins/scrollreveal.ejs +1 -0
  14. package/layout/_plugins/search/algolia_search.ejs +11 -12
  15. package/layout/layout.ejs +1 -1
  16. package/package.json +1 -1
  17. package/scripts/events/lib/config.js +3 -0
  18. package/scripts/events/lib/doc_tree.js +1 -6
  19. package/scripts/filters/index.js +26 -0
  20. package/scripts/generators/notebooks.js +1 -1
  21. package/scripts/generators/search.js +21 -2
  22. package/scripts/helpers/dynamic_color.js +138 -0
  23. package/scripts/tags/index.js +1 -0
  24. package/scripts/tags/lib/box.js +1 -1
  25. package/scripts/tags/lib/chat.js +515 -0
  26. package/scripts/tags/lib/folders.js +1 -1
  27. package/scripts/tags/lib/folding.js +2 -2
  28. package/scripts/tags/lib/sites.js +1 -1
  29. package/scripts/tags/lib/video.js +7 -2
  30. package/source/css/_components/tag-plugins/chat.styl +621 -0
  31. package/source/css/_components/tag-plugins/friends.styl +10 -0
  32. package/source/css/_components/tag-plugins/sites.styl +12 -0
  33. package/source/css/_components/tag-plugins/tabs.styl +5 -2
  34. package/source/css/_custom.styl +1 -0
  35. package/source/css/_defines/func.styl +7 -6
  36. package/source/css/_defines/theme.styl +38 -0
  37. package/source/css/_plugins/katex.styl +0 -1
  38. package/source/js/plugins/download-file.js +198 -0
  39. package/source/js/plugins/video.js +65 -0
  40. package/source/js/plugins/voice.js +438 -0
  41. package/source/js/search/algolia-search.js +63 -61
  42. package/source/js/services/artalk_latest_comment.js +33 -0
  43. package/source/js/services/friends.js +4 -0
  44. package/source/js/services/giscus_latest_comment.js +36 -0
  45. package/source/js/services/memos.js +91 -69
  46. package/source/js/services/sites.js +4 -0
  47. package/source/js/services/twikoo_latest_comment.js +47 -0
  48. package/source/js/services/waline_latest_comment.js +32 -0
@@ -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">'