hexo-theme-stellar 1.27.0 → 1.28.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/_config.yml +9 -5
- package/_data/icons.yml +1 -1
- package/languages/en.yml +1 -0
- package/languages/zh-CN.yml +1 -0
- package/languages/zh-TW.yml +1 -0
- package/layout/_partial/comments/layout.ejs +13 -8
- package/layout/_partial/head.ejs +2 -1
- package/layout/_partial/widgets/toc.ejs +6 -0
- package/layout/_plugins/search/algolia_search.ejs +13 -0
- package/layout/_plugins/swiper.ejs +2 -2
- package/layout/_plugins/tianli_gpt.ejs +5 -2
- package/package.json +1 -1
- package/scripts/generators/author.js +2 -1
- package/source/css/_layout/partial/footer.styl +2 -1
- package/source/css/_layout/sidebar/menu.styl +1 -1
- package/source/css/_layout/sidebar/sidebar.styl +2 -0
- package/source/css/_layout/tag-plugins/emoji.styl +1 -0
- package/source/css/_layout/widgets/list.styl +0 -1
- package/source/css/_plugins/comments/twikoo.styl +103 -59
- package/source/js/main.js +4 -0
- package/source/js/plugins/copycode.js +27 -36
- package/source/js/search/algolia-search.js +75 -0
package/_config.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
######## Stellar info ########
|
|
2
2
|
stellar:
|
|
3
|
-
version: '1.
|
|
3
|
+
version: '1.28.0'
|
|
4
4
|
homepage: 'https://xaoxuu.com/wiki/stellar/'
|
|
5
5
|
repo: 'https://github.com/xaoxuu/hexo-theme-stellar'
|
|
6
6
|
main_css: /css/main.css
|
|
@@ -145,11 +145,15 @@ article:
|
|
|
145
145
|
max_count: 5
|
|
146
146
|
|
|
147
147
|
search:
|
|
148
|
-
service: local_search # local_search, todo...
|
|
148
|
+
service: local_search # local_search, algolia_search, todo...
|
|
149
149
|
local_search: # 在 front-matter 中设置 indexing:false 来避免被搜索索引
|
|
150
150
|
field: all # post, page, all
|
|
151
151
|
path: /search.json # 搜索文件存放位置
|
|
152
152
|
content: true # 是否搜索内容
|
|
153
|
+
algolia_search: # Docsearch https://docsearch.algolia.com/apply/ 申请
|
|
154
|
+
appId:
|
|
155
|
+
apiKey:
|
|
156
|
+
indexName:
|
|
153
157
|
|
|
154
158
|
|
|
155
159
|
######## Comments ########
|
|
@@ -204,9 +208,9 @@ comments:
|
|
|
204
208
|
# Waline
|
|
205
209
|
# https://waline.js.org/
|
|
206
210
|
waline:
|
|
207
|
-
js: https://gcore.jsdelivr.net/npm/@waline/client@3.1.
|
|
208
|
-
css: https://gcore.jsdelivr.net/npm/@waline/client@3.1.
|
|
209
|
-
meta_css: https://gcore.jsdelivr.net/npm/@waline/client@3.1.
|
|
211
|
+
js: https://gcore.jsdelivr.net/npm/@waline/client@3.1.3/dist/waline.js
|
|
212
|
+
css: https://gcore.jsdelivr.net/npm/@waline/client@3.1.3/dist/waline.css
|
|
213
|
+
meta_css: https://gcore.jsdelivr.net/npm/@waline/client@3.1.3/dist/waline-meta.css
|
|
210
214
|
# Waline server address url, you should set this to your own link
|
|
211
215
|
serverURL: https://waline.vercel.app
|
|
212
216
|
# If false, comment count will only be displayed in post page, not in home page
|
package/_data/icons.yml
CHANGED
|
@@ -31,7 +31,7 @@ default:category: <svg style="margin-bottom:1px" xmlns="http://www.w3.org/2000/s
|
|
|
31
31
|
# 编辑本文
|
|
32
32
|
default:edit: <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" fill-rule="evenodd" d="M11.943 1.25H13.5a.75.75 0 0 1 0 1.5H12c-2.378 0-4.086.002-5.386.176c-1.279.172-2.05.5-2.62 1.069c-.569.57-.896 1.34-1.068 2.619c-.174 1.3-.176 3.008-.176 5.386s.002 4.086.176 5.386c.172 1.279.5 2.05 1.069 2.62c.57.569 1.34.896 2.619 1.068c1.3.174 3.008.176 5.386.176s4.086-.002 5.386-.176c1.279-.172 2.05-.5 2.62-1.069c.569-.57.896-1.34 1.068-2.619c.174-1.3.176-3.008.176-5.386v-1.5a.75.75 0 0 1 1.5 0v1.557c0 2.309 0 4.118-.19 5.53c-.194 1.444-.6 2.584-1.494 3.479c-.895.895-2.035 1.3-3.48 1.494c-1.411.19-3.22.19-5.529.19h-.114c-2.309 0-4.118 0-5.53-.19c-1.444-.194-2.584-.6-3.479-1.494c-.895-.895-1.3-2.035-1.494-3.48c-.19-1.411-.19-3.22-.19-5.529v-.114c0-2.309 0-4.118.19-5.53c.194-1.444.6-2.584 1.494-3.479c.895-.895 2.035-1.3 3.48-1.494c1.411-.19 3.22-.19 5.529-.19m4.827 1.026a3.503 3.503 0 0 1 4.954 4.953l-6.648 6.649c-.371.37-.604.604-.863.806a5.34 5.34 0 0 1-.987.61c-.297.141-.61.245-1.107.411l-2.905.968a1.492 1.492 0 0 1-1.887-1.887l.968-2.905c.166-.498.27-.81.411-1.107c.167-.35.372-.68.61-.987c.202-.26.435-.492.806-.863zm3.893 1.06a2.003 2.003 0 0 0-2.832 0l-.376.377c.022.096.054.21.098.338c.143.413.415.957.927 1.469a3.875 3.875 0 0 0 1.807 1.025l.376-.376a2.003 2.003 0 0 0 0-2.832m-1.558 4.391a5.397 5.397 0 0 1-1.686-1.146a5.395 5.395 0 0 1-1.146-1.686L11.218 9.95c-.417.417-.58.582-.72.76a3.84 3.84 0 0 0-.437.71c-.098.203-.172.423-.359.982l-.431 1.295l1.032 1.033l1.295-.432c.56-.187.779-.261.983-.358c.251-.12.49-.267.71-.439c.177-.139.342-.302.759-.718z" clip-rule="evenodd"/></svg>
|
|
33
33
|
default:upup: <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 12c0-4.714 0-7.071 1.464-8.536C4.93 2 7.286 2 12 2c4.714 0 7.071 0 8.535 1.464C22 4.93 22 7.286 22 12c0 4.714 0 7.071-1.465 8.535C19.072 22 16.714 22 12 22s-7.071 0-8.536-1.465C2 19.072 2 16.714 2 12Z"/><path stroke-linecap="round" stroke-linejoin="round" d="m9 15.5l3-3l3 3m-6-4l3-3l3 3"/></g></svg>
|
|
34
|
-
|
|
34
|
+
default:tocomment: <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" fill-rule="evenodd" d="M10.46 1.25h3.08c1.603 0 2.86 0 3.864.095c1.023.098 1.861.3 2.6.752a5.75 5.75 0 0 1 1.899 1.899c.452.738.654 1.577.752 2.6c.095 1.004.095 2.261.095 3.865v1.067c0 1.141 0 2.036-.05 2.759c-.05.735-.153 1.347-.388 1.913a5.75 5.75 0 0 1-3.112 3.112c-.805.334-1.721.408-2.977.43a10.81 10.81 0 0 0-.929.036c-.198.022-.275.054-.32.08c-.047.028-.112.078-.224.232c-.121.166-.258.396-.476.764l-.542.916c-.773 1.307-2.69 1.307-3.464 0l-.542-.916a10.605 10.605 0 0 0-.476-.764c-.112-.154-.177-.204-.224-.232c-.045-.026-.122-.058-.32-.08c-.212-.023-.49-.03-.93-.037c-1.255-.021-2.171-.095-2.976-.429A5.75 5.75 0 0 1 1.688 16.2c-.235-.566-.338-1.178-.389-1.913c-.049-.723-.049-1.618-.049-2.76v-1.066c0-1.604 0-2.86.095-3.865c.098-1.023.3-1.862.752-2.6a5.75 5.75 0 0 1 1.899-1.899c.738-.452 1.577-.654 2.6-.752C7.6 1.25 8.857 1.25 10.461 1.25M6.739 2.839c-.914.087-1.495.253-1.959.537A4.25 4.25 0 0 0 3.376 4.78c-.284.464-.45 1.045-.537 1.96c-.088.924-.089 2.11-.089 3.761v1c0 1.175 0 2.019.046 2.685c.045.659.131 1.089.278 1.441a4.25 4.25 0 0 0 2.3 2.3c.515.214 1.173.294 2.429.316h.031c.398.007.747.013 1.037.045c.311.035.616.104.909.274c.29.17.5.395.682.645c.169.232.342.525.538.856l.559.944a.52.52 0 0 0 .882 0l.559-.944c.196-.331.37-.624.538-.856c.182-.25.392-.476.682-.645c.293-.17.598-.24.909-.274c.29-.032.639-.038 1.037-.045h.032c1.255-.022 1.913-.102 2.428-.316a4.25 4.25 0 0 0 2.3-2.3c.147-.352.233-.782.278-1.441c.046-.666.046-1.51.046-2.685v-1c0-1.651 0-2.837-.089-3.762c-.087-.914-.253-1.495-.537-1.959a4.25 4.25 0 0 0-1.403-1.403c-.464-.284-1.045-.45-1.96-.537c-.924-.088-2.11-.089-3.761-.089h-3c-1.651 0-2.837 0-3.762.089" clip-rule="evenodd"/><path fill="currentColor" d="M9 11a1 1 0 1 1-2 0a1 1 0 0 1 2 0m4 0a1 1 0 1 1-2 0a1 1 0 0 1 2 0m4 0a1 1 0 1 1-2 0a1 1 0 0 1 2 0"/></svg>
|
|
35
35
|
|
|
36
36
|
github:logo: <svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>
|
|
37
37
|
github:repo: <svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path></svg>
|
package/languages/en.yml
CHANGED
package/languages/zh-CN.yml
CHANGED
package/languages/zh-TW.yml
CHANGED
|
@@ -14,15 +14,20 @@ if (theme.comments.service && theme.comments.service.length > 0) {
|
|
|
14
14
|
// 合并项目评论
|
|
15
15
|
const proj = theme.wiki.tree[page.wiki]
|
|
16
16
|
if (loadComment && (proj != null)) {
|
|
17
|
-
if (proj.
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
if (proj.comments === false) {
|
|
18
|
+
loadComment = false;
|
|
19
|
+
page.comments = false;
|
|
20
|
+
} else {
|
|
21
|
+
if (proj.comment_title != undefined && page.comment_title == undefined) {
|
|
22
|
+
if (['utterances', 'beaudar', 'giscus'].includes(theme.comments.service)) {
|
|
23
|
+
page.comment_title = proj.comment_title;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (proj.comments && proj.comments.service) {
|
|
27
|
+
cmt = proj.comments;
|
|
28
|
+
let s = proj.comments.service;
|
|
29
|
+
cmt[s] = Object.assign({}, theme.comments[s], proj.comments[s]);
|
|
20
30
|
}
|
|
21
|
-
}
|
|
22
|
-
if (proj.comments && proj.comments.service) {
|
|
23
|
-
cmt = proj.comments;
|
|
24
|
-
let s = proj.comments.service;
|
|
25
|
-
cmt[s] = Object.assign({}, theme.comments[s], proj.comments[s]);
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
if (cmt.service && page[cmt.service]) {
|
package/layout/_partial/head.ejs
CHANGED
|
@@ -102,7 +102,8 @@ function custom_inject() {
|
|
|
102
102
|
<meta name="HandheldFriendly" content="True" >
|
|
103
103
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
104
104
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
105
|
-
<meta name="theme-color" content="#
|
|
105
|
+
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#f9fafb">
|
|
106
|
+
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#000">
|
|
106
107
|
|
|
107
108
|
<title><%- generate_title() %></title>
|
|
108
109
|
|
|
@@ -55,6 +55,12 @@ function layoutDiv(fallback) {
|
|
|
55
55
|
el += icon('default:upup')
|
|
56
56
|
el += `<span>${__('btn.top')}</span>`
|
|
57
57
|
el += `</a>`
|
|
58
|
+
if (page.comments) {
|
|
59
|
+
el += `<a class="buttom" onclick="util.scrollComment()">`
|
|
60
|
+
el += icon('default:tocomment')
|
|
61
|
+
el += `<span>${__('btn.comments')}</span>`
|
|
62
|
+
el += `</a>`
|
|
63
|
+
}
|
|
58
64
|
el += `</div>`
|
|
59
65
|
el += `</widget>`
|
|
60
66
|
return el
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
window.addEventListener('DOMContentLoaded', (event) => {
|
|
3
|
+
window.searchConfig = {
|
|
4
|
+
appId: '<%- conf.appId %>',
|
|
5
|
+
apiKey: '<%- conf.apiKey %>',
|
|
6
|
+
indexName: '<%- conf.indexName %>',
|
|
7
|
+
hitsPerPage: 100,
|
|
8
|
+
};
|
|
9
|
+
utils.js('https://gcore.jsdelivr.net/algoliasearch/3/algoliasearch.min.js', { defer: true });
|
|
10
|
+
utils.js('/js/search/algolia-search.js', { defer: true });
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
<%
|
|
1
|
+
<%
|
|
2
|
+
const { field } = theme.plugins.tianli_gpt;
|
|
3
|
+
const matchesField = field === 'all' || field === layout || (field === 'wiki' && page.wiki) || (field === 'topic' && page.topic);
|
|
4
|
+
if (matchesField) { %>
|
|
2
5
|
<script defer src="<%- theme.plugins.tianli_gpt?.js %>"></script>
|
|
3
6
|
<script defer>
|
|
4
7
|
window.addEventListener('DOMContentLoaded', (event) => {
|
|
@@ -8,4 +11,4 @@
|
|
|
8
11
|
}, JSON.parse(`<%- JSON.stringify(theme.plugins.tianli_gpt) %>`)))
|
|
9
12
|
});
|
|
10
13
|
</script>
|
|
11
|
-
<% } %>
|
|
14
|
+
<% } %>
|
package/package.json
CHANGED
|
@@ -1,120 +1,164 @@
|
|
|
1
1
|
.cmt-body.twikoo
|
|
2
|
-
--twikoo-
|
|
3
|
-
--twikoo-secondtext: #909094;
|
|
4
|
-
--twikoo-emoji-background: #f8f8f8;
|
|
5
|
-
--twikoo-theme: $color-theme;
|
|
2
|
+
--twikoo-theme: $color-theme
|
|
6
3
|
margin-top: 1.5rem
|
|
7
4
|
|
|
8
5
|
.tk-content
|
|
9
6
|
.vemoji, .tk-owo-emotion
|
|
10
|
-
width: unset
|
|
11
|
-
border-radius: $border-image
|
|
12
|
-
max-height: 24px
|
|
13
|
-
max-width: 100px
|
|
14
|
-
|
|
7
|
+
width: unset
|
|
8
|
+
border-radius: $border-image
|
|
9
|
+
max-height: 24px
|
|
10
|
+
max-width: 100px
|
|
11
|
+
display: inline
|
|
12
|
+
margin: 0 0.25em
|
|
15
13
|
img
|
|
16
|
-
max-width: 400px
|
|
17
|
-
max-height: 400px
|
|
18
|
-
border-radius: $border-image
|
|
14
|
+
max-width: 400px
|
|
15
|
+
max-height: 400px
|
|
16
|
+
border-radius: $border-image
|
|
19
17
|
|
|
20
18
|
.OwO
|
|
21
19
|
.OwO-body
|
|
22
|
-
background: var(--
|
|
23
|
-
color: var(--text-p1) !important
|
|
20
|
+
background-color: var(--block) !important
|
|
21
|
+
color: var(--text-p1) !important
|
|
24
22
|
|
|
25
23
|
.OwO-items
|
|
26
24
|
.OwO-item
|
|
27
25
|
img
|
|
28
|
-
max-height: 26px
|
|
29
|
-
width: unset
|
|
26
|
+
max-height: 26px
|
|
27
|
+
width: unset
|
|
30
28
|
|
|
31
29
|
.twikoo
|
|
32
30
|
.el-input-group__append, .el-input-group__prepend,
|
|
33
31
|
.el-input__inner, .el-textarea__inner,
|
|
34
|
-
.el-button:not(.el-button--primary):not(.el-button--text),
|
|
35
|
-
.tk-comments-count,
|
|
36
|
-
.tk-content,
|
|
37
32
|
.tk-preview-container
|
|
38
|
-
color: var(--
|
|
39
|
-
|
|
33
|
+
border-color: var(--block-border)
|
|
34
|
+
.el-input__inner:focus,
|
|
35
|
+
.el-textarea__inner:focus
|
|
36
|
+
border-color: var(--twikoo-theme) !important
|
|
40
37
|
.el-button:not(.el-button--primary):not(.el-button--text):active,
|
|
41
38
|
.el-button:not(.el-button--primary):not(.el-button--text):focus,
|
|
42
39
|
.el-button:not(.el-button--primary):not(.el-button--text):hover
|
|
43
|
-
color: var(--twikoo-theme) !important
|
|
40
|
+
color: var(--twikoo-theme) !important
|
|
41
|
+
border-color: var(--theme-link-opa) !important
|
|
42
|
+
background-color: var(--block) !important
|
|
43
|
+
.el-button--primary.is-disabled:active,
|
|
44
|
+
.el-button--primary.is-disabled:focus,
|
|
45
|
+
.el-button--primary.is-disabled:hover
|
|
46
|
+
background-color: var(--theme-link-opa) !important
|
|
47
|
+
|
|
48
|
+
.el-button:focus,.el-button:hover
|
|
49
|
+
border-color: var(--theme-link-opa)
|
|
50
|
+
.el-button:active
|
|
51
|
+
color: var(--twikoo-theme)
|
|
52
|
+
border-color: var(--twikoo-theme)
|
|
53
|
+
.el-button.is-active,.el-button.is-plain:active
|
|
54
|
+
color: var(--twikoo-theme)
|
|
55
|
+
border-color: var(--twikoo-theme)
|
|
56
|
+
|
|
57
|
+
.el-button--primary
|
|
58
|
+
background-color: var(--twikoo-theme)
|
|
59
|
+
border-color: var(--twikoo-theme) !important
|
|
60
|
+
.el-button--primary:focus,.el-button--primary:hover
|
|
61
|
+
background: $color-hover
|
|
62
|
+
border-color: $color-hover !important
|
|
63
|
+
.el-button--primary:active
|
|
64
|
+
background: var(--twikoo-theme)
|
|
65
|
+
border-color: var(--twikoo-theme)
|
|
66
|
+
.el-button--primary.is-active
|
|
67
|
+
background: var(--twikoo-theme)
|
|
68
|
+
border-color: var(--twikoo-theme)
|
|
69
|
+
.el-button--primary.is-disabled,
|
|
70
|
+
.el-button--primary.is-disabled:active,
|
|
71
|
+
.el-button--primary.is-disabled:focus,
|
|
72
|
+
.el-button--primary.is-disabled:hover
|
|
73
|
+
background-color: var(--theme-link-opa) !important
|
|
74
|
+
border-color: var(--theme-link-opa) !important
|
|
75
|
+
.el-button--primary.is-plain
|
|
76
|
+
color: var(--twikoo-theme) !important
|
|
77
|
+
border-color: var(--theme-link-opa)
|
|
78
|
+
.el-button--primary.is-plain:focus,
|
|
79
|
+
.el-button--primary.is-plain:hover
|
|
80
|
+
background: var(--twikoo-theme) !important
|
|
81
|
+
border-color: var(--twikoo-theme)
|
|
82
|
+
.el-button--primary.is-plain:active
|
|
83
|
+
background: var(--twikoo-theme) !important
|
|
84
|
+
border-color: var(--twikoo-theme)
|
|
44
85
|
|
|
45
86
|
.tk-action-icon svg
|
|
46
|
-
color: var(--text-
|
|
87
|
+
color: var(--text-p2)
|
|
88
|
+
|
|
89
|
+
.tk-action-link
|
|
90
|
+
color: var(--text-p1)
|
|
91
|
+
&:hover
|
|
92
|
+
color: var(--twikoo-theme)
|
|
93
|
+
|
|
94
|
+
.el-loading-spinner .path
|
|
95
|
+
stroke: var(--twikoo-theme)
|
|
96
|
+
|
|
97
|
+
.tk-icon.__comments
|
|
98
|
+
color: var(--twikoo-theme)
|
|
47
99
|
|
|
48
100
|
b, strong
|
|
49
|
-
color: var(--
|
|
101
|
+
color: var(--text-p1)
|
|
50
102
|
|
|
51
103
|
a
|
|
52
104
|
cursor: pointer
|
|
53
105
|
|
|
54
106
|
.tk-time, .tk-extras
|
|
55
|
-
color: var(--
|
|
107
|
+
color: var(--text-p3)
|
|
56
108
|
|
|
57
109
|
.tk-expand
|
|
58
110
|
width: auto
|
|
59
111
|
border: none
|
|
60
112
|
padding: 6px 2rem
|
|
61
113
|
border-radius: $border-card
|
|
62
|
-
background: var(--block)
|
|
114
|
+
background: var(--block-hover)
|
|
63
115
|
color: var(--text-p1)
|
|
64
116
|
line-height: 2
|
|
65
117
|
font-size: 14px
|
|
66
118
|
font-weight: 500
|
|
67
|
-
|
|
119
|
+
trans1 background
|
|
68
120
|
|
|
69
121
|
&:hover
|
|
70
|
-
background: var(--
|
|
122
|
+
background: var(--card)
|
|
71
123
|
|
|
72
124
|
.tk-comment
|
|
73
|
-
margin-top: 0
|
|
125
|
+
margin-top: 0
|
|
74
126
|
margin-bottom: 1rem
|
|
75
|
-
border: 1px dashed var(--block-border)
|
|
76
|
-
padding: 1rem
|
|
77
|
-
border-radius: $border-card
|
|
78
|
-
background: var(--
|
|
127
|
+
border: 1px dashed var(--block-border)
|
|
128
|
+
padding: 1rem
|
|
129
|
+
border-radius: $border-card
|
|
130
|
+
background: var(--block)
|
|
79
131
|
|
|
80
132
|
&:hover
|
|
81
|
-
border-color: var(--twikoo-theme)
|
|
133
|
+
border-color: var(--twikoo-theme)
|
|
82
134
|
|
|
83
135
|
.tk-main .tk-comment
|
|
84
|
-
margin-top: 1rem
|
|
85
|
-
margin-bottom: 0
|
|
136
|
+
margin-top: 1rem
|
|
137
|
+
margin-bottom: 0
|
|
86
138
|
|
|
87
139
|
.tk-submit
|
|
88
|
-
padding: 1rem 1rem 0 1rem
|
|
89
|
-
border-radius: $border-card
|
|
90
|
-
background: var(--
|
|
140
|
+
padding: 1rem 1rem 0 1rem
|
|
141
|
+
border-radius: $border-card
|
|
142
|
+
background: var(--block)
|
|
91
143
|
|
|
92
144
|
.tk-tag
|
|
93
|
-
vertical-align: 0.1em
|
|
145
|
+
vertical-align: 0.1em
|
|
94
146
|
|
|
147
|
+
.tk-tag-green
|
|
148
|
+
border: none
|
|
149
|
+
background-color: var(--theme-link-opa)
|
|
150
|
+
color: var(--twikoo-theme)
|
|
151
|
+
|
|
95
152
|
.tk-comments-title .tk-comments-count
|
|
96
|
-
margin-top: 15px
|
|
97
|
-
color: var(--text-p1)
|
|
153
|
+
margin-top: 15px
|
|
154
|
+
color: var(--text-p1)
|
|
98
155
|
|
|
99
156
|
span:nth-child(1)
|
|
100
|
-
font-size: 1.5rem
|
|
101
|
-
font-weight: 700
|
|
157
|
+
font-size: 1.5rem
|
|
158
|
+
font-weight: 700
|
|
102
159
|
|
|
103
160
|
span:nth-child(2)
|
|
104
|
-
font-size: 1rem
|
|
161
|
+
font-size: 1rem
|
|
105
162
|
|
|
106
163
|
.tk-comments-no
|
|
107
|
-
color: var(--text-p1)
|
|
108
|
-
|
|
109
|
-
_dark_comments()
|
|
110
|
-
.cmt-body.twikoo
|
|
111
|
-
--twikoo-lighttext: $color-link;
|
|
112
|
-
--twikoo-secondtext: var(--text-p2);
|
|
113
|
-
--twikoo-theme: $color-theme;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if theme(dark)
|
|
117
|
-
_dark_comments()
|
|
118
|
-
else if theme(auto)
|
|
119
|
-
@media (prefers-color-scheme: dark)
|
|
120
|
-
_dark_comments()
|
|
164
|
+
color: var(--text-p1)
|
package/source/js/main.js
CHANGED
|
@@ -1,41 +1,32 @@
|
|
|
1
|
-
window.codeElements.forEach(
|
|
2
|
-
//
|
|
1
|
+
window.codeElements.forEach((codeElement) => {
|
|
2
|
+
// 创建复制按钮
|
|
3
3
|
const codeCopyBtn = document.createElement('div');
|
|
4
|
-
codeCopyBtn.
|
|
5
|
-
codeCopyBtn.
|
|
6
|
-
|
|
7
|
-
codeCopyBtn.addEventListener('click', async () => {
|
|
8
|
-
const currentCodeElement = code.children[0]?.innerText;
|
|
9
|
-
await copyCode(currentCodeElement);
|
|
10
|
-
codeCopyBtn.innerHTML = ctx.copycode.success_text;
|
|
11
|
-
codeCopyBtn.classList.add('success');
|
|
12
|
-
hud.toast(ctx.copycode.toast, 2500);
|
|
13
|
-
setTimeout(() => {
|
|
14
|
-
codeCopyBtn.innerHTML = ctx.copycode.default_text;
|
|
15
|
-
codeCopyBtn.classList.remove('success');
|
|
16
|
-
},3000);
|
|
17
|
-
})
|
|
18
|
-
})
|
|
4
|
+
codeCopyBtn.className = 'copy-btn';
|
|
5
|
+
codeCopyBtn.textContent = ctx.copycode.default_text;
|
|
6
|
+
codeElement.appendChild(codeCopyBtn);
|
|
19
7
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
// 添加点击事件监听
|
|
9
|
+
codeCopyBtn.addEventListener('click', async () => {
|
|
10
|
+
const codeToCopy = codeElement.querySelector('code')?.textContent || '';
|
|
11
|
+
if (navigator.clipboard) {
|
|
12
|
+
try {
|
|
13
|
+
await navigator.clipboard.writeText(codeToCopy);
|
|
14
|
+
codeCopyBtn.textContent = ctx.copycode.success_text;
|
|
15
|
+
codeCopyBtn.classList.add('success');
|
|
16
|
+
hud.toast(ctx.copycode.toast, 2500);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
codeCopyBtn.textContent = '未获得用户许可';
|
|
19
|
+
codeCopyBtn.classList.add('warning');
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
codeCopyBtn.textContent = '浏览器不支持/非HTTPS';
|
|
27
23
|
codeCopyBtn.classList.add('warning');
|
|
28
|
-
setTimeout(() => {
|
|
29
|
-
codeCopyBtn.innerText = ctx.copycode.default_text;
|
|
30
|
-
codeCopyBtn.classList.remove('warning');
|
|
31
|
-
},3000);
|
|
32
24
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
codeCopyBtn.classList.add('warning');
|
|
25
|
+
|
|
26
|
+
// 3秒后恢复默认文本
|
|
36
27
|
setTimeout(() => {
|
|
37
|
-
codeCopyBtn.
|
|
38
|
-
codeCopyBtn.classList.remove('warning');
|
|
39
|
-
},3000);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
28
|
+
codeCopyBtn.textContent = ctx.copycode.default_text;
|
|
29
|
+
codeCopyBtn.classList.remove('success', 'warning');
|
|
30
|
+
}, 3000);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
utils.jq(() => {
|
|
2
|
+
var $inputArea = $("input#search-input");
|
|
3
|
+
if ($inputArea.length === 0) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
var $resultArea = $("#search-result");
|
|
8
|
+
var $searchWrapper = $("#search-wrapper");
|
|
9
|
+
var client = algoliasearch(window.searchConfig.appId, window.searchConfig.apiKey);
|
|
10
|
+
var index = client.initIndex(window.searchConfig.indexName);
|
|
11
|
+
|
|
12
|
+
function filterResults(hits, filterPath) {
|
|
13
|
+
if (!filterPath || filterPath === '/') return hits;
|
|
14
|
+
var regex = new RegExp(filterPath);
|
|
15
|
+
return hits.filter(hit => regex.test(hit.url));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function displayResults(hits) {
|
|
19
|
+
var $resultList = $("<ul>").addClass("search-result-list");
|
|
20
|
+
if (hits.length === 0) {
|
|
21
|
+
$searchWrapper.addClass('noresult');
|
|
22
|
+
} else {
|
|
23
|
+
$searchWrapper.removeClass('noresult');
|
|
24
|
+
hits.forEach(function(hit) {
|
|
25
|
+
var contentSnippet = hit._snippetResult.content.value;
|
|
26
|
+
var title = hit.hierarchy.lvl1 || 'Untitled';
|
|
27
|
+
var $item = $("<li>").html(`<a href="${hit.url}"><span class='search-result-title'>${title}</span><p class="search-result-content">${contentSnippet}</p></a>`);
|
|
28
|
+
$resultList.append($item);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
$resultArea.html($resultList);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
$inputArea.on("input", function() {
|
|
35
|
+
var query = $(this).val().trim();
|
|
36
|
+
var filterPath = $inputArea.data('filter');
|
|
37
|
+
|
|
38
|
+
if (query.length <= 0) {
|
|
39
|
+
$searchWrapper.attr('searching', 'false');
|
|
40
|
+
$resultArea.empty();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
$searchWrapper.attr('searching', 'true');
|
|
45
|
+
|
|
46
|
+
index.search(query, {
|
|
47
|
+
hitsPerPage: window.searchConfig.hitsPerPage,
|
|
48
|
+
attributesToHighlight: ['content'],
|
|
49
|
+
attributesToSnippet: ['content:30'],
|
|
50
|
+
highlightPreTag: '<span class="search-keyword">',
|
|
51
|
+
highlightPostTag: '</span>',
|
|
52
|
+
restrictSearchableAttributes: ['content']
|
|
53
|
+
}).then(function(responses) {
|
|
54
|
+
displayResults(filterResults(responses.hits, filterPath));
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
$inputArea.on("keydown", function(e) {
|
|
59
|
+
if (e.which == 13) {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
var observer = new MutationObserver(function(mutationsList) {
|
|
65
|
+
if (mutationsList.length === 1) {
|
|
66
|
+
if (mutationsList[0].addedNodes.length) {
|
|
67
|
+
$searchWrapper.removeClass('noresult');
|
|
68
|
+
} else if (mutationsList[0].removedNodes.length) {
|
|
69
|
+
$searchWrapper.addClass('noresult');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
observer.observe($resultArea[0], { childList: true });
|
|
75
|
+
});
|