hexo-theme-solitude 2.1.6 → 2.1.8
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/CONTRIBUTING.md +1 -1
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/README_en-US.md +1 -1
- package/README_zh-Hant.md +1 -1
- package/SECURITY.md +1 -1
- package/_config.yml +16 -20
- package/languages/default.yml +173 -173
- package/layout/archive.pug +3 -1
- package/layout/category.pug +3 -1
- package/layout/includes/inject/body.pug +1 -1
- package/layout/includes/page/default.pug +1 -1
- package/layout/includes/page/links.pug +1 -1
- package/layout/includes/page/tlink.pug +1 -1
- package/layout/includes/rightmenu.pug +6 -5
- package/layout/includes/widgets/page/about/hobbies.pug +18 -17
- package/layout/includes/widgets/page/about/tenyear.pug +24 -25
- package/layout/includes/widgets/page/links/linksCard.pug +5 -2
- package/layout/includes/widgets/page/message/content.pug +1 -1
- 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/post.pug +1 -1
- package/layout/tag.pug +2 -0
- package/package.json +1 -1
- package/plugins.yml +10 -10
- package/scripts/event/init.js +0 -1
- package/scripts/event/merge_config.js +14 -39
- package/scripts/event/welcome.js +11 -7
- package/scripts/filter/default.js +20 -21
- package/scripts/filter/lazyload.js +2 -4
- package/scripts/filter/randomPosts.js +14 -3
- package/scripts/helper/getArchiveLength.js +9 -11
- package/scripts/helper/related_post.js +56 -56
- package/scripts/tags/article.js +53 -15
- package/scripts/tags/tabs.js +37 -46
- package/source/css/_comments/comment.styl +4 -3
- package/source/css/_comments/twikoo.styl +6 -7
- package/source/css/_global/animation.styl +0 -15
- package/source/css/_global/index.styl +19 -19
- 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/_highlight/prismjs/index.styl +1 -1
- package/source/css/_highlight/prismjs/line-number.styl +1 -1
- package/source/css/_layout/article-container.styl +1 -1
- package/source/css/_layout/console.styl +1 -0
- package/source/css/_layout/recent-post.styl +2 -2
- package/source/css/_page/_about/about.styl +1 -1
- package/source/css/_page/_about/game.styl +2 -17
- package/source/css/_page/error.styl +2 -3
- package/source/css/_page/links.styl +2 -2
- package/source/css/_page/other.styl +1 -0
- package/source/css/_page/says.styl +4 -3
- package/source/css/_tags/gallery.styl +1 -1
- package/source/css/_tags/tabs.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 +60 -52
- package/source/js/main.js +253 -248
- package/source/js/music.js +21 -39
- package/source/js/right_menu.js +64 -127
- 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 +17 -16
- 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
@@ -1,24 +1,25 @@
|
|
1
|
-
- var
|
2
|
-
- var game2 = site.data.about.game2
|
1
|
+
- var games = site.data.about.game
|
3
2
|
|
4
|
-
if
|
3
|
+
if games
|
5
4
|
.author-content
|
6
|
-
|
7
|
-
|
5
|
+
each game, index in games
|
6
|
+
style.
|
7
|
+
.game-#{index}::after {
|
8
|
+
box-shadow: #{game.box_shadow} !important;
|
9
|
+
}
|
10
|
+
.author-content-item.game(class=`game-${index}`, style=`background: url(${game.img}) no-repeat top; background-size: cover;`)
|
8
11
|
.card-content
|
9
|
-
.author-content-item-tips=
|
10
|
-
span.author-content-item-title=
|
12
|
+
.author-content-item-tips= game.title
|
13
|
+
span.author-content-item-title= game.subtitle
|
11
14
|
.content-bottom
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
.tips= game2.tips_left
|
21
|
-
.tips= game2.tips_right
|
15
|
+
if game.icon_group
|
16
|
+
.icon-group
|
17
|
+
each icon in game.icon_group
|
18
|
+
i(style=`background-image: url(${icon})`)
|
19
|
+
else if game.tips_left
|
20
|
+
.tips= game.tips_left
|
21
|
+
if game.tips_right
|
22
|
+
.tips= game.tips_right
|
22
23
|
|
23
24
|
if site.data.about.likes
|
24
25
|
- const likes = site.data.about.likes
|
@@ -2,47 +2,46 @@
|
|
2
2
|
if tenyear
|
3
3
|
.author-content#tenyear
|
4
4
|
.create-site-post.author-content-item.single
|
5
|
-
.author-content-item-tips=tenyear.tips
|
6
|
-
.author-content-item-title=tenyear.title
|
7
|
-
p=tenyear.text
|
5
|
+
.author-content-item-tips= tenyear.tips
|
6
|
+
.author-content-item-title= tenyear.title
|
7
|
+
p= tenyear.text
|
8
8
|
.tenyear-timeline
|
9
9
|
.progress
|
10
10
|
.past-time
|
11
11
|
.percentage-label
|
12
12
|
.time-labels
|
13
|
-
.start-time#tenyear-start-time= tenyear.start
|
14
|
-
.end-time#tenyear-end-time= tenyear.end
|
13
|
+
.start-time#tenyear-start-time= new Date(tenyear.start).toLocaleDateString()
|
14
|
+
.end-time#tenyear-end-time= new Date(tenyear.end).toLocaleDateString()
|
15
15
|
|
16
16
|
script.
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
const tenYear = () => {
|
18
|
+
const progressElement = document.querySelector(".progress");
|
19
|
+
const pastTimeElement = document.querySelector(".past-time");
|
20
|
+
const percentageLabelElement = document.querySelector(".percentage-label");
|
21
|
+
const startTimeElement = document.getElementById("tenyear-start-time");
|
22
|
+
const endTimeElement = document.getElementById("tenyear-end-time");
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
let pastTimeElement = document.querySelector(".past-time");
|
24
|
-
let percentageLabelElement = document.querySelector(".percentage-label");
|
25
|
-
let startTimeElement = document.getElementById("tenyear-start-time");
|
26
|
-
let endTimeElement = document.getElementById("tenyear-end-time");
|
24
|
+
const startTime = new Date(startTimeElement.textContent).getTime();
|
25
|
+
const endTime = new Date(endTimeElement.textContent).getTime();
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
let currentTime = new Date().getTime();
|
33
|
-
let progress = ((currentTime - startTime) / (endTime - startTime) * 100);
|
34
|
-
let progressPercentage = progress <= 100 ? progress + "%" : "100%";
|
27
|
+
const updateProgress = () => {
|
28
|
+
const currentTime = new Date().getTime();
|
29
|
+
const progress = ((currentTime - startTime) / (endTime - startTime) * 100);
|
30
|
+
const progressPercentage = Math.min(progress, 100) + "%";
|
35
31
|
|
36
32
|
pastTimeElement.style.setProperty("--past-time-percentage", progress + "%");
|
37
33
|
progressElement.style.setProperty("--progress-percentage", progressPercentage);
|
38
|
-
if(progress > 5){
|
34
|
+
if (progress > 5) {
|
39
35
|
percentageLabelElement.textContent = `${progress.toFixed(0)}%`;
|
40
36
|
percentageLabelElement.style.left = `calc(${progress}% - 35px)`;
|
41
37
|
}
|
42
|
-
}
|
38
|
+
};
|
43
39
|
|
44
40
|
percentageLabelElement.style.visibility = "visible";
|
45
41
|
updateProgress();
|
46
|
-
}
|
42
|
+
};
|
47
43
|
|
48
|
-
document.getElementById("tenyear")
|
44
|
+
if (document.getElementById("tenyear")) {
|
45
|
+
tenYear();
|
46
|
+
window.Pjax.on('complete', tenYear);
|
47
|
+
}
|
@@ -2,8 +2,11 @@
|
|
2
2
|
each item in data.link_list
|
3
3
|
.site-card
|
4
4
|
if item.tag
|
5
|
-
|
6
|
-
|
5
|
+
if item.color == 'vip' || item.color == 'speed'
|
6
|
+
span.site-card-tag(class=item.color)= item.tag
|
7
|
+
i.light
|
8
|
+
else
|
9
|
+
span.site-card-tag(style=`background-color: ${item.color};`)= item.tag
|
7
10
|
a.img(title=item.name, href=url_for(item.link))
|
8
11
|
img.flink-avatar(src=item.topimg + (data.topimg_suffix || ''), alt=item.name)
|
9
12
|
a.info.cf-friends-link(title=item.name, href=url_for(item.link))
|
@@ -0,0 +1,56 @@
|
|
1
|
+
- const { server, site } = theme.artalk
|
2
|
+
|
3
|
+
script.
|
4
|
+
function updatePostsBasedOnComments() {
|
5
|
+
const location = window.location;
|
6
|
+
const posts = Array.from(document.querySelectorAll('.recent-post-item[onclick] .post_cover a'))
|
7
|
+
.map(item => item.href.replace(location, ''));
|
8
|
+
|
9
|
+
fetchCommentsData(posts)
|
10
|
+
.then(data => updatePostElements(posts, data))
|
11
|
+
.catch(error => console.error("Error fetching comments:", error));
|
12
|
+
}
|
13
|
+
|
14
|
+
function fetchCommentsData(posts) {
|
15
|
+
const url = `!{server}/api/v2/stats/page_comment?page_keys=${posts.join(',')}&site_name=!{site}`;
|
16
|
+
return fetch(url)
|
17
|
+
.then(res => res.json())
|
18
|
+
.then(data => data.data);
|
19
|
+
}
|
20
|
+
|
21
|
+
function updatePostElements(posts, data) {
|
22
|
+
posts.forEach(post => {
|
23
|
+
const commentCount = data[post];
|
24
|
+
if (commentCount > !{count}) {
|
25
|
+
const postElement = document.querySelector(`.recent-post-item[onclick*="${post}"]`);
|
26
|
+
if (postElement) {
|
27
|
+
addHotTipIfNeeded(postElement);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
});
|
31
|
+
}
|
32
|
+
|
33
|
+
function addHotTipIfNeeded(postElement) {
|
34
|
+
const infoTopTips = postElement.querySelector(".recent-post-info-top-tips");
|
35
|
+
const originalSpan = infoTopTips?.querySelector(".original");
|
36
|
+
const existingHotTip = infoTopTips?.querySelector(".hot-tip");
|
37
|
+
|
38
|
+
if (!existingHotTip && originalSpan) {
|
39
|
+
const hotTip = createHotTipElement();
|
40
|
+
infoTopTips.insertBefore(hotTip, originalSpan);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
function createHotTipElement() {
|
45
|
+
const hotTip = document.createElement("span");
|
46
|
+
hotTip.classList.add("hot-tip");
|
47
|
+
|
48
|
+
const icon = document.createElement("i");
|
49
|
+
icon.classList.add("solitude", "fas", "fa-fire-flame-curved");
|
50
|
+
hotTip.appendChild(icon);
|
51
|
+
|
52
|
+
const commentCount = document.createTextNode("!{_p('hot-tip')}");
|
53
|
+
hotTip.appendChild(commentCount);
|
54
|
+
|
55
|
+
return hotTip;
|
56
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
script.
|
2
|
+
function updatePostsBasedOnComments() {
|
3
|
+
const location = window.location.origin;
|
4
|
+
const posts = Array.from(document.querySelectorAll('.recent-post-item[onclick] .post_cover a'))
|
5
|
+
.map(item => item.href.replace(location, ''));
|
6
|
+
|
7
|
+
const fetchCommentsCount = () => {
|
8
|
+
twikoo.getCommentsCount({
|
9
|
+
envId: "!{theme.twikoo.envId}",
|
10
|
+
urls: posts,
|
11
|
+
includeReply: true
|
12
|
+
}).then(handleCommentsResponse)
|
13
|
+
.catch(error => console.error("Error fetching comments:", error));
|
14
|
+
};
|
15
|
+
|
16
|
+
const handleCommentsResponse = (response) => {
|
17
|
+
response.forEach(comment => {
|
18
|
+
if (comment.count > !{count}) {
|
19
|
+
const postElement = document.querySelector(`.recent-post-item[onclick*="${comment.url}"]`);
|
20
|
+
if (postElement) {
|
21
|
+
updatePostElement(postElement);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
});
|
25
|
+
};
|
26
|
+
|
27
|
+
const updatePostElement = (postElement) => {
|
28
|
+
const infoTopTips = postElement.querySelector(".recent-post-info-top-tips");
|
29
|
+
const originalSpan = infoTopTips?.querySelector(".original");
|
30
|
+
const existingHotTip = infoTopTips?.querySelector(".hot-tip");
|
31
|
+
|
32
|
+
if (!existingHotTip && originalSpan) {
|
33
|
+
const hotTip = createHotTipElement();
|
34
|
+
infoTopTips.insertBefore(hotTip, originalSpan);
|
35
|
+
}
|
36
|
+
};
|
37
|
+
|
38
|
+
const createHotTipElement = () => {
|
39
|
+
const hotTip = document.createElement("span");
|
40
|
+
hotTip.classList.add("hot-tip");
|
41
|
+
|
42
|
+
const icon = document.createElement("i");
|
43
|
+
icon.classList.add("solitude", "fas", "fa-fire-flame-curved");
|
44
|
+
hotTip.appendChild(icon);
|
45
|
+
|
46
|
+
const commentCount = document.createTextNode("!{_p('hot-tip')}");
|
47
|
+
hotTip.appendChild(commentCount);
|
48
|
+
|
49
|
+
return hotTip;
|
50
|
+
};
|
51
|
+
|
52
|
+
if (typeof twikoo === 'object') {
|
53
|
+
fetchCommentsCount();
|
54
|
+
} else {
|
55
|
+
utils.getScript('!{url_for(theme.cdn.twikoo)}').then(fetchCommentsCount);
|
56
|
+
}
|
57
|
+
}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
- const google_adsense = theme.google_adsense.enable
|
2
|
+
- const select = ['title','#body-wrap','#site-config','meta[name="description"]','.js-pjax','meta[property^="og:"]','#config-diff', '.rs_show', '.rs_hide']
|
2
3
|
|
3
4
|
script.
|
4
5
|
const pjax = new Pjax({
|
5
6
|
elements: 'a:not([target="_blank"])',
|
6
|
-
selectors:
|
7
|
+
selectors: !{JSON.stringify(select)},
|
7
8
|
cacheBust: false,
|
8
9
|
analytics: !{google_adsense},
|
9
10
|
scrollRestoration: false
|
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/post.pug
CHANGED
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/plugins.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
algolia_search:
|
2
2
|
name: algoliasearch
|
3
3
|
file: dist/algoliasearch.umd.js
|
4
|
-
version: 5.
|
4
|
+
version: 5.14.2
|
5
5
|
instantsearch:
|
6
6
|
name: instantsearch.js
|
7
7
|
file: dist/instantsearch.production.min.js
|
8
|
-
version: 4.
|
8
|
+
version: 4.75.5
|
9
9
|
pjax:
|
10
10
|
name: pjax
|
11
11
|
file: pjax.min.js
|
@@ -13,16 +13,16 @@ pjax:
|
|
13
13
|
twikoo:
|
14
14
|
name: twikoo
|
15
15
|
file: dist/twikoo.all.min.js
|
16
|
-
version: 1.6.
|
16
|
+
version: 1.6.40
|
17
17
|
waline_js:
|
18
18
|
name: '@waline/client'
|
19
19
|
file: dist/waline.js
|
20
20
|
other_name: waline
|
21
|
-
version: 3.3.
|
21
|
+
version: 3.3.2
|
22
22
|
waline_css:
|
23
23
|
name: '@waline/client'
|
24
24
|
file: dist/waline.css
|
25
|
-
version: 3.3.
|
25
|
+
version: 3.3.2
|
26
26
|
other_name: waline
|
27
27
|
valine:
|
28
28
|
name: valine
|
@@ -31,11 +31,11 @@ valine:
|
|
31
31
|
artalk_css:
|
32
32
|
name: artalk
|
33
33
|
file: dist/Artalk.css
|
34
|
-
version: 2.9.
|
34
|
+
version: 2.9.1
|
35
35
|
artalk_js:
|
36
36
|
name: artalk
|
37
37
|
file: dist/Artalk.js
|
38
|
-
version: 2.9.
|
38
|
+
version: 2.9.1
|
39
39
|
katex:
|
40
40
|
name: katex
|
41
41
|
file: dist/katex.min.css
|
@@ -106,7 +106,7 @@ fancyapps_css:
|
|
106
106
|
mermaid_js:
|
107
107
|
name: mermaid
|
108
108
|
file: dist/mermaid.js
|
109
|
-
version:
|
109
|
+
version: 11.4.0
|
110
110
|
chart_js:
|
111
111
|
name: chart.js
|
112
112
|
file: dist/chart.umd.js
|
@@ -115,7 +115,7 @@ chart_js:
|
|
115
115
|
typeit_js:
|
116
116
|
name: typeit
|
117
117
|
file: index.umd.min.js
|
118
|
-
version: 8.8.
|
118
|
+
version: 8.8.7
|
119
119
|
other_name: typeit
|
120
120
|
blueimp_md5:
|
121
121
|
name: blueimp-md5
|
@@ -129,5 +129,5 @@ qrcode:
|
|
129
129
|
color_thief:
|
130
130
|
name: colorthief
|
131
131
|
file: color-thief.min.js
|
132
|
-
version: 2.
|
132
|
+
version: 2.6.0
|
133
133
|
other_name: color-thief
|
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)
|
package/scripts/event/welcome.js
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
hexo.on('ready', () => {
|
2
|
-
const {version} = require('../../package.json')
|
3
|
-
|
4
|
-
=====================[ Hexo Theme - Solitude ]=====================
|
2
|
+
const { version } = require('../../package.json')
|
3
|
+
const logo = `
|
5
4
|
##### #### # ##### ###### # # ###### ######
|
6
5
|
# # # # # # # # # # #
|
7
6
|
##### # # # # # # # # # ######
|
8
7
|
# # # # # # # # # # #
|
9
8
|
###### #### ##### ##### # ### ###### ######
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
`.replace(/#/g, '●')
|
10
|
+
const message = `
|
11
|
+
\x1b[38;5;45m=====================[ Hexo Theme - Solitude ]=====================\x1b[0m
|
12
|
+
\x1b[38;5;45m${logo}\x1b[0m
|
13
|
+
\x1b[38;5;45m version: ${version}\x1b[0m
|
14
|
+
\x1b[38;5;45m===================================================================\x1b[0m
|
15
|
+
\x1b[38;5;45mGitHub: https://github.com/everfu/hexo-theme-solitude\x1b[0m
|
16
|
+
`
|
17
|
+
hexo.log.info(message)
|
14
18
|
})
|
@@ -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,5 +1,16 @@
|
|
1
1
|
hexo.extend.filter.register('after_render:html', function (data) {
|
2
|
-
const posts = hexo.locals.get('posts')
|
3
|
-
|
4
|
-
|
2
|
+
const posts = hexo.locals.get('posts')
|
3
|
+
.filter(post => post.random !== false)
|
4
|
+
.map(post => post.path);
|
5
|
+
|
6
|
+
const scriptContent = `
|
7
|
+
<script>
|
8
|
+
const posts = ${JSON.stringify(posts)};
|
9
|
+
function toRandomPost() {
|
10
|
+
const randomPost = posts[Math.floor(Math.random() * posts.length)];
|
11
|
+
pjax.loadUrl(GLOBAL_CONFIG.root + randomPost);
|
12
|
+
}
|
13
|
+
</script>`;
|
14
|
+
|
15
|
+
return data + scriptContent;
|
5
16
|
});
|
@@ -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
|
});
|