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.
- package/_config.yml +15 -19
- package/languages/default.yml +173 -173
- package/layout/archive.pug +3 -1
- package/layout/category.pug +3 -1
- package/layout/includes/rightmenu.pug +6 -5
- package/layout/includes/widgets/third-party/hot/artalk.pug +56 -0
- package/layout/includes/widgets/third-party/hot/twikoo.pug +57 -0
- package/layout/includes/widgets/third-party/pjax.pug +2 -1
- package/layout/index.pug +1 -1
- package/layout/tag.pug +2 -0
- package/package.json +1 -1
- package/scripts/event/init.js +0 -1
- package/scripts/event/merge_config.js +14 -39
- package/scripts/filter/default.js +20 -21
- package/scripts/filter/lazyload.js +2 -4
- package/scripts/helper/getArchiveLength.js +9 -11
- package/scripts/helper/related_post.js +56 -56
- package/scripts/tags/tabs.js +28 -46
- package/source/css/_comments/twikoo.styl +3 -3
- package/source/css/_highlight/highlight/diff.styl +13 -1
- package/source/css/_highlight/index.styl +2 -2
- package/source/css/_highlight/prismjs/diff.styl +13 -1
- package/source/css/_layout/recent-post.styl +2 -2
- package/source/img/error_load.avif +0 -0
- package/source/js/covercolor/api.js +29 -14
- package/source/js/covercolor/ave.js +38 -24
- package/source/js/covercolor/local.js +52 -52
- package/source/js/main.js +236 -244
- package/source/js/music.js +21 -39
- package/source/js/right_menu.js +67 -132
- package/source/js/third_party/barrage.min.js +93 -1
- package/source/js/third_party/envelope.min.js +1 -1
- package/source/js/third_party/post_ai.min.js +184 -1
- package/source/js/tw_cn.js +19 -18
- package/source/js/utils.js +50 -57
- package/layout/includes/widgets/home/hot/artalk.pug +0 -45
- package/layout/includes/widgets/home/hot/twikoo.pug +0 -46
- package/source/img/loading.avif +0 -0
- /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/
|
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
package/scripts/event/init.js
CHANGED
@@ -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
|
-
|
38
|
-
|
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
|
-
|
81
|
-
|
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
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
data.
|
11
|
-
data.
|
12
|
-
data.
|
13
|
-
data.
|
14
|
-
data.
|
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
|
-
|
18
|
-
|
19
|
-
|
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
|
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,
|
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,
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
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
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
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
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
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 =
|
44
|
-
|
45
|
-
|
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]
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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 +=
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
67
|
-
return
|
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
|
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
|
-
|
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
|
}
|
package/scripts/tags/tabs.js
CHANGED
@@ -5,51 +5,33 @@
|
|
5
5
|
|
6
6
|
'use strict'
|
7
7
|
|
8
|
-
function postTabs
|
9
|
-
const tabBlock = /<!--\s*tab (.*?)\s*-->\n([\w\W\s\S]*?)<!--\s*endtab\s*-->/g
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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)
|
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)
|
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
|
@@ -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
|
3
|
-
if (
|
4
|
-
setThemeColors(
|
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
|
-
|
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
|
-
|
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
|
18
|
-
.then(response =>
|
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
|
31
|
-
document.documentElement.style.setProperty('--efu-main-op-deep', value
|
32
|
-
document.documentElement.style.setProperty('--efu-main-none', value
|
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
|
-
|
58
|
-
|
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)');
|