hexo-theme-solitude 2.1.6 → 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 (39) hide show
  1. package/_config.yml +15 -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/rightmenu.pug +6 -5
  6. package/layout/includes/widgets/third-party/hot/artalk.pug +56 -0
  7. package/layout/includes/widgets/third-party/hot/twikoo.pug +57 -0
  8. package/layout/includes/widgets/third-party/pjax.pug +2 -1
  9. package/layout/index.pug +1 -1
  10. package/layout/tag.pug +2 -0
  11. package/package.json +1 -1
  12. package/scripts/event/init.js +0 -1
  13. package/scripts/event/merge_config.js +14 -39
  14. package/scripts/filter/default.js +20 -21
  15. package/scripts/filter/lazyload.js +2 -4
  16. package/scripts/helper/getArchiveLength.js +9 -11
  17. package/scripts/helper/related_post.js +56 -56
  18. package/scripts/tags/tabs.js +28 -46
  19. package/source/css/_comments/twikoo.styl +3 -3
  20. package/source/css/_highlight/highlight/diff.styl +13 -1
  21. package/source/css/_highlight/index.styl +2 -2
  22. package/source/css/_highlight/prismjs/diff.styl +13 -1
  23. package/source/css/_layout/recent-post.styl +2 -2
  24. package/source/img/error_load.avif +0 -0
  25. package/source/js/covercolor/api.js +29 -14
  26. package/source/js/covercolor/ave.js +38 -24
  27. package/source/js/covercolor/local.js +52 -52
  28. package/source/js/main.js +236 -244
  29. package/source/js/music.js +21 -39
  30. package/source/js/right_menu.js +67 -132
  31. package/source/js/third_party/barrage.min.js +93 -1
  32. package/source/js/third_party/envelope.min.js +1 -1
  33. package/source/js/third_party/post_ai.min.js +184 -1
  34. package/source/js/tw_cn.js +19 -18
  35. package/source/js/utils.js +50 -57
  36. package/layout/includes/widgets/home/hot/artalk.pug +0 -45
  37. package/layout/includes/widgets/home/hot/twikoo.pug +0 -46
  38. package/source/img/loading.avif +0 -0
  39. /package/layout/includes/widgets/{home → third-party}/hot/index.pug +0 -0
package/layout/index.pug CHANGED
@@ -13,7 +13,7 @@ block content
13
13
  include ./includes/widgets/home/categoryBar
14
14
  .recent-posts#recent-posts
15
15
  if theme.comment.hot_tip.enable
16
- include ./includes/widgets/home/hot/index.pug
16
+ include ./includes/widgets/third-party/hot/index.pug
17
17
  if theme.carousel && is_home_first_page()
18
18
  include ./includes/widgets/home/carousel.pug
19
19
  for post, index in page.posts.sort("-sticky" || "-date").data
package/layout/tag.pug CHANGED
@@ -14,4 +14,6 @@ block content
14
14
  each post,index in page.posts.find({ parent: { $exists: false } }).data
15
15
  include includes/widgets/home/postList
16
16
  include includes/mixins/pagination
17
+ if theme.comment.hot_tip.enable
18
+ include ./includes/widgets/third-party/hot/index.pug
17
19
  include includes/widgets/aside/aside
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-solitude",
3
- "version": "2.1.6",
3
+ "version": "2.1.7",
4
4
  "description": "A beautiful, powerful, and efficient Hexo theme developed by everfu.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -3,7 +3,6 @@ hexo.extend.filter.register('before_generate', () => {
3
3
  const nodeVer = process.version.replace(/^v/, '');
4
4
  const [majorVer] = nodeVer.split('.');
5
5
  const logger = hexo.log;
6
- const config = hexo.config;
7
6
 
8
7
  if (hexoVer < 7.0) {
9
8
  logger.error('请把 Hexo 升级到 V7.0.0 或更高的版本!');
@@ -33,18 +33,9 @@ hexo.extend.filter.register('before_generate', () => {
33
33
  }
34
34
  },
35
35
  aside: {
36
- home: {
37
- noSticky: 'about',
38
- Sticky: 'allInfo'
39
- },
40
- post: {
41
- noSticky: 'about',
42
- Sticky: 'allInfo'
43
- },
44
- page: {
45
- noSticky: 'about',
46
- Sticky: 'allInfo'
47
- },
36
+ home: { noSticky: 'about', Sticky: 'allInfo' },
37
+ post: { noSticky: 'about', Sticky: 'allInfo' },
38
+ page: { noSticky: 'about', Sticky: 'allInfo' },
48
39
  card: {
49
40
  style: 0,
50
41
  author: {
@@ -73,24 +64,12 @@ hexo.extend.filter.register('before_generate', () => {
73
64
  },
74
65
  newest_comment: {
75
66
  enable: false,
76
- storage: .5,
67
+ storage: 0.5,
77
68
  limit: 5
78
69
  },
79
- toc: {
80
- post: true,
81
- page: false,
82
- vague: true,
83
- },
84
- tags: {
85
- enable: true,
86
- limit: 20,
87
- highlight: false,
88
- list: [],
89
- },
90
- archive: {
91
- enable: true,
92
- type: 'month'
93
- },
70
+ toc: { post: true, page: false, vague: true },
71
+ tags: { enable: true, limit: 20, highlight: false, list: [] },
72
+ archive: { enable: true, type: 'month' },
94
73
  siteinfo: {
95
74
  postcount: true,
96
75
  wordcount: false,
@@ -111,9 +90,7 @@ hexo.extend.filter.register('before_generate', () => {
111
90
  tags: true,
112
91
  categories: true,
113
92
  archives: 0,
114
- default: {
115
- cover: ['/img/default.avif'],
116
- }
93
+ default: { cover: ['/img/default.avif'] },
117
94
  },
118
95
  post: {
119
96
  default: {
@@ -150,10 +127,7 @@ hexo.extend.filter.register('before_generate', () => {
150
127
  api: 'https://api.qjqq.cn/api/Imgcolor?img=',
151
128
  time: 43200000,
152
129
  },
153
- share: {
154
- enable: false,
155
- list: []
156
- },
130
+ share: { enable: false, list: [] },
157
131
  footer: {
158
132
  enable: true,
159
133
  desc: "The article from Solitude",
@@ -341,7 +315,7 @@ hexo.extend.filter.register('before_generate', () => {
341
315
  enable: false,
342
316
  recentComment: {
343
317
  enable: false,
344
- storage: .2,
318
+ storage: 0.2,
345
319
  },
346
320
  card: {
347
321
  tags: true,
@@ -404,7 +378,7 @@ hexo.extend.filter.register('before_generate', () => {
404
378
  enable: false,
405
379
  dark: 'https://bu.dusays.com/2023/09/29/651685ce667d1.jpg',
406
380
  light: 'https://bu.dusays.com/2023/09/29/651685cc18d39.jpg',
407
- opacity: .2,
381
+ opacity: 0.2,
408
382
  },
409
383
  translate: {
410
384
  enable: false,
@@ -427,6 +401,7 @@ hexo.extend.filter.register('before_generate', () => {
427
401
  custom_format: '//open.lightxi.com/cdnjs/ajax/libs/${cdnjs_name}/${version}/${min_cdnjs_file}',
428
402
  option: {}
429
403
  }
430
- }
431
- hexo.theme.config = Object.assign(defaultConfig, hexo.theme.config)
404
+ };
405
+
406
+ hexo.theme.config = { ...defaultConfig, ...hexo.theme.config };
432
407
  }, 1)
@@ -2,32 +2,31 @@
2
2
 
3
3
  hexo.extend.filter.register('after_post_render', function (data) {
4
4
  data.title = data.title || 'Untitled';
5
- const {config} = hexo.theme;
6
- if (data.layout === 'post') {
7
- let {copyright, locate, cover} = hexo.theme.config.post.default
8
- cover = cover !== null ? cover : ['/img/default.avif']
9
- data.locate = data.locate || locate
10
- data.cc = data.cc || copyright
11
- data.cover = data.cover || cover[getRandomInt(0, cover?.length)]
12
- data.excerpt = data.description || data.excerpt
13
- data.toc = !!(config.aside.toc.post && data.toc !== false)
14
- data.ai = data.ai !== false;
15
- data.aside = data.aside || true;
5
+ const { config } = hexo.theme;
6
+ const defaultCover = ['/img/default.avif'];
7
+
8
+ const setCoverAndExcerpt = (layout) => {
9
+ const { copyright, locate, cover } = hexo.theme.config[layout].default;
10
+ data.locate = data.locate || locate;
11
+ data.cc = data.cc || copyright;
12
+ data.cover = data.cover || (cover?.length ? cover[getRandomInt(0, cover.length)] : defaultCover[0]);
13
+ data.excerpt = layout === 'post' ? data.description || data.excerpt : data.title;
14
+ data.toc = !!(config.aside.toc[layout] && data.toc !== false);
15
+ data.aside = layout === 'post' ? (data.aside || true) : (data.aside || false);
16
+ };
17
+
18
+ if (data.layout === 'post' || data.layout === 'page') {
19
+ setCoverAndExcerpt(data.layout);
16
20
  }
17
- if (data.layout === 'page') {
18
- let {cover} = hexo.theme.config.page.default
19
- cover = cover !== null ? cover : ['/img/default.avif']
20
- data.cover = data.cover || cover[getRandomInt(0, cover?.length)]
21
- data.excerpt = data.title
22
- data.toc = !!(config.aside.toc.page && data.toc !== false && data.aside);
23
- data.aside = data.aside || false;
21
+
22
+ if (data.layout === 'post') {
23
+ data.ai = data.ai || true;
24
24
  }
25
+
25
26
  data.comment = !!(config.comment.use && data.comment !== false);
26
27
  return data;
27
28
  });
28
29
 
29
30
  function getRandomInt(min, max) {
30
- min = Math.ceil(min);
31
- max = Math.floor(max);
32
- return Math.floor(Math.random() * (max - min)) + min;
31
+ return Math.floor(Math.random() * (max - min)) + Math.ceil(min);
33
32
  }
@@ -1,7 +1,5 @@
1
1
  'use strict'
2
2
 
3
- const urlFor = require('hexo-util').url_for.bind(hexo)
4
-
5
3
  const lazyload = (content, img) => {
6
4
  return content.replace(/(<img(?!.*?class[\t]*=[\t]*['"].*?nolazyload.*?['"]).*? src=)/gi, `$1 "${img}" data-lazy-src=`)
7
5
  }
@@ -9,12 +7,12 @@ const lazyload = (content, img) => {
9
7
  hexo.extend.filter.register('after_render:html', function (data) {
10
8
  const { enable, placeholder ,field } = hexo.theme.config.lazyload
11
9
  if (!enable || field !== 'site') return;
12
- return lazyload(data, urlFor(placeholder))
10
+ return lazyload(data, placeholder)
13
11
  })
14
12
 
15
13
  hexo.extend.filter.register('after_post_render', data => {
16
14
  const { enable, placeholder, field } = hexo.theme.config.lazyload
17
15
  if (!enable || field !== 'post') return
18
- data.content = lazyload(data.content, urlFor(placeholder))
16
+ data.content = lazyload(data.content, placeholder)
19
17
  return data
20
18
  })
@@ -1,14 +1,12 @@
1
- const moment = require('moment')
1
+ const moment = require('moment');
2
2
 
3
- hexo.extend.helper.register('getArchiveLength', function (type) {
4
- if (type !== 'year' && type !== 'month') {
5
- type = 'year';
6
- }
7
- const posts = this.site.posts.sort('-date').data
8
- let archive = {}
9
- for (const post of posts) {
10
- const postdate = type === 'year' ? moment(post.date).format('YYYY') : moment(post.date).format('YYYY/MM');
3
+ hexo.extend.helper.register('getArchiveLength', function (type = 'year') {
4
+ const validTypes = ['year', 'month'];
5
+ type = validTypes.includes(type) ? type : 'year';
6
+
7
+ return this.site.posts.sort('-date').data.reduce((archive, post) => {
8
+ const postdate = moment(post.date).format(type === 'year' ? 'YYYY' : 'YYYY/MM');
11
9
  archive[postdate] = (archive[postdate] || 0) + 1;
12
- }
13
- return archive;
10
+ return archive;
11
+ }, {});
14
12
  });
@@ -6,80 +6,80 @@
6
6
  'use strict'
7
7
 
8
8
  hexo.extend.helper.register('related_posts', function (currentPost, allPosts) {
9
- const relatedPosts = []
10
- const config = hexo.theme.config
11
- const limitNum = config.related_post.limit || 6
12
- const dateType = config.related_post.date_type || 'created'
13
- const headlineLang = this._p('star')
9
+ const config = hexo.theme.config;
10
+ const limitNum = config.related_post.limit || 6;
11
+ const dateType = config.related_post.date_type || 'created';
12
+ const headlineLang = this._p('star');
14
13
 
15
- currentPost.tags.forEach(function (tag) {
16
- allPosts.forEach(function (post) {
14
+ const relatedPostsMap = new Map();
15
+
16
+ currentPost.tags.forEach(tag => {
17
+ allPosts.forEach(post => {
17
18
  if (isTagRelated(tag.name, post.tags) && currentPost.path !== post.path) {
18
- const relatedPost = {
19
- title: post.title,
20
- path: post.path,
21
- cover: post.cover,
22
- cover_type: post.cover_type,
23
- weight: 1,
24
- updated: post.updated,
25
- created: post.date
26
- }
27
- const index = findItem(relatedPosts, 'path', post.path)
28
- if (index !== -1) {
29
- relatedPosts[index].weight += 1
19
+ if (!relatedPostsMap.has(post.path)) {
20
+ relatedPostsMap.set(post.path, {
21
+ title: post.title,
22
+ path: post.path,
23
+ cover: post.cover || 'var(--default-bg-color)',
24
+ weight: 1,
25
+ updated: post.updated,
26
+ created: post.date
27
+ });
30
28
  } else {
31
- relatedPosts.push(relatedPost)
29
+ relatedPostsMap.get(post.path).weight += 1;
32
30
  }
33
31
  }
34
- })
35
- })
32
+ });
33
+ });
36
34
 
35
+ const relatedPosts = Array.from(relatedPostsMap.values());
37
36
  if (relatedPosts.length === 0) {
38
- return ''
37
+ return '';
39
38
  }
40
39
 
41
- relatedPosts.sort(compare('weight', dateType))
40
+ relatedPosts.sort(compare('weight', dateType));
42
41
 
43
- let result = '<div class="relatedPosts">'
44
- result += `<div class="headline"><i class="solitude fa-solid fa-star"></i><span>${headlineLang}</span><div class="relatedPosts-link"><a onclick="event.preventDefault(); toRandomPost();" href="javascript:void(0);" rel="external nofollow" data-pjax-state="">${this._p('random')}</a></div></div>`
45
- result += '<div class="relatedPosts-list">'
42
+ let result = `
43
+ <div class="relatedPosts">
44
+ <div class="headline">
45
+ <i class="solitude fa-solid fa-star"></i>
46
+ <span>${headlineLang}</span>
47
+ <div class="relatedPosts-link">
48
+ <a onclick="event.preventDefault(); toRandomPost();" href="javascript:void(0);" rel="external nofollow" data-pjax-state="">${this._p('random')}</a>
49
+ </div>
50
+ </div>
51
+ <div class="relatedPosts-list">`;
46
52
 
47
53
  for (let i = 0; i < Math.min(relatedPosts.length, limitNum); i++) {
48
- const cover = relatedPosts[i].cover || 'var(--default-bg-color)'
49
- const title = this.escape_html(relatedPosts[i].title)
50
- result += `<div><a href="${this.url_for(relatedPosts[i].path)}" title="${title}">`
51
- result += `<img class="cover" src="${this.url_for(cover)}" alt="cover">`
52
- result += `<div class="content is-center"><div class="title">${title}</div></div>`
53
- result += '</a></div>'
54
+ const { cover, title, path } = relatedPosts[i];
55
+ result += `
56
+ <div>
57
+ <a href="${this.url_for(path)}" title="${this.escape_html(title)}">
58
+ <img class="cover" src="${this.url_for(cover)}" alt="cover">
59
+ <div class="content is-center">
60
+ <div class="title">${this.escape_html(title)}</div>
61
+ </div>
62
+ </a>
63
+ </div>`;
54
64
  }
55
65
 
56
- result += '</div></div>'
57
- return result
58
- })
59
-
60
- function isTagRelated(tagName, TBDtags) {
61
- return TBDtags.some(function (tag) {
62
- return tagName === tag.name
63
- })
64
- }
66
+ result += `
67
+ </div>
68
+ </div>`;
69
+ return result;
70
+ });
65
71
 
66
- function findItem(arrayToSearch, attr, val) {
67
- return arrayToSearch.findIndex(function (item) {
68
- return item[attr] === val
69
- })
72
+ function isTagRelated(tagName, tags) {
73
+ return tags.some(tag => tagName === tag.name);
70
74
  }
71
75
 
72
76
  function compare(attr, dateType) {
73
- return function (a, b) {
74
- const val1 = a[attr]
75
- const val2 = b[attr]
77
+ return (a, b) => {
78
+ const val1 = a[attr];
79
+ const val2 = b[attr];
76
80
  if (val1 === val2) {
77
- if (dateType === 'created') {
78
- return b.created - a.created
79
- } else if (dateType === 'updated') {
80
- return b.updated - a.updated
81
- }
81
+ return dateType === 'created' ? b.created - a.created : b.updated - a.updated;
82
82
  }
83
- return val2 - val1
84
- }
83
+ return val2 - val1;
84
+ };
85
85
  }
@@ -5,51 +5,33 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- function postTabs ([name, active], content) {
9
- const tabBlock = /<!--\s*tab (.*?)\s*-->\n([\w\W\s\S]*?)<!--\s*endtab\s*-->/g
10
-
11
- const matches = []
12
- let match
13
- let tabId = 0
14
- let tabNav = ''
15
- let tabContent = ''
16
-
17
- active = Number(active) || 0
18
-
19
- while ((match = tabBlock.exec(content)) !== null) {
20
- matches.push(match[1])
21
- matches.push(match[2])
22
- }
23
-
24
- for (let i = 0; i < matches.length; i += 2) {
25
- const tabParameters = matches[i].split('@')
26
- let postContent = matches[i + 1]
27
- let tabCaption = tabParameters[0] || ''
28
- let tabIcon = tabParameters[1] || ''
29
- let tabHref = ''
30
-
31
- postContent = hexo.render.renderSync({ text: postContent, engine: 'markdown' }).trim()
32
- tabHref = (name + ' ' + tabId).toLowerCase().split(' ').join('-');
33
-
34
- ((tabCaption.length === 0) && (tabIcon.length === 0)) && (tabCaption = name + ' ' + tabId)
35
-
36
- const isOnlyicon = tabIcon.length > 0 && tabCaption.length === 0 ? ' style="text-align: center;"' : ''
37
- const icon = tabIcon.trim()
38
- tabIcon.length > 0 && (tabIcon = `<i ${isOnlyicon} class="tab solitude ${icon}"></i>`)
39
-
40
- const toTop = '<button type="button" class="tab-to-top" aria-label="scroll to top"><i class="solitude fas fa-arrow-up"></i></button>'
41
- const isActive = active === tabId ? ' active' : ''
42
- tabNav += `<li class="tab${isActive}"><button type="button" data-href="#${tabHref}">${tabIcon + tabCaption.trim()}</button></li>`
43
- tabContent += `<div class="tab-item-content${isActive}" id="${tabHref}">${postContent + toTop}</div>`
44
- tabId += 1
45
- }
46
-
47
- tabNav = `<ul class="nav-tabs">${tabNav}</ul>`
48
- tabContent = `<div class="tab-contents">${tabContent}</div>`
49
-
50
- return `<div class="tabs" id="${name.toLowerCase().split(' ').join('-')}">${tabNav + tabContent}</div>`
8
+ function postTabs([name, active], content) {
9
+ const tabBlock = /<!--\s*tab (.*?)\s*-->\n([\w\W\s\S]*?)<!--\s*endtab\s*-->/g;
10
+ const matches = [...content.matchAll(tabBlock)];
11
+
12
+ active = Number(active) || 0;
13
+
14
+ const tabItems = matches.map((match, tabId) => {
15
+ const [tabCaption = '', tabIcon = ''] = match[1].split('@');
16
+ const postContent = hexo.render.renderSync({ text: match[2], engine: 'markdown' }).trim();
17
+ const tabHref = `${name.toLowerCase().replace(/\s+/g, '-')}-${tabId}`;
18
+
19
+ const iconHtml = tabIcon ? `<i class="${tabIcon.trim()} tab solitude"></i>` : '';
20
+ const isActive = active === tabId ? ' active' : '';
21
+ const toTopButton = '<button type="button" class="tab-to-top" aria-label="scroll to top"><i class="solitude fas fa-arrow-up"></i></button>';
22
+
23
+ return {
24
+ nav: `<li class="tab${isActive}"><button type="button" data-href="#${tabHref}">${iconHtml}${tabCaption.trim() || `${name} ${tabId}`}</button></li>`,
25
+ content: `<div class="tab-item-content${isActive}" id="${tabHref}">${postContent}${toTopButton}</div>`
26
+ };
27
+ });
28
+
29
+ const tabNav = `<ul class="nav-tabs">${tabItems.map(item => item.nav).join('')}</ul>`;
30
+ const tabContent = `<div class="tab-contents">${tabItems.map(item => item.content).join('')}</div>`;
31
+
32
+ return `<div class="tabs" id="${name.toLowerCase().replace(/\s+/g, '-')}">${tabNav}${tabContent}</div>`;
51
33
  }
52
34
 
53
- hexo.extend.tag.register('tabs', postTabs, { ends: true })
54
- hexo.extend.tag.register('subtabs', postTabs, { ends: true })
55
- hexo.extend.tag.register('subsubtabs', postTabs, { ends: true })
35
+ hexo.extend.tag.register('tabs', postTabs, { ends: true });
36
+ hexo.extend.tag.register('subtabs', postTabs, { ends: true });
37
+ hexo.extend.tag.register('subsubtabs', postTabs, { ends: true });
@@ -350,13 +350,13 @@ img.tk-avatar-img
350
350
  border var(--style-border-always)
351
351
 
352
352
  .el-input-group__append, .el-input-group__prepend
353
- background-color var(--efu-card-bg) !important
353
+ background-color var(--efu-card-bg)
354
354
  color var(--efu-fontcolor) !important
355
355
  border 0 !important
356
356
  font-weight 700
357
357
 
358
358
  .el-input__inner
359
- background var(--efu-secondbg) !important
359
+ background-color: var(--efu-secondbg) !important
360
360
  border 0 !important
361
361
  color var(--efu-fontcolor) !important
362
362
  padding-left 8px
@@ -372,7 +372,7 @@ img.tk-avatar-img
372
372
  border none
373
373
 
374
374
  .el-textarea__inner
375
- background var(--efu-secondbg) !important
375
+ background-color var(--efu-secondbg)
376
376
  color var(--efu-fontcolor) !important
377
377
  border-radius 12px !important
378
378
  min-height 100px !important
@@ -27,6 +27,12 @@ figure.highlight
27
27
 
28
28
  .emphasis
29
29
  color $highlight-emphasis-light
30
+
31
+ .addition
32
+ color $highlight-inserted
33
+
34
+ .deletion
35
+ color $highlight-deleted
30
36
 
31
37
  [data-theme=dark] &
32
38
  .keyword
@@ -48,4 +54,10 @@ figure.highlight
48
54
  color $highlight-title-dark
49
55
 
50
56
  .emphasis
51
- color $highlight-emphasis-dark
57
+ color $highlight-emphasis-dark
58
+
59
+ .addition
60
+ color $highlight-inserted
61
+
62
+ .deletion
63
+ color $highlight-deleted
@@ -80,8 +80,8 @@ figure
80
80
 
81
81
  .caption
82
82
  position absolute
83
- right 2.7rem
84
- font-size 0.85em
83
+ right 3.5rem
84
+ font-size 14px
85
85
  color var(--efu-secondtext)
86
86
 
87
87
  +maxWidth768()
@@ -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
@@ -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)');