hexo-theme-solitude 2.1.5 → 2.1.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.
Files changed (47) hide show
  1. package/_config.yml +18 -19
  2. package/languages/default.yml +173 -173
  3. package/layout/archive.pug +3 -1
  4. package/layout/category.pug +3 -1
  5. package/layout/includes/head/page_config.pug +3 -1
  6. package/layout/includes/loading.pug +1 -1
  7. package/layout/includes/rightmenu.pug +6 -5
  8. package/layout/includes/widgets/aside/aside.pug +1 -1
  9. package/layout/includes/widgets/page/links/banner.pug +15 -12
  10. package/layout/includes/widgets/rightside/show.pug +1 -1
  11. package/layout/includes/widgets/third-party/hot/artalk.pug +56 -0
  12. package/layout/includes/widgets/third-party/hot/twikoo.pug +57 -0
  13. package/layout/includes/widgets/third-party/pjax.pug +2 -1
  14. package/layout/index.pug +1 -1
  15. package/layout/tag.pug +2 -0
  16. package/package.json +1 -1
  17. package/scripts/event/cdn.js +1 -1
  18. package/scripts/event/init.js +0 -1
  19. package/scripts/event/merge_config.js +14 -39
  20. package/scripts/filter/default.js +20 -21
  21. package/scripts/filter/lazyload.js +2 -4
  22. package/scripts/helper/getArchiveLength.js +9 -11
  23. package/scripts/helper/related_post.js +56 -56
  24. package/scripts/tags/article.js +1 -1
  25. package/scripts/tags/tabs.js +28 -46
  26. package/source/css/_comments/twikoo.styl +3 -3
  27. package/source/css/_highlight/highlight/diff.styl +13 -1
  28. package/source/css/_highlight/index.styl +9 -0
  29. package/source/css/_highlight/prismjs/diff.styl +13 -1
  30. package/source/css/_layout/article-container.styl +1 -1
  31. package/source/css/_layout/recent-post.styl +2 -2
  32. package/source/img/error_load.avif +0 -0
  33. package/source/js/covercolor/api.js +29 -14
  34. package/source/js/covercolor/ave.js +38 -24
  35. package/source/js/covercolor/local.js +52 -52
  36. package/source/js/main.js +238 -240
  37. package/source/js/music.js +21 -39
  38. package/source/js/right_menu.js +67 -132
  39. package/source/js/third_party/barrage.min.js +93 -1
  40. package/source/js/third_party/envelope.min.js +1 -1
  41. package/source/js/third_party/post_ai.min.js +184 -1
  42. package/source/js/tw_cn.js +19 -18
  43. package/source/js/utils.js +50 -57
  44. package/layout/includes/widgets/home/hot/artalk.pug +0 -45
  45. package/layout/includes/widgets/home/hot/twikoo.pug +0 -46
  46. package/source/img/loading.avif +0 -0
  47. /package/layout/includes/widgets/{home → third-party}/hot/index.pug +0 -0
@@ -78,6 +78,15 @@ figure
78
78
  font-size 1.15em
79
79
  user-select none
80
80
 
81
+ .caption
82
+ position absolute
83
+ right 3.5rem
84
+ font-size 14px
85
+ color var(--efu-secondtext)
86
+
87
+ +maxWidth768()
88
+ display none
89
+
81
90
  .code-expand-btn
82
91
  background var(--efu-hltools-bg)
83
92
  transition .3s
@@ -39,6 +39,12 @@ pre[class*='language-']
39
39
  .inserted
40
40
  color $highlight-inserted
41
41
 
42
+ .addition
43
+ color $highlight-inserted
44
+
45
+ .deletion
46
+ color $highlight-deleted
47
+
42
48
  [data-theme='dark'] &
43
49
  .keyword
44
50
  .function
@@ -77,4 +83,10 @@ pre[class*='language-']
77
83
  color $highlight-deleted
78
84
 
79
85
  .inserted
80
- color $highlight-inserted
86
+ color $highlight-inserted
87
+
88
+ .addition
89
+ color $highlight-inserted
90
+
91
+ .deletion
92
+ color $highlight-deleted
@@ -1,4 +1,4 @@
1
- #article-container
1
+ .post-content
2
2
  overflow-wrap break-word
3
3
  +maxWidth768()
4
4
  overflow hidden
@@ -23,7 +23,7 @@ if hexo-config('index_post_list.direction') == "column"
23
23
 
24
24
  +maxWidth1300()
25
25
  margin-bottom .5rem
26
- #tag &
26
+ #tag &:first-child
27
27
  margin-top: 2.5rem
28
28
 
29
29
  +maxWidth768()
@@ -255,7 +255,7 @@ else if hexo-config('index_post_list.direction') == "row"
255
255
  flex-direction row
256
256
  width 100%
257
257
  box-shadow var(--efu-shadow-border)
258
- #tag &
258
+ #tag &:first-child
259
259
  margin-top: 2.5rem
260
260
 
261
261
  +maxWidth768()
Binary file
@@ -1,35 +1,47 @@
1
1
  const coverColor = () => {
2
- const page_color = PAGE_CONFIG.color
3
- if (page_color){
4
- setThemeColors(page_color);
2
+ const pageColor = PAGE_CONFIG.color;
3
+ if (pageColor) {
4
+ setThemeColors(pageColor);
5
5
  return;
6
6
  }
7
+
7
8
  const path = document.getElementById("post-cover")?.src;
8
- path ? handleApiColor(path) : setDefaultThemeColors();
9
+ if (path) {
10
+ handleApiColor(path);
11
+ } else {
12
+ setDefaultThemeColors();
13
+ }
9
14
  }
10
15
 
11
16
  function handleApiColor(path) {
12
17
  const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || {};
13
- cacheGroup.postcolor && cacheGroup.postcolor[path] ? setThemeColors(cacheGroup.postcolor[path].value) : img2color(path);
18
+ if (cacheGroup.postcolor?.[path]) {
19
+ setThemeColors(cacheGroup.postcolor[path].value);
20
+ } else {
21
+ img2color(path);
22
+ }
14
23
  }
15
24
 
16
25
  function img2color(src) {
17
- fetch(coverColorConfig.api + encodeURIComponent(src))
18
- .then(response => response.json())
26
+ fetch(`${coverColorConfig.api}${encodeURIComponent(src)}`)
27
+ .then(response => {
28
+ if (!response.ok) throw new Error('Network response was not ok');
29
+ return response.json();
30
+ })
19
31
  .then(data => {
20
32
  setThemeColors(data.RGB);
21
33
  cacheColor(src, data.RGB);
22
34
  })
23
- .catch(console.error);
35
+ .catch(error => console.error('Error fetching color:', error));
24
36
  }
25
37
 
26
38
  function setThemeColors(value) {
27
39
  if (value) {
28
40
  const [r, g, b] = value.match(/\w\w/g).map(x => parseInt(x, 16));
29
41
  document.documentElement.style.setProperty('--efu-main', value);
30
- document.documentElement.style.setProperty('--efu-main-op', value + '23');
31
- document.documentElement.style.setProperty('--efu-main-op-deep', value + 'dd');
32
- document.documentElement.style.setProperty('--efu-main-none', value + '00');
42
+ document.documentElement.style.setProperty('--efu-main-op', `${value}23`);
43
+ document.documentElement.style.setProperty('--efu-main-op-deep', `${value}dd`);
44
+ document.documentElement.style.setProperty('--efu-main-none', `${value}00`);
33
45
  adjustBrightness(r, g, b);
34
46
  document.getElementById("coverdiv").classList.add("loaded");
35
47
  initThemeColor();
@@ -49,13 +61,16 @@ function setDefaultThemeColors() {
49
61
  function cacheColor(src, color) {
50
62
  const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || {};
51
63
  cacheGroup.postcolor = cacheGroup.postcolor || {};
52
- cacheGroup.postcolor[src] = {value: color, expiration: Date.now() + coverColorConfig.time};
64
+ cacheGroup.postcolor[src] = { value: color, expiration: Date.now() + coverColorConfig.time };
53
65
  localStorage.setItem('Solitude', JSON.stringify(cacheGroup));
54
66
  }
55
67
 
56
68
  function adjustBrightness(r, g, b) {
57
- if (Math.round(((r * 299) + (g * 587) + (b * 114)) / 1000) < 125) {
58
- [...document.getElementsByClassName('card-content')].forEach(item => item.style.setProperty('--efu-card-bg', 'var(--efu-white)'));
69
+ const brightness = Math.round(((r * 299) + (g * 587) + (b * 114)) / 1000);
70
+ if (brightness < 125) {
71
+ [...document.getElementsByClassName('card-content')].forEach(item => {
72
+ item.style.setProperty('--efu-card-bg', 'var(--efu-white)');
73
+ });
59
74
  [...document.getElementsByClassName('author-info__sayhi')].forEach(item => {
60
75
  item.style.setProperty('background', 'var(--efu-white-op)');
61
76
  item.style.setProperty('color', 'var(--efu-white)');
@@ -1,38 +1,49 @@
1
1
  const coverColor = () => {
2
- const page_color = PAGE_CONFIG.color
3
- if (page_color){
4
- setThemeColors(page_color);
5
- return;
2
+ const pageColor = PAGE_CONFIG.color;
3
+ if (pageColor) {
4
+ setThemeColors(pageColor);
5
+ } else {
6
+ const path = document.getElementById("post-cover")?.src;
7
+ path ? handleApiColor(path) : setDefaultThemeColors();
6
8
  }
7
- const path = document.getElementById("post-cover")?.src;
8
- path ? handleApiColor(path) : setDefaultThemeColors();
9
9
  }
10
10
 
11
11
  const handleApiColor = (path) => {
12
- const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || {};
13
- const color = cacheGroup.postcolor?.[path]?.value;
14
- color ? setThemeColors(color) : img2color(path);
12
+ const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || { postcolor: {} };
13
+ const color = cacheGroup.postcolor[path]?.value;
14
+ if (color) {
15
+ setThemeColors(color);
16
+ } else {
17
+ img2color(path);
18
+ }
15
19
  }
16
20
 
17
21
  const img2color = (src) => {
18
22
  fetch(`${src}?imageAve`)
19
- .then(response => response.json())
23
+ .then(response => {
24
+ if (!response.ok) throw new Error('Network response was not ok');
25
+ return response.json();
26
+ })
20
27
  .then(({ RGB }) => {
21
- RGB = `#${RGB.slice(2)}`;
22
- setThemeColors(RGB);
23
- cacheColor(src, RGB);
28
+ const formattedRGB = `#${RGB.slice(2)}`;
29
+ setThemeColors(formattedRGB);
30
+ cacheColor(src, formattedRGB);
24
31
  })
25
- .catch(console.error);
32
+ .catch(error => console.error('Error fetching color:', error));
26
33
  }
27
34
 
28
35
  const setThemeColors = (value) => {
29
36
  if (!value) return setDefaultThemeColors();
30
37
  const [r, g, b] = value.match(/\w\w/g).map(x => parseInt(x, 16));
31
- const [main, op, opDeep, none] = [`${value}`, `${value}23`, `${value}dd`, `${value}00`];
32
- document.documentElement.style.setProperty('--efu-main', main);
33
- document.documentElement.style.setProperty('--efu-main-op', op);
34
- document.documentElement.style.setProperty('--efu-main-op-deep', opDeep);
35
- document.documentElement.style.setProperty('--efu-main-none', none);
38
+ const themeColors = {
39
+ main: value,
40
+ op: `${value}23`,
41
+ opDeep: `${value}dd`,
42
+ none: `${value}00`
43
+ };
44
+ Object.entries(themeColors).forEach(([key, color]) => {
45
+ document.documentElement.style.setProperty(`--efu-${key}`, color);
46
+ });
36
47
  adjustBrightness(r, g, b);
37
48
  document.getElementById("coverdiv").classList.add("loaded");
38
49
  initThemeColor();
@@ -40,7 +51,9 @@ const setThemeColors = (value) => {
40
51
 
41
52
  const setDefaultThemeColors = () => {
42
53
  const vars = ['--efu-theme', '--efu-theme-op', '--efu-theme-op-deep', '--efu-theme-none'];
43
- vars.forEach((varName, i) => document.documentElement.style.setProperty(['--efu-main', '--efu-main-op', '--efu-main-op-deep', '--efu-main-none'][i], `var(${varName})`));
54
+ vars.forEach((varName, i) => {
55
+ document.documentElement.style.setProperty(['--efu-main', '--efu-main-op', '--efu-main-op-deep', '--efu-main-none'][i], `var(${varName})`);
56
+ });
44
57
  initThemeColor();
45
58
  }
46
59
 
@@ -51,10 +64,11 @@ const cacheColor = (src, color) => {
51
64
  }
52
65
 
53
66
  const adjustBrightness = (r, g, b) => {
54
- if (Math.round(((r * 299) + (g * 587) + (b * 114)) / 1000) < 125) {
55
- document.querySelectorAll('.card-content').forEach(item =>
56
- item.style.setProperty('--efu-card-bg', 'var(--efu-white)')
57
- );
67
+ const brightness = Math.round(((r * 299) + (g * 587) + (b * 114)) / 1000);
68
+ if (brightness < 125) {
69
+ document.querySelectorAll('.card-content').forEach(item => {
70
+ item.style.setProperty('--efu-card-bg', 'var(--efu-white)');
71
+ });
58
72
  document.querySelectorAll('.author-info__sayhi').forEach(item => {
59
73
  item.style.setProperty('background', 'var(--efu-white-op)');
60
74
  item.style.setProperty('color', 'var(--efu-white)');
@@ -1,23 +1,26 @@
1
1
  const coverColor = () => {
2
- const page_color = PAGE_CONFIG.color
3
- if (page_color){
4
- setThemeColors(page_color);
5
- return;
2
+ const pageColor = PAGE_CONFIG.color || document.getElementById("post-cover")?.src;
3
+ if (pageColor) {
4
+ return localColor(pageColor);
6
5
  }
7
- const path = document.getElementById("post-cover")?.src;
8
- path ? localColor(path) : setDefaultThemeColors();
6
+ setDefaultThemeColors();
9
7
  }
10
8
 
11
- function setDefaultThemeColors() {
12
- document.documentElement.style.setProperty('--efu-main', 'var(--efu-theme)');
13
- document.documentElement.style.setProperty('--efu-main-op', 'var(--efu-theme-op)');
14
- document.documentElement.style.setProperty('--efu-main-op-deep', 'var(--efu-theme-op-deep)');
15
- document.documentElement.style.setProperty('--efu-main-none', 'var(--efu-theme-none)');
9
+ const setDefaultThemeColors = () => {
10
+ const themeVars = {
11
+ '--efu-main': 'var(--efu-theme)',
12
+ '--efu-main-op': 'var(--efu-theme-op)',
13
+ '--efu-main-op-deep': 'var(--efu-theme-op-deep)',
14
+ '--efu-main-none': 'var(--efu-theme-none)'
15
+ };
16
+ Object.entries(themeVars).forEach(([key, value]) => {
17
+ document.documentElement.style.setProperty(key, value);
18
+ });
16
19
  initThemeColor();
17
20
  }
18
21
 
19
22
  const localColor = path => {
20
- var colorThief = new ColorThief();
23
+ const colorThief = new ColorThief();
21
24
  const img = new Image();
22
25
  img.crossOrigin = "Anonymous";
23
26
  img.onload = () => setThemeColors(rgbToHex(colorThief.getColor(img)));
@@ -26,50 +29,47 @@ const localColor = path => {
26
29
  }
27
30
 
28
31
  const rgbToHex = ([r, g, b]) => {
29
- const hex = '#' + [r, g, b].map(x => {
30
- const component = Math.floor(x * 0.8);
31
- const hexValue = component.toString(16);
32
- return hexValue.length === 1 ? '0' + hexValue : hexValue;
33
- }).join('');
34
- return hex;
32
+ return '#' + [r, g, b].map(x => {
33
+ const component = Math.floor(x * 0.8);
34
+ return component.toString(16).padStart(2, '0');
35
+ }).join('');
35
36
  }
36
37
 
37
- function setThemeColors(value, r = null, g = null, b = null) {
38
- if (value) {
39
- document.documentElement.style.setProperty('--efu-main', value);
40
- document.documentElement.style.setProperty('--efu-main-op', value + '23');
41
- document.documentElement.style.setProperty('--efu-main-op-deep', value + 'dd');
42
- document.documentElement.style.setProperty('--efu-main-none', value + '00');
38
+ const setThemeColors = (value, r = null, g = null, b = null) => {
39
+ if (!value) return setDefaultThemeColors();
43
40
 
44
- if (r && g && b) {
45
- let brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
46
- if (brightness < 125) {
47
- let cardContents = document.getElementsByClassName('card-content');
48
- for (let i = 0; i < cardContents.length; i++) {
49
- cardContents[i].style.setProperty('--efu-card-bg', 'var(--efu-white)');
50
- }
41
+ const themeColors = {
42
+ '--efu-main': value,
43
+ '--efu-main-op': value + '23',
44
+ '--efu-main-op-deep': value + 'dd',
45
+ '--efu-main-none': value + '00'
46
+ };
47
+ Object.entries(themeColors).forEach(([key, color]) => {
48
+ document.documentElement.style.setProperty(key, color);
49
+ });
51
50
 
52
- let authorInfo = document.getElementsByClassName('author-info__sayhi');
53
- for (let i = 0; i < authorInfo.length; i++) {
54
- authorInfo[i].style.setProperty('background', 'var(--efu-white-op)');
55
- authorInfo[i].style.setProperty('color', 'var(--efu-white)');
56
- }
57
-
58
- value = LightenDarkenColor(value, 50);
59
- document.documentElement.style.setProperty('--efu-main', value);
60
- document.documentElement.style.setProperty('--efu-main-op', value + '23');
61
- document.documentElement.style.setProperty('--efu-main-op-deep', value + 'dd');
62
- document.documentElement.style.setProperty('--efu-main-none', value + '00');
63
- }
51
+ if (r && g && b) {
52
+ const brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
53
+ if (brightness < 125) {
54
+ adjustCardStyles();
55
+ value = LightenDarkenColor(value, 50);
56
+ setThemeColors(value);
64
57
  }
65
-
66
- document.getElementById("coverdiv").classList.add("loaded");
67
- initThemeColor();
68
- } else {
69
- document.documentElement.style.setProperty('--efu-main', 'var(--efu-theme)');
70
- document.documentElement.style.setProperty('--efu-main-op', 'var(--efu-theme-op)');
71
- document.documentElement.style.setProperty('--efu-main-op-deep', 'var(--efu-theme-op-deep)');
72
- document.documentElement.style.setProperty('--efu-main-none', 'var(--efu-theme-none)');
73
- initThemeColor();
74
58
  }
59
+
60
+ document.getElementById("coverdiv").classList.add("loaded");
61
+ initThemeColor();
62
+ }
63
+
64
+ const adjustCardStyles = () => {
65
+ const cardContents = document.getElementsByClassName('card-content');
66
+ Array.from(cardContents).forEach(item => {
67
+ item.style.setProperty('--efu-card-bg', 'var(--efu-white)');
68
+ });
69
+
70
+ const authorInfo = document.getElementsByClassName('author-info__sayhi');
71
+ Array.from(authorInfo).forEach(item => {
72
+ item.style.setProperty('background', 'var(--efu-white-op)');
73
+ item.style.setProperty('color', 'var(--efu-white)');
74
+ });
75
75
  }