hexo-theme-solitude 2.0.9 → 2.0.11

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 (39) hide show
  1. package/.github/PULL_REQUEST_TEMPLATE.md +1 -8
  2. package/CONTRIBUTING.md +1 -1
  3. package/LICENSE +1 -1
  4. package/README.md +1 -1
  5. package/README_zh-Hans.md +3 -3
  6. package/README_zh-Hant.md +2 -2
  7. package/SECURITY.md +4 -4
  8. package/_config.yml +20 -29
  9. package/layout/includes/console.pug +1 -1
  10. package/layout/includes/inject/body.pug +104 -100
  11. package/layout/includes/nav.pug +2 -2
  12. package/layout/includes/widgets/aside/aside.pug +1 -1
  13. package/layout/includes/widgets/home/postList.pug +1 -20
  14. package/layout/includes/widgets/home/topGroup.pug +5 -5
  15. package/layout/includes/widgets/page/links/banner.pug +1 -2
  16. package/layout/includes/widgets/post/copyright.pug +1 -1
  17. package/layout/includes/widgets/randomlink.pug +1 -2
  18. package/package.json +5 -4
  19. package/plugins.yml +16 -5
  20. package/scripts/event/merge_config.js +415 -423
  21. package/scripts/helper/inject_head_js.js +13 -7
  22. package/scripts/tags/article.js +39 -0
  23. package/scripts/tags/chart.js +27 -0
  24. package/scripts/tags/gallery.js +1 -1
  25. package/scripts/tags/typeit.js +29 -0
  26. package/source/css/_global/function.styl +1 -1
  27. package/source/css/_layout/article-container.styl +2 -2
  28. package/source/css/_layout/console.styl +7 -4
  29. package/source/css/_layout/recent-post.styl +53 -75
  30. package/source/css/_page/_home/home-top.styl +8 -13
  31. package/source/css/_page/recentcomment.styl +1 -3
  32. package/source/css/_post/meta.styl +2 -2
  33. package/source/css/_tags/gallery.styl +2 -1
  34. package/source/css/var.styl +7 -7
  35. package/source/js/covercolor/local.js +10 -82
  36. package/source/js/main.js +1 -1
  37. package/source/js/utils.js +1 -7
  38. package/.editorconfig +0 -9
  39. package/.github/workflows/stale.yml +0 -19
@@ -12,93 +12,21 @@ function setDefaultThemeColors() {
12
12
  }
13
13
 
14
14
  const localColor = path => {
15
+ var colorThief = new ColorThief();
15
16
  const img = new Image();
16
17
  img.crossOrigin = "Anonymous";
17
- img.onload = () => setThemeColors(calculateColor(img));
18
+ img.onload = () => setThemeColors(rgbToHex(colorThief.getColor(img)));
18
19
  img.onerror = () => console.error('Image Error');
19
20
  img.src = path;
20
21
  }
21
22
 
22
- const calculateColor = img => {
23
- const canvas = document.createElement("canvas");
24
- const ctx = canvas.getContext("2d");
25
- ctx.drawImage(img, 0, 0);
26
- const data = ctx.getImageData(0, 0, img.width, img.height).data;
27
- const {r, g, b} = calculateRGB(data);
28
- let value = rgbToHex(r, g, b);
29
- return getContrastYIQ(value) === "light" ? LightenDarkenColor(value, -50) : LightenDarkenColor(value, 20);
30
- }
31
-
32
- function calculateRGB(data) {
33
- let r = 0, g = 0, b = 0;
34
- const step = 5;
35
- for (let i = 0; i < data.length; i += 4 * step) {
36
- r += data[i];
37
- g += data[i + 1];
38
- b += data[i + 2];
39
- }
40
- r = Math.floor(r / (data.length / 4 / step));
41
- g = Math.floor(g / (data.length / 4 / step));
42
- b = Math.floor(b / (data.length / 4 / step));
43
- return {r, g, b};
44
- }
45
-
46
- function rgbToHex(r, g, b) {
47
- return "#" + [r, g, b].map(x => x.toString(16).padStart(2, '0')).join('');
48
- }
49
-
50
- function LightenDarkenColor(col, amt) {
51
- let usePound = false;
52
-
53
- if (col[0] === "#") {
54
- col = col.slice(1);
55
- usePound = true;
56
- }
57
-
58
- const num = parseInt(col, 16);
59
- const r = Math.min(255, Math.max(0, (num >> 16) + amt * 2));
60
- const b = Math.min(255, Math.max(0, ((num >> 8) & 0xff) + amt * 2));
61
- const g = Math.min(255, Math.max(0, (num & 0xff) + amt * 2));
62
-
63
- return `${usePound ? "#" : ""}${(g | (b << 8) | (r << 16)).toString(16).padStart(6, "0")}`;
64
- }
65
-
66
- function getContrastYIQ(hexcolor) {
67
- let colorrgb = colorRgb(hexcolor);
68
- let colors = colorrgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
69
- let red = colors[1];
70
- let green = colors[2];
71
- let blue = colors[3];
72
- let brightness = (red * 299) + (green * 587) + (blue * 114);
73
- brightness = brightness / 255000;
74
- return brightness >= 0.5 ? "light" : "dark";
75
- }
76
-
77
- function colorRgb(str) {
78
- const HEX_SHORT_REGEX = /^#([0-9a-fA-f]{3})$/;
79
- const HEX_LONG_REGEX = /^#([0-9a-fA-f]{6})$/;
80
- const HEX_SHORT_LENGTH = 4;
81
-
82
- if (!str || typeof str !== 'string') {
83
- return str;
84
- }
85
-
86
- const sColor = str.toLowerCase();
87
- let hexValue = "";
88
-
89
- if (sColor && (HEX_SHORT_REGEX.test(sColor) || HEX_LONG_REGEX.test(sColor))) {
90
- hexValue = sColor.length === HEX_SHORT_LENGTH ?
91
- sColor.replace(/^#(.)/g, "#$1$1") :
92
- sColor;
93
-
94
- const rgbValue = hexValue.slice(1)
95
- .match(/.{2}/g)
96
- .map(val => parseInt(val, 16));
97
-
98
- return `rgb(${rgbValue[0]}, ${rgbValue[1]}, ${rgbValue[2]})`;
99
- } else {
100
- return sColor;
101
- }
23
+ const rgbToHex = ([r, g, b]) => {
24
+ const hex = '#' + [r, g, b].map(x => {
25
+ const component = Math.floor(x * 0.8);
26
+ const hexValue = component.toString(16);
27
+ return hexValue.length === 1 ? '0' + hexValue : hexValue;
28
+ }).join('');
29
+ return hex;
102
30
  }
103
31
 
104
32
  function setThemeColors(value, r = null, g = null, b = null) {
@@ -139,4 +67,4 @@ function setThemeColors(value, r = null, g = null, b = null) {
139
67
  document.documentElement.style.setProperty('--efu-main-none', 'var(--efu-theme-none)');
140
68
  initThemeColor();
141
69
  }
142
- }
70
+ }
package/source/js/main.js CHANGED
@@ -666,7 +666,7 @@ window.refreshFn = () => {
666
666
  runtime && sco.addRuntime();
667
667
  [scrollFn, sidebarFn, sco.addPhotoFigcaption, sco.setTimeState, sco.tagPageActive, sco.categoriesBarActive, sco.listenToPageInputPress, sco.addNavBackgroundInit, sco.refreshWaterFall].forEach(fn => fn());
668
668
  lazyload.enable && utils.lazyloadImg();
669
- lightbox && utils.lightbox(document.querySelectorAll("#article-container img:not(.flink-avatar,.gallery-group img)"));
669
+ lightbox && utils.lightbox(document.querySelectorAll("#article-container img:not(.flink-avatar,.gallery-group img, .no-lightbox)"));
670
670
  randomlink && randomLinksList();
671
671
  post_ai && is_post && efu_ai.init();
672
672
  sco.switchComments();
@@ -101,12 +101,6 @@
101
101
  },
102
102
  isMobile: () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
103
103
  isHidden: e => 0 === e.offsetHeight && 0 === e.offsetWidth,
104
- addEventListenerPjax: (ele, event, fn, option = false) => {
105
- ele.addEventListener(event, fn, option)
106
- utils.addGlobalFn('pjax', () => {
107
- ele.removeEventListener(event, fn, option)
108
- })
109
- },
110
104
  animateIn: (ele, text) => {
111
105
  Object.assign(ele.style, {display: 'block', animation: text});
112
106
  },
@@ -205,4 +199,4 @@
205
199
  },
206
200
  }
207
201
  window.utils = {...window.utils, ...utilsFn};
208
- })()
202
+ })()
package/.editorconfig DELETED
@@ -1,9 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- charset = utf-8
5
- end_of_line = lf
6
- insert_final_newline = true
7
- trim_trailing_whitespace = true
8
- indent_style = space
9
- indent_size = 2
@@ -1,19 +0,0 @@
1
- name: 'Close stale issues and PRs'
2
- on:
3
- schedule:
4
- - cron: '30 1 * * *'
5
-
6
- jobs:
7
- stale:
8
- runs-on: ubuntu-latest
9
- steps:
10
- - uses: actions/stale@v5
11
- with:
12
- days-before-issue-stale: 30
13
- days-before-pr-stale: -1
14
- days-before-close: 7
15
- stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
16
- close-pr-message: 'This issue has not seen any activity since it was marked stale. Closing.'
17
- stale-issue-label: 'Stale'
18
- exempt-issue-labels: 'pinned,bug,enhancement,documentation,Plan'
19
- operations-per-run: 1000