hexo-theme-solitude 3.0.20 → 4.0.0
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/.github/FUNDING.yml +3 -3
- package/README.md +11 -1
- package/README_en-US.md +11 -1
- package/_config.yml +16 -7
- package/languages/default.yml +56 -36
- package/languages/en.yml +90 -69
- package/languages/es.yml +94 -73
- package/languages/zh-CN.yml +56 -34
- package/languages/zh-TW.yml +80 -57
- package/layout/archive.pug +60 -14
- package/layout/category.pug +13 -11
- package/layout/includes/body/gadsense.pug +2 -2
- package/layout/includes/console.pug +71 -72
- package/layout/includes/footer.pug +38 -24
- package/layout/includes/head/config.pug +83 -39
- package/layout/includes/head/mode.pug +7 -7
- package/layout/includes/head/page_config.pug +20 -11
- package/layout/includes/inject/body.pug +18 -40
- package/layout/includes/keyboard.pug +3 -3
- package/layout/includes/loading.pug +1 -37
- package/layout/includes/mixins/articleSort.pug +3 -3
- package/layout/includes/mixins/common.pug +8 -4
- package/layout/includes/mixins/pace.pug +1 -1
- package/layout/includes/mixins/pagination.pug +3 -3
- package/layout/includes/nav.pug +5 -4
- package/layout/includes/page/about.pug +9 -8
- package/layout/includes/page/brevity.pug +2 -2
- package/layout/includes/page/links.pug +23 -11
- package/layout/includes/page/music.pug +0 -5
- package/layout/includes/rightmenu.pug +20 -20
- package/layout/includes/sidebar.pug +2 -2
- package/layout/includes/widgets/aside/asideInfoCard.pug +2 -2
- package/layout/includes/widgets/aside/asideTag.pug +2 -2
- package/layout/includes/widgets/home/bbTimeList.pug +3 -3
- package/layout/includes/widgets/home/categoryBar.pug +30 -15
- package/layout/includes/widgets/home/hometop.pug +113 -8
- package/layout/includes/widgets/home/postList.pug +1 -2
- package/layout/includes/widgets/home/topGroup.pug +3 -7
- package/layout/includes/widgets/nav/group.pug +4 -2
- package/layout/includes/widgets/nav/menu.pug +6 -4
- package/layout/includes/widgets/nav/right.pug +7 -6
- package/layout/includes/widgets/page/about/award.pug +67 -38
- package/layout/includes/widgets/page/about/hobbies.pug +12 -3
- package/layout/includes/widgets/page/banner.pug +1 -1
- package/layout/includes/widgets/page/kit/content.pug +2 -2
- package/layout/includes/widgets/page/links/banner.pug +30 -19
- package/layout/includes/widgets/page/message/artalk.pug +3 -3
- package/layout/includes/widgets/page/message/content.pug +3 -3
- package/layout/includes/widgets/page/message/twikoo.pug +3 -3
- package/layout/includes/widgets/page/message/valine.pug +4 -4
- package/layout/includes/widgets/page/message/waline.pug +3 -3
- package/layout/includes/widgets/page/recentcomment/artalk.pug +5 -9
- package/layout/includes/widgets/page/recentcomment/twikoo.pug +5 -9
- package/layout/includes/widgets/page/recentcomment/valine.pug +6 -10
- package/layout/includes/widgets/page/recentcomment/waline.pug +5 -9
- package/layout/includes/widgets/post/award.pug +1 -28
- package/layout/includes/widgets/post/copyright.pug +10 -10
- package/layout/includes/widgets/post/postInfo.pug +10 -11
- package/layout/includes/widgets/post/postMeta.pug +3 -2
- package/layout/includes/widgets/rightside/hide.pug +5 -5
- package/layout/includes/widgets/rightside/show.pug +7 -7
- package/layout/includes/widgets/third-party/comments/artalk.pug +9 -9
- package/layout/includes/widgets/third-party/comments/giscus.pug +2 -2
- package/layout/includes/widgets/third-party/comments/twikoo.pug +5 -5
- package/layout/includes/widgets/third-party/comments/valine.pug +6 -6
- package/layout/includes/widgets/third-party/comments/waline.pug +6 -6
- package/layout/includes/widgets/third-party/hot/index.pug +1 -1
- package/layout/includes/widgets/third-party/hot/twikoo.pug +1 -1
- package/layout/includes/widgets/third-party/music.pug +9 -5
- package/layout/includes/widgets/third-party/news-comment/artalk.pug +6 -6
- package/layout/includes/widgets/third-party/news-comment/twikoo.pug +7 -7
- package/layout/includes/widgets/third-party/news-comment/valine.pug +8 -8
- package/layout/includes/widgets/third-party/news-comment/waline.pug +7 -7
- package/layout/includes/widgets/third-party/pjax.pug +16 -10
- package/layout/includes/widgets/third-party/search/algolia-search.pug +2 -2
- package/layout/includes/widgets/third-party/search/docsearch.pug +3 -3
- package/layout/includes/widgets/third-party/search/index.pug +1 -3
- package/layout/includes/widgets/third-party/search/local-search.pug +9 -9
- package/layout/index.pug +10 -8
- package/package.json +8 -7
- package/plugins.yml +22 -21
- package/scripts/event/cdn.js +11 -6
- package/scripts/event/friend_links.js +30 -0
- package/scripts/event/merge_config.js +15 -7
- package/scripts/filter/comment.js +2 -2
- package/scripts/filter/default.js +1 -1
- package/scripts/helper/inject_head_js.js +79 -33
- package/scripts/helper/related_post.js +16 -21
- package/scripts/tags/chart.js +1 -1
- package/scripts/tags/typeit.js +1 -1
- package/source/css/_components/capsule.styl +259 -168
- package/source/css/_components/rightside.styl +98 -242
- package/source/css/_global/animation.styl +1 -10
- package/source/css/_global/index.styl +27 -1
- package/source/css/_layout/aside.styl +7 -1
- package/source/css/_layout/console.styl +144 -163
- package/source/css/_layout/header.styl +238 -47
- package/source/css/_layout/pagination.styl +176 -132
- package/source/css/_layout/rightmenu.styl +11 -2
- package/source/css/_layout/sidebar.styl +39 -17
- package/source/css/_mode/index.styl +7 -1
- package/source/css/_page/_about/about.styl +18 -2
- package/source/css/_page/_about/buff.styl +1 -1
- package/source/css/_page/_about/contentinfo.styl +2 -1
- package/source/css/_page/_about/game.styl +57 -1
- package/source/css/_page/_about/like.styl +7 -2
- package/source/css/_page/_about/maxim.styl +1 -1
- package/source/css/_page/_about/reward.styl +226 -108
- package/source/css/_page/_about/skills.styl +5 -3
- package/source/css/_page/_home/category-bar.styl +162 -88
- package/source/css/_page/_home/home-top.styl +309 -263
- package/source/css/_page/_home/home.styl +34 -7
- package/source/css/_page/archive.styl +412 -0
- package/source/css/_page/category.styl +27 -1
- package/source/css/_page/index.styl +2 -0
- package/source/css/_page/links.styl +190 -0
- package/source/css/_page/other.styl +37 -0
- package/source/css/_post/index.styl +2 -1
- package/source/css/_post/meta.styl +245 -217
- package/source/css/_search/local-search.styl +158 -82
- package/source/css/var.styl +2 -2
- package/source/js/archive-page.js +191 -0
- package/source/js/core/actions.js +48 -0
- package/source/js/core/api.js +32 -0
- package/source/js/core/config.js +13 -0
- package/source/js/core/lifecycle.js +52 -0
- package/source/js/core/preloader.js +34 -0
- package/source/js/core/resources.js +65 -0
- package/source/js/covercolor/api.js +13 -103
- package/source/js/covercolor/ave.js +14 -77
- package/source/js/covercolor/local.js +22 -116
- package/source/js/covercolor/shared.js +102 -0
- package/source/js/friend_links.js +502 -0
- package/source/js/main.js +793 -177
- package/source/js/music.js +24 -14
- package/source/js/post_ai.js +13 -2
- package/source/js/right_menu.js +44 -24
- package/source/js/search/algolia.js +29 -21
- package/source/js/search/local.js +231 -266
- package/source/js/tw_cn.js +37 -12
- package/source/js/utils.js +37 -25
- package/layout/includes/widgets/randomlink.pug +0 -43
- package/scripts/filter/randomPosts.js +0 -16
package/source/js/tw_cn.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Solitude } from "./core/api.js";
|
|
2
|
+
|
|
3
|
+
const initializeTranslation = () => {
|
|
4
|
+
const {
|
|
5
|
+
defaultEncoding,
|
|
6
|
+
translateDelay,
|
|
7
|
+
toSimplified,
|
|
8
|
+
toTraditional,
|
|
9
|
+
switchedToSimplified,
|
|
10
|
+
switchedToTraditional,
|
|
11
|
+
} = Solitude.config.translate;
|
|
3
12
|
const targetEncodingCookie = 'translate-chn-cht';
|
|
4
13
|
|
|
5
14
|
let currentEncoding = defaultEncoding;
|
|
6
|
-
let targetEncoding = Number(
|
|
15
|
+
let targetEncoding = Number(Solitude.saveToLocal.get(targetEncodingCookie)) || defaultEncoding;
|
|
7
16
|
|
|
8
17
|
function setLang() {
|
|
9
18
|
document.documentElement.lang = targetEncoding === 1 ? 'zh-TW' : 'zh-CN';
|
|
@@ -23,6 +32,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
23
32
|
if (obj.title) obj.title = translateText(obj.title);
|
|
24
33
|
if (obj.alt) obj.alt = translateText(obj.alt);
|
|
25
34
|
if (obj.placeholder) obj.placeholder = translateText(obj.placeholder);
|
|
35
|
+
if (obj.getAttribute?.('heotip')) {
|
|
36
|
+
obj.setAttribute('heotip', translateText(obj.getAttribute('heotip')));
|
|
37
|
+
}
|
|
26
38
|
if (obj.tagName === 'INPUT' && obj.value && !['text', 'hidden'].includes(obj.type)) {
|
|
27
39
|
obj.value = translateText(obj.value);
|
|
28
40
|
}
|
|
@@ -34,16 +46,23 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
34
46
|
});
|
|
35
47
|
}
|
|
36
48
|
|
|
37
|
-
function
|
|
49
|
+
function updateButtonLabel(button, label) {
|
|
50
|
+
const textNode = button.lastElementChild || button.lastChild;
|
|
51
|
+
if (textNode) textNode.textContent = label;
|
|
52
|
+
button.setAttribute('title', label);
|
|
53
|
+
button.setAttribute('heotip', label);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function translatePage(button, simplified = toSimplified, traditional = toTraditional) {
|
|
38
57
|
currentEncoding = targetEncoding;
|
|
39
58
|
targetEncoding = targetEncoding === 1 ? 2 : 1;
|
|
40
|
-
button
|
|
59
|
+
updateButtonLabel(button, targetEncoding === 1 ? simplified : traditional);
|
|
41
60
|
|
|
42
|
-
|
|
43
|
-
|
|
61
|
+
Solitude.snackbarShow(targetEncoding === 1 ? switchedToTraditional : switchedToSimplified);
|
|
62
|
+
Solitude.saveToLocal.set(targetEncodingCookie, targetEncoding, 2);
|
|
44
63
|
setLang();
|
|
45
64
|
translateBody();
|
|
46
|
-
|
|
65
|
+
Solitude.hideRightMenu?.();
|
|
47
66
|
}
|
|
48
67
|
|
|
49
68
|
function JTPYStr() {
|
|
@@ -75,12 +94,12 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
75
94
|
function translateInitialization() {
|
|
76
95
|
const btn_1 = document.getElementById('menu-translate');
|
|
77
96
|
if (btn_1) {
|
|
78
|
-
btn_1
|
|
97
|
+
updateButtonLabel(btn_1, targetEncoding === 1 ? toSimplified : toTraditional);
|
|
79
98
|
if (currentEncoding !== targetEncoding) {
|
|
80
99
|
setLang();
|
|
81
100
|
setTimeout(translateBody, translateDelay);
|
|
82
101
|
}
|
|
83
|
-
btn_1.addEventListener('click', () => translatePage(
|
|
102
|
+
btn_1.addEventListener('click', () => translatePage(btn_1), false);
|
|
84
103
|
}
|
|
85
104
|
|
|
86
105
|
const btn_2 = document.querySelector('.rs_hide .translate');
|
|
@@ -90,10 +109,16 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
90
109
|
setLang();
|
|
91
110
|
setTimeout(translateBody, translateDelay);
|
|
92
111
|
}
|
|
93
|
-
btn_2.addEventListener('click', () => translatePage('简', '繁'
|
|
112
|
+
btn_2.addEventListener('click', () => translatePage(btn_2, '简', '繁'), false);
|
|
94
113
|
}
|
|
95
114
|
}
|
|
96
115
|
|
|
97
116
|
translateInitialization();
|
|
98
117
|
document.addEventListener('pjax:complete', translateInitialization);
|
|
99
|
-
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
if (document.readyState === 'loading') {
|
|
121
|
+
document.addEventListener('DOMContentLoaded', initializeTranslation, { once: true });
|
|
122
|
+
} else {
|
|
123
|
+
initializeTranslation();
|
|
124
|
+
}
|
package/source/js/utils.js
CHANGED
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
copy: async (text) => {
|
|
39
39
|
const message = await navigator.clipboard
|
|
40
40
|
.writeText(text)
|
|
41
|
-
.then(() =>
|
|
42
|
-
.catch(() =>
|
|
43
|
-
|
|
41
|
+
.then(() => Solitude.config.lang.copy.success)
|
|
42
|
+
.catch(() => Solitude.config.lang.copy.error);
|
|
43
|
+
Solitude.snackbarShow(message, false, 2000);
|
|
44
44
|
},
|
|
45
45
|
getEleTop: (ele) => {
|
|
46
46
|
let actualTop = ele.offsetTop;
|
|
@@ -113,11 +113,11 @@
|
|
|
113
113
|
elements_selector: "img",
|
|
114
114
|
threshold: 0,
|
|
115
115
|
data_src: "lazy-src",
|
|
116
|
-
callback_error: (img) => (img.src =
|
|
116
|
+
callback_error: (img) => (img.src = Solitude.config.lazyload.error),
|
|
117
117
|
});
|
|
118
118
|
},
|
|
119
119
|
lightbox: function (selector) {
|
|
120
|
-
const lightboxType =
|
|
120
|
+
const lightboxType = Solitude.config.lightbox;
|
|
121
121
|
const options = {
|
|
122
122
|
class: "fancybox",
|
|
123
123
|
"data-fancybox": "gallery",
|
|
@@ -131,30 +131,42 @@
|
|
|
131
131
|
if (i.parentNode.tagName !== "A") {
|
|
132
132
|
options.href = options["data-thumb"] = i.dataset.lazySrc || i.src;
|
|
133
133
|
options["data-caption"] = i.title || i.alt || "";
|
|
134
|
-
|
|
134
|
+
Solitude.wrap(i, "a", options);
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
|
|
138
138
|
if (!window.fancyboxRun) {
|
|
139
139
|
Fancybox.bind("[data-fancybox]", {
|
|
140
140
|
Hash: false,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
"
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
141
|
+
Carousel: {
|
|
142
|
+
transition: "slide",
|
|
143
|
+
Thumbs: { showOnStart: false },
|
|
144
|
+
Zoomable: { Panzoom: { maxScale: 4 } },
|
|
145
|
+
Toolbar: {
|
|
146
|
+
display: {
|
|
147
|
+
left: ["counter"],
|
|
148
|
+
middle: [],
|
|
149
|
+
right: ["thumbs", "close"],
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
breakpoints: {
|
|
153
|
+
"(min-width: 768px)": {
|
|
154
|
+
Toolbar: {
|
|
155
|
+
display: {
|
|
156
|
+
left: ["counter"],
|
|
157
|
+
middle: [
|
|
158
|
+
"zoomIn",
|
|
159
|
+
"zoomOut",
|
|
160
|
+
"toggle1to1",
|
|
161
|
+
"rotateCCW",
|
|
162
|
+
"rotateCW",
|
|
163
|
+
"flipX",
|
|
164
|
+
"flipY",
|
|
165
|
+
],
|
|
166
|
+
right: ["autoplay", "thumbs", "close"],
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
158
170
|
},
|
|
159
171
|
},
|
|
160
172
|
});
|
|
@@ -170,7 +182,7 @@
|
|
|
170
182
|
const hour = 3600000;
|
|
171
183
|
const day = 86400000;
|
|
172
184
|
const month = 2592000000;
|
|
173
|
-
const { time } =
|
|
185
|
+
const { time } = Solitude.config.lang;
|
|
174
186
|
|
|
175
187
|
const dayCount = Math.floor(dateDiff / day);
|
|
176
188
|
if (!more) return dayCount;
|
|
@@ -214,5 +226,5 @@
|
|
|
214
226
|
}[m])
|
|
215
227
|
),
|
|
216
228
|
};
|
|
217
|
-
|
|
229
|
+
Object.assign(window.Solitude, utilsFn);
|
|
218
230
|
})();
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
- var datalinks = []
|
|
2
|
-
- var data = site.data.links.links
|
|
3
|
-
if(data)
|
|
4
|
-
each item in data
|
|
5
|
-
each y in item.link_list
|
|
6
|
-
- datalinks.push({ name: y.name,link: y.link})
|
|
7
|
-
|
|
8
|
-
script.
|
|
9
|
-
const links = !{JSON.stringify(datalinks)}
|
|
10
|
-
const randomText = '!{_p('link.random')}'
|
|
11
|
-
function travelling() {
|
|
12
|
-
const link = links[utils.randomNum(links.length)];
|
|
13
|
-
Snackbar.show({
|
|
14
|
-
text: randomText.replace(/\$\{name}/,link.name),
|
|
15
|
-
duration: 8000,
|
|
16
|
-
pos: 'top-center',
|
|
17
|
-
actionText: '!{_p('link.to')}',
|
|
18
|
-
onActionClick: function(element) {
|
|
19
|
-
element.style.opacity = 0;
|
|
20
|
-
window.open(link.link, '_blank');
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if theme.footer.randomlink
|
|
26
|
-
script.
|
|
27
|
-
function randomLinksList() {
|
|
28
|
-
const linkcard = document.getElementById('friend-links-in-footer');
|
|
29
|
-
if (linkcard == null) return;
|
|
30
|
-
|
|
31
|
-
let data = '';
|
|
32
|
-
let linksCopy = [...links];
|
|
33
|
-
let count = Math.min(3, linksCopy.length);
|
|
34
|
-
|
|
35
|
-
for (let i = 0; i < count; i++) {
|
|
36
|
-
let index = utils.randomNum(linksCopy.length);
|
|
37
|
-
const {link, name} = linksCopy[index];
|
|
38
|
-
data += `<a class="footer-item" href="${link}" target="_blank" rel="noopener noreferrer nofollow">${name}</a>`;
|
|
39
|
-
linksCopy.splice(index, 1);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
linkcard.innerHTML = data + '<a class="footer-item" href="#{url_for(/links/)}">#{_p('more')}</a>';
|
|
43
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
hexo.extend.filter.register('after_render:html', function (data) {
|
|
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;
|
|
16
|
-
});
|