hexo-theme-solitude 1.11.3 → 1.12.1
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/logo.svg +18 -42
- package/CONTRIBUTING.md +1 -1
- package/README.md +7 -19
- package/README_en-US.md +16 -26
- package/README_zh-Hant.md +15 -25
- package/SECURITY.md +1 -1
- package/_config.yml +52 -37
- package/languages/default.yml +15 -0
- package/languages/en.yml +15 -1
- package/languages/zh-CN.yml +14 -0
- package/languages/zh-TW.yml +14 -0
- package/layout/includes/body/mode.pug +3 -3
- package/layout/includes/console.pug +4 -3
- package/layout/includes/inject/body.pug +2 -3
- package/layout/includes/inject/head.pug +3 -2
- package/layout/includes/widgets/aside/asideNewstComments.pug +9 -0
- package/layout/includes/widgets/aside/asideSwitch.pug +2 -0
- package/layout/includes/widgets/home/carousel.pug +18 -1
- package/layout/includes/widgets/home/postList.pug +4 -3
- package/layout/includes/widgets/post/copyright.pug +46 -0
- package/layout/includes/widgets/post/postMeta.pug +1 -1
- package/layout/includes/widgets/post/postNav.pug +4 -4
- package/layout/includes/widgets/third-party/comments/comment.pug +3 -1
- package/layout/includes/widgets/third-party/comments/giscus.pug +60 -0
- package/layout/includes/widgets/third-party/comments/js.pug +3 -1
- package/layout/includes/widgets/third-party/news-comment/artalk.pug +10 -12
- package/layout/includes/widgets/third-party/news-comment/newest-comment.pug +6 -5
- package/layout/includes/widgets/third-party/news-comment/twikoo.pug +10 -9
- package/layout/includes/widgets/third-party/news-comment/valine.pug +9 -7
- package/layout/includes/widgets/third-party/news-comment/waline.pug +9 -7
- package/layout/post.pug +0 -22
- package/package.json +3 -3
- package/plugins.yml +6 -1
- package/scripts/event/merge_config.js +17 -16
- package/scripts/event/welcome.js +1 -1
- package/scripts/filter/default.js +2 -2
- package/scripts/filter/post_image.js +13 -0
- package/scripts/helper/page.js +6 -2
- package/source/css/_highlight/color.styl +69 -131
- package/source/css/_highlight/highlight/diff.styl +34 -62
- package/source/css/_highlight/index.styl +1 -1
- package/source/css/_highlight/prismjs/diff.styl +60 -59
- package/source/css/_layout/article-container.styl +1 -5
- package/source/css/_layout/aside.styl +52 -5
- package/source/css/_layout/console.styl +3 -78
- package/source/css/_page/_home/carousel.styl +2 -0
- package/source/css/_page/message.styl +2 -1
- package/source/css/_page/music.styl +8 -1
- package/source/css/_page/other.styl +1 -0
- package/source/css/_post/commentBarrage.styl +2 -11
- package/source/css/_post/copyright.styl +129 -2
- package/source/css/_post/meta.styl +4 -44
- package/source/css/_post/pagination.styl +13 -0
- package/source/css/_post/postAI.styl +2 -3
- package/source/css/_post/relatedPost.styl +115 -129
- package/source/css/_post/tools.styl +168 -271
- package/source/css/third_party/snackbar.min.css +1 -1
- package/source/img/404.avif +0 -0
- package/source/img/avatar.avif +0 -0
- package/source/img/default.avif +0 -0
- package/source/img/error_load.avif +0 -0
- package/source/img/happy-sticker.avif +0 -0
- package/source/img/loading.avif +0 -0
- package/source/img/recent_c.avif +0 -0
- package/source/js/main.js +98 -277
- package/source/js/music.js +1 -0
- package/source/js/right_menu.js +163 -136
- package/source/img/404.webp +0 -0
- package/source/img/avatar.png +0 -0
- package/source/img/default.png +0 -0
- package/source/img/error_load.webp +0 -0
- package/source/img/happy-sticker.png +0 -0
- package/source/img/loading.gif +0 -0
package/languages/zh-CN.yml
CHANGED
@@ -68,9 +68,22 @@ post:
|
|
68
68
|
reprint: 本文是转载或翻译文章,版权归原作者所有。转载本文请联系原作者。
|
69
69
|
original: 本文是原创文章,采用
|
70
70
|
original_end: 协议,完整转载请注明来自
|
71
|
+
share:
|
72
|
+
qq: 分享到QQ
|
73
|
+
weibo: 分享到微博
|
74
|
+
telegram: 分享到Telegram
|
75
|
+
twitter: 分享到Twitter
|
76
|
+
linkedin: 分享到LinkedIn
|
77
|
+
facebook: 分享到Facebook
|
78
|
+
link: 复制文章链接
|
79
|
+
qrcode: 使用手机扫码阅读这篇文章
|
80
|
+
whatsapp: 分享到WhatsApp
|
71
81
|
ai:
|
72
82
|
title: 文章摘要
|
73
83
|
tip: 投诉
|
84
|
+
nav:
|
85
|
+
next: 下一篇
|
86
|
+
prev: 上一篇
|
74
87
|
|
75
88
|
award:
|
76
89
|
thanks: 致谢
|
@@ -100,6 +113,7 @@ aside:
|
|
100
113
|
back: 欢迎再次回来,
|
101
114
|
sticker: 心情贴纸
|
102
115
|
newpost: 最近发布
|
116
|
+
newcomment: 最新评论
|
103
117
|
card:
|
104
118
|
posts: '累计文章数:'
|
105
119
|
tags: '标签总数:'
|
package/languages/zh-TW.yml
CHANGED
@@ -68,9 +68,22 @@ post:
|
|
68
68
|
reprint: 本文是转载或翻译文章,版权归原作者所有。转载本文请联系原作者。
|
69
69
|
original: 本文是原创文章,采用
|
70
70
|
original_end: 协议,完整转载请注明来自
|
71
|
+
share:
|
72
|
+
qq: 分享到QQ
|
73
|
+
weibo: 分享到微博
|
74
|
+
telegram: 分享到Telegram
|
75
|
+
twitter: 分享到Twitter
|
76
|
+
linkedin: 分享到LinkedIn
|
77
|
+
facebook: 分享到Facebook
|
78
|
+
link: 复制文章链接
|
79
|
+
qrcode: 使用手机扫码阅读这篇文章
|
80
|
+
whatsapp: 分享到WhatsApp
|
71
81
|
ai:
|
72
82
|
title: 文章摘要
|
73
83
|
tip: 投訴
|
84
|
+
nav:
|
85
|
+
next: 下一篇
|
86
|
+
prev: 上一篇
|
74
87
|
|
75
88
|
award:
|
76
89
|
thanks: 致謝
|
@@ -100,6 +113,7 @@ aside:
|
|
100
113
|
back: 歡迎再次回來,
|
101
114
|
sticker: 心情贴纸
|
102
115
|
newpost: 最近发布
|
116
|
+
newcomment: 最新评论
|
103
117
|
card:
|
104
118
|
posts: '累計文章數:'
|
105
119
|
tags: '標籤總數:'
|
@@ -11,7 +11,7 @@ case theme.display_mode.type
|
|
11
11
|
} else {
|
12
12
|
document.documentElement.setAttribute('data-theme', cachedMode);
|
13
13
|
}
|
14
|
-
|
14
|
+
typeof rm === 'object' && rm.mode(cachedMode === 'dark' && isDarkMode)
|
15
15
|
}
|
16
16
|
initTheme()
|
17
17
|
when "dark"
|
@@ -22,7 +22,7 @@ case theme.display_mode.type
|
|
22
22
|
document.documentElement.setAttribute('data-theme', 'dark');
|
23
23
|
else
|
24
24
|
document.documentElement.setAttribute('data-theme', cachedMode);
|
25
|
-
|
25
|
+
typeof rm === 'object' && rm.mode(cachedMode === undefined || cachedMode === 'dark')
|
26
26
|
}
|
27
27
|
initTheme()
|
28
28
|
when "light"
|
@@ -33,6 +33,6 @@ case theme.display_mode.type
|
|
33
33
|
document.documentElement.setAttribute('data-theme', 'light');
|
34
34
|
else
|
35
35
|
document.documentElement.setAttribute('data-theme', cachedMode);
|
36
|
-
|
36
|
+
typeof rm === 'object' && rm.mode(cachedMode === 'dark')
|
37
37
|
}
|
38
38
|
initTheme()
|
@@ -3,17 +3,18 @@ div#console
|
|
3
3
|
i.solitude.st-close-fill
|
4
4
|
if theme.console_plus
|
5
5
|
div.console-card-group
|
6
|
-
if theme.
|
6
|
+
if theme.recent_comments.enable && theme.recent_comments.img
|
7
7
|
div.console-card-group-left
|
8
8
|
div.console-card#card-newest-comments(onclick="sco.hideConsole()")
|
9
9
|
div.card-content
|
10
10
|
div.author-content-item-tips= _p('console.comment_tip')
|
11
11
|
div.author-content-item-title
|
12
12
|
| #{_p('console.comment_title')}
|
13
|
-
if theme.recent_comments.enable
|
13
|
+
if theme.recent_comments.enable
|
14
14
|
a.recent-comment-more(href=url_for(theme.recent_comments.page) title=_p('console.recent_comment_more'))
|
15
15
|
i.solitude.st-right-btn-fill
|
16
|
-
|
16
|
+
a.recent-comment-image(href=url_for(theme.recent_comments.page))
|
17
|
+
img(src=theme.recent_comments.img)
|
17
18
|
|
18
19
|
div.console-card-group-right
|
19
20
|
div.console-card.tags(onclick="sco.hideConsole()")
|
@@ -18,6 +18,8 @@ div
|
|
18
18
|
|
19
19
|
if theme.mermaid
|
20
20
|
script(src=url_for(theme.cdn.mermaid_js))
|
21
|
+
if theme.post.share.enable && theme.post.share.list && theme.post.share.list.includes('qrcode')
|
22
|
+
script(src=url_for(theme.cdn.qrcode))
|
21
23
|
|
22
24
|
if theme.display_mode.universe
|
23
25
|
script(src=url_for(theme.cdn.universe_js))
|
@@ -105,9 +107,6 @@ div
|
|
105
107
|
if theme.footer.randomlink
|
106
108
|
include ../widgets/randomlink.pug
|
107
109
|
|
108
|
-
// newest comment
|
109
|
-
include ../widgets/third-party/news-comment/newest-comment.pug
|
110
|
-
|
111
110
|
// pjax
|
112
111
|
!= partial("includes/widgets/third-party/pjax", {}, {cache: true})
|
113
112
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
each item in theme.verify_site || []
|
2
2
|
meta(name=item.name, content=item.content)
|
3
3
|
|
4
|
+
link(rel="canonical" href=urlNoIndex())
|
4
5
|
link(rel="stylesheet", href=url_for(theme.cdn.solitude_css))
|
5
6
|
|
6
7
|
// aplayer
|
@@ -27,7 +28,7 @@ include ../head/pwa.pug
|
|
27
28
|
|
28
29
|
script.
|
29
30
|
console.log(
|
30
|
-
"%c Program: Hexo %c Theme: Solitude %c Version: v1.
|
31
|
+
"%c Program: Hexo %c Theme: Solitude %c Version: v1.12.1",
|
31
32
|
"border-radius:5px 0 0 5px;padding: 5px 10px;color:white;background:#ff3842;",
|
32
33
|
"padding: 5px 10px;color:white;background:#3e9f50;",
|
33
34
|
"padding: 5px 10px;color:white;background:#0084ff;border-radius:0 5px 5px 0",
|
@@ -39,7 +40,7 @@ if theme.memorial.enable
|
|
39
40
|
mdate = (mdate.split(","));
|
40
41
|
let ndate = new Date();
|
41
42
|
for (let i of mdate) {
|
42
|
-
if (i
|
43
|
+
if (i === (ndate.getMonth()+1) + "-" + (ndate.getDate())) {
|
43
44
|
document.documentElement.classList.add('memorial');
|
44
45
|
}
|
45
46
|
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
.card-widget.card-recent-comment
|
2
|
+
.item-headline
|
3
|
+
i.solitude.st-chat-fill
|
4
|
+
span= _p('aside.newcomment')
|
5
|
+
if theme.recent_comments.enable
|
6
|
+
a.recent-comment-more(href=url_for(theme.recent_comments.page) title=_p('console.recent_comment_more'))
|
7
|
+
i.solitude.st-right-btn-fill
|
8
|
+
.aside-list
|
9
|
+
include ../third-party/news-comment/newest-comment.pug
|
@@ -10,7 +10,24 @@ if recommends
|
|
10
10
|
img(src=item.cover, alt=item.title)
|
11
11
|
.blog-slider__content
|
12
12
|
span.blog-slider__title=item.title
|
13
|
-
|
13
|
+
case theme.index_post_list.content
|
14
|
+
when false
|
15
|
+
break
|
16
|
+
when 1
|
17
|
+
span.blog-slider__desc= item.description
|
18
|
+
when 2
|
19
|
+
if item.description
|
20
|
+
span.blog-slider__desc= item.description
|
21
|
+
else
|
22
|
+
- const content = strip_html(item.content)
|
23
|
+
- let expert = content.substring(0, theme.index_post_list.length).replace(/\d+/g, '').replace(//g, '').replace(/&#x/g, '')
|
24
|
+
- content.length > theme.index_post_list.length ? expert += ' ...' : ''
|
25
|
+
.span.blog-slider__desc= expert
|
26
|
+
default
|
27
|
+
- const content = strip_html(item.content)
|
28
|
+
- let expert = content.substring(0, theme.index_post_list.length).replace(/\d+/g, '').replace(//g, '').replace(/&#x/g, '')
|
29
|
+
- content.length > theme.index_post_list.length ? expert += ' ...' : ''
|
30
|
+
.span.blog-slider__desc= expert
|
14
31
|
div.article-meta-wrap
|
15
32
|
span.article-meta.tags
|
16
33
|
each tag in item.tags.data
|
@@ -29,12 +29,12 @@ mixin info
|
|
29
29
|
.content!= post.description
|
30
30
|
else
|
31
31
|
- const content = strip_html(post.content)
|
32
|
-
- let expert = content.substring(0, theme.index_post_list.length)
|
32
|
+
- let expert = content.substring(0, theme.index_post_list.length).replace(/\d+/g, '').replace(//g, '').replace(/&#x/g, '')
|
33
33
|
- content.length > theme.index_post_list.length ? expert += ' ...' : ''
|
34
34
|
.content!= expert
|
35
35
|
default
|
36
36
|
- const content = strip_html(post.content)
|
37
|
-
- let expert = content.substring(0, theme.index_post_list.length)
|
37
|
+
- let expert = content.substring(0, theme.index_post_list.length).replace(/\d+/g, '').replace(//g, '').replace(/&#x/g, '')
|
38
38
|
- content.length > theme.index_post_list.length ? expert += ' ...' : ''
|
39
39
|
.content!= expert
|
40
40
|
|
@@ -73,8 +73,9 @@ div.recent-post-item(onclick="pjax.loadUrl('" + url_for(post.path) + "')")
|
|
73
73
|
|
74
74
|
|
75
75
|
if theme.google_adsense && theme.google_adsense.enable && theme.google_adsense.auto_ads === false && theme.google_adsense.post_card
|
76
|
+
- var ads_height = theme.index_post_list.direction === 'column' ? '401px;' : '280px;'
|
76
77
|
if (index + 1) % 3 === 0
|
77
78
|
div.recent-post-item.google-ads-warp
|
78
|
-
ins.adsbygoogle(style="display:block; text-align:center; min-width: 100%; height:
|
79
|
+
ins.adsbygoogle(style="display:block; text-align:center; min-width: 100%; height:" + ads_height, data-ad-layout="in-article", data-ad-format="fluid", hide-unfilled="true", data-ad-client=theme.google_adsense.client, data-ad-slot=theme.google_adsense.slot)
|
79
80
|
script.
|
80
81
|
(adsbygoogle = window.adsbygoogle || []).push({});
|
@@ -15,6 +15,52 @@
|
|
15
15
|
a.reward-link-button(href=url_for(theme.post.rss))
|
16
16
|
i.solitude.st-plant-fill
|
17
17
|
= _p('footer.rss')
|
18
|
+
if theme.post.share.enable
|
19
|
+
.social-share
|
20
|
+
- const path = config.url + url_for(page.path);
|
21
|
+
- const encodedPath = encodeURIComponent(path);
|
22
|
+
- const encodedTitle = encodeURIComponent(page.title);
|
23
|
+
- const encodedDescription = encodeURIComponent(page.description);
|
24
|
+
- const encodedIcon = encodeURIComponent(page.cover || theme.site.icon);
|
25
|
+
each item in theme.post.share.list || []
|
26
|
+
case item
|
27
|
+
when 'qq'
|
28
|
+
a.social-share-ico.icon-qq(href=`https://connect.qq.com/widget/shareqq/index.html?url=${encodedPath}&title=${encodedTitle}&desc=${encodedDescription}&summary=${encodedDescription}&site=${encodedTitle}&pics=${encodedIcon}` title=_p('post.share.qq'))
|
29
|
+
i.solitude.st-qq-fill
|
30
|
+
when 'weibo'
|
31
|
+
a.social-share-ico.icon-weibo(href=`http://service.weibo.com/share/share.php?url=${encodedPath}&title=${encodedTitle}&pic=${encodedIcon}` title=_p('post.share.weibo'))
|
32
|
+
i.solitude.st-weibo-fill
|
33
|
+
when 'telegram'
|
34
|
+
a.social-share-ico.icon-telegram(href=`https://t.me/share/url?url=${encodedPath}&text=${encodedTitle}` title=_p('post.share.telegram'))
|
35
|
+
i.solitude.st-telegram-fill
|
36
|
+
when 'whatsapp'
|
37
|
+
a.social-share-ico.icon-whatsapp(href=`https://api.whatsapp.com/send?text=${encodedTitle} ${encodedPath}` title=_p('post.share.whatsapp'))
|
38
|
+
i.solitude.st-whatsapp-fill
|
39
|
+
when 'linkedin'
|
40
|
+
a.social-share-ico.icon-linkedin(href=`https://www.linkedin.com/shareArticle?mini=true&url=${encodedPath}&title=${encodedTitle}&summary=${encodedDescription}&source=${encodedTitle}` title=_p('post.share.linkedin'))
|
41
|
+
i.solitude.st-linkedin-box-fill
|
42
|
+
when 'facebook'
|
43
|
+
a.social-share-ico.icon-facebook(href=`https://www.facebook.com/sharer/sharer.php?u=${encodedPath}` title=_p('post.share.facebook'))
|
44
|
+
i.solitude.st-facebook-fill
|
45
|
+
when 'twitter'
|
46
|
+
a.social-share-ico.icon-twitter(href=`https://twitter.com/intent/tweet?url=${encodedPath}&text=${encodedTitle}` title=_p('post.share.twitter'))
|
47
|
+
i.solitude.st-twitter-x-fill
|
48
|
+
when 'link'
|
49
|
+
.social-share-ico.icon-link(onclick=`utils.copy("${path}")` title=_p('post.share.link'))
|
50
|
+
i.solitude.st-links-line
|
51
|
+
when 'qrcode'
|
52
|
+
.social-share-ico.icon-qrcode(title=_p('post.share.qrcode'))
|
53
|
+
i.solitude.st-qr-code-fill
|
54
|
+
.share-main
|
55
|
+
.share-main-all
|
56
|
+
#qrcode
|
57
|
+
.reward-dec=_p('post.share.qrcode')
|
58
|
+
script(pjax).
|
59
|
+
typeof QRCode === 'function' && new QRCode(document.getElementById("qrcode"), '!{path}');
|
60
|
+
window.addEventListener('DOMContentLoaded', () => {
|
61
|
+
new QRCode(document.getElementById("qrcode"), '!{path}');
|
62
|
+
});
|
63
|
+
|
18
64
|
if copyright.enable || page.copyright
|
19
65
|
.post-copyright__notice
|
20
66
|
span.post-copyright-info
|
@@ -3,23 +3,23 @@ nav.needEndHide.pagination-post#pagination
|
|
3
3
|
.prev-post.pull-left
|
4
4
|
a(href=url_for(page.prev.path))
|
5
5
|
.pagination-info
|
6
|
-
.label
|
6
|
+
.label=_p('post.nav.prev')
|
7
7
|
.prev_info= page.prev.title
|
8
8
|
.next-post.pull-right
|
9
9
|
a(href=url_for(page.next.path))
|
10
10
|
.pagination-info
|
11
|
-
.label
|
11
|
+
.label=_p('post.nav.next')
|
12
12
|
.next_info= page.next.title
|
13
13
|
else
|
14
14
|
if !page.prev && page.next
|
15
15
|
.next-post.pull-full
|
16
16
|
a(href=url_for(page.next.path))
|
17
17
|
div.pagination-info
|
18
|
-
.label
|
18
|
+
.label=_p('post.nav.next')
|
19
19
|
.next_info= page.next.title
|
20
20
|
if !page.next && page.prev
|
21
21
|
.prev-post.pull-full
|
22
22
|
a(href=url_for(page.prev.path))
|
23
23
|
.pagination-info
|
24
|
-
.label
|
24
|
+
.label=_p('post.nav.prev')
|
25
25
|
.prev_info= page.prev.title
|
@@ -0,0 +1,60 @@
|
|
1
|
+
- const { repo, repo_id, category_id, theme:themes, option } = theme.giscus
|
2
|
+
- const giscusUrl = theme.cdn.giscus || 'https://giscus.app/client.js'
|
3
|
+
- const giscusOriginUrl = new URL(giscusUrl).origin
|
4
|
+
- const { use, lazyload } = theme.comment
|
5
|
+
|
6
|
+
script.
|
7
|
+
(()=>{
|
8
|
+
const getGiscusTheme = theme => {
|
9
|
+
return theme === 'dark' ? '!{themes.dark}' : '!{themes.light}'
|
10
|
+
}
|
11
|
+
|
12
|
+
const loadGiscus = () => {
|
13
|
+
const config = Object.assign({
|
14
|
+
src: '!{giscusUrl}',
|
15
|
+
'data-repo': '!{repo}',
|
16
|
+
'data-repo-id': '!{repo_id}',
|
17
|
+
'data-category-id': '!{category_id}',
|
18
|
+
'data-mapping': 'pathname',
|
19
|
+
'data-theme': getGiscusTheme(document.documentElement.getAttribute('data-theme')),
|
20
|
+
'data-reactions-enabled': '1',
|
21
|
+
crossorigin: 'anonymous',
|
22
|
+
async: true
|
23
|
+
},!{JSON.stringify(option)})
|
24
|
+
|
25
|
+
const ele = document.createElement('script')
|
26
|
+
for (let key in config) {
|
27
|
+
ele.setAttribute(key, config[key])
|
28
|
+
}
|
29
|
+
document.getElementById('giscus-wrap').appendChild(ele)
|
30
|
+
}
|
31
|
+
|
32
|
+
const changeGiscusTheme = theme => {
|
33
|
+
const sendMessage = message => {
|
34
|
+
const iframe = document.querySelector('iframe.giscus-frame')
|
35
|
+
if (!iframe) return
|
36
|
+
iframe.contentWindow.postMessage({ giscus: message }, '!{giscusOriginUrl}')
|
37
|
+
}
|
38
|
+
|
39
|
+
sendMessage({
|
40
|
+
setConfig: {
|
41
|
+
theme: getGiscusTheme(theme)
|
42
|
+
}
|
43
|
+
});
|
44
|
+
}
|
45
|
+
|
46
|
+
utils.addGlobalFn('themeChange', changeGiscusTheme, 'giscus')
|
47
|
+
|
48
|
+
if ('!{use[0]}' === 'Giscus' || !!{lazyload}) {
|
49
|
+
if (!{lazyload}) {
|
50
|
+
const giscusWrap = document.getElementById('giscus-wrap')
|
51
|
+
if (giscusWrap) {
|
52
|
+
utils.loadComment(giscusWrap, loadGiscus)
|
53
|
+
}
|
54
|
+
} else {
|
55
|
+
loadGiscus()
|
56
|
+
}
|
57
|
+
} else {
|
58
|
+
window.loadOtherComment = loadGiscus
|
59
|
+
}
|
60
|
+
})()
|
@@ -9,4 +9,6 @@ each name in use
|
|
9
9
|
when 'Valine'
|
10
10
|
!=partial('includes/widgets/third-party/comments/valine', {}, {cache: true})
|
11
11
|
when 'Artalk'
|
12
|
-
!=partial('includes/widgets/third-party/comments/artalk', {}, {cache: true})
|
12
|
+
!=partial('includes/widgets/third-party/comments/artalk', {}, {cache: true})
|
13
|
+
when 'Giscus'
|
14
|
+
!=partial('includes/widgets/third-party/comments/giscus', {}, {cache: true})
|
@@ -1,8 +1,8 @@
|
|
1
1
|
- const { server, site, option } = theme.artalk
|
2
2
|
- const avatarCdn = theme.comment.avatar
|
3
3
|
|
4
|
-
script.
|
5
|
-
|
4
|
+
script(pjax).
|
5
|
+
(() => {
|
6
6
|
const changeContent = content => {
|
7
7
|
if (content === '') return content;
|
8
8
|
const replacements = [
|
@@ -24,15 +24,14 @@ script.
|
|
24
24
|
}
|
25
25
|
];
|
26
26
|
content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content);
|
27
|
-
return content.length > 150 ? content.substring(0,
|
27
|
+
return content.length > 150 ? content.substring(0, 100) + '...' : content;
|
28
28
|
};
|
29
29
|
|
30
30
|
const generateHtml = (array, asideList) => {
|
31
31
|
asideList.innerHTML = array.length ? array.map(item => `
|
32
32
|
<div class='aside-list-item'>
|
33
|
-
<div
|
33
|
+
<div class='thumbnail'>
|
34
34
|
<img src='${item.avatar}' alt='${item.nick}'>
|
35
|
-
<div class='name'><span>${item.nick}</span></div>
|
36
35
|
</div>
|
37
36
|
<div class='content'>
|
38
37
|
<div class='comment' onclick='pjax.loadUrl("${item.url}")'>${item.content}</div>
|
@@ -68,7 +67,7 @@ script.
|
|
68
67
|
nick: e.nick,
|
69
68
|
url: e.page_key + `#atk-comment-${e.id}`,
|
70
69
|
date: e.date,
|
71
|
-
})).slice(0,
|
70
|
+
})).slice(0, !{limit});
|
72
71
|
utils.saveToLocal.set('artalk-newest-comments', artalk, !{theme.comment.newest_comment.storage});
|
73
72
|
generateHtml(artalk, asideList);
|
74
73
|
}).catch(error => {
|
@@ -78,6 +77,7 @@ script.
|
|
78
77
|
};
|
79
78
|
|
80
79
|
const newestCommentInit = (asideList) => {
|
80
|
+
if (!asideList) return;
|
81
81
|
const data = utils.saveToLocal.get('artalk-newest-comments');
|
82
82
|
if (data) {
|
83
83
|
generateHtml(data, asideList);
|
@@ -86,9 +86,7 @@ script.
|
|
86
86
|
}
|
87
87
|
};
|
88
88
|
|
89
|
-
const $asideList = document.querySelector('
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
}
|
94
|
-
});
|
89
|
+
const $asideList = document.querySelector('.card-recent-comment .aside-list');
|
90
|
+
window.addEventListener('DOMContentLoaded', () => newestCommentInit($asideList), false)
|
91
|
+
window.addEventListener('pjax:complete', () => newestCommentInit(document.querySelector('.card-recent-comment .aside-list')), false);
|
92
|
+
})();
|
@@ -1,10 +1,11 @@
|
|
1
|
-
|
1
|
+
- var limit = theme.aside.newest_comment.limit ? theme.aside.newest_comment.limit : 5
|
2
|
+
if theme.comment.use
|
2
3
|
case theme.comment.use[0]
|
3
4
|
when 'Twikoo'
|
4
|
-
!=partial('includes/widgets/third-party/news-comment/twikoo', {}, {cache: true})
|
5
|
+
!=partial('includes/widgets/third-party/news-comment/twikoo', {limit}, {cache: true})
|
5
6
|
when 'Waline'
|
6
|
-
!=partial('includes/widgets/third-party/news-comment/waline', {}, {cache: true})
|
7
|
+
!=partial('includes/widgets/third-party/news-comment/waline', {limit}, {cache: true})
|
7
8
|
when 'Valine'
|
8
|
-
!=partial('includes/widgets/third-party/news-comment/valine', {}, {cache: true})
|
9
|
+
!=partial('includes/widgets/third-party/news-comment/valine', {limit}, {cache: true})
|
9
10
|
when 'Artalk'
|
10
|
-
!=partial('includes/widgets/third-party/news-comment/artalk', {}, {cache: true})
|
11
|
+
!=partial('includes/widgets/third-party/news-comment/artalk', {limit}, {cache: true})
|
@@ -1,5 +1,5 @@
|
|
1
1
|
script.
|
2
|
-
|
2
|
+
(() => {
|
3
3
|
const changeContent = (content) => {
|
4
4
|
if (!content) return '';
|
5
5
|
const replacements = [
|
@@ -12,14 +12,13 @@ script.
|
|
12
12
|
{regex: /<[^>]+>/g, replacement: ''}
|
13
13
|
]
|
14
14
|
content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content)
|
15
|
-
return content.length > 150 ? `${content.substring(0,
|
15
|
+
return content.length > 150 ? `${content.substring(0, 100)}...` : content
|
16
16
|
}
|
17
17
|
const generateHtml = (array) => {
|
18
18
|
const html = array.map(item => `
|
19
19
|
<div class='aside-list-item'>
|
20
|
-
<div
|
20
|
+
<div class='thumbnail'>
|
21
21
|
<img src='${item.avatar}' alt='${item.nick}'>
|
22
|
-
<div class='name'><span>${item.nick}</span></div>
|
23
22
|
</div>
|
24
23
|
<div class='content'>
|
25
24
|
<div class='comment' onclick='pjax.loadUrl("${item.url}")'>${item.content}</div>
|
@@ -27,7 +26,7 @@ script.
|
|
27
26
|
</div>
|
28
27
|
</div>
|
29
28
|
`).join('')
|
30
|
-
document.querySelector('
|
29
|
+
document.querySelector('.card-recent-comment .aside-list').innerHTML = array.length ? html : "!{_p('newest_comment.zero')}"
|
31
30
|
window.lazyLoadInstance?.update()
|
32
31
|
window.pjax?.refresh()
|
33
32
|
sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
|
@@ -37,7 +36,7 @@ script.
|
|
37
36
|
twikoo.getRecentComments({
|
38
37
|
envId: '!{theme.twikoo.envId}',
|
39
38
|
region: '',
|
40
|
-
pageSize:
|
39
|
+
pageSize: !{limit},
|
41
40
|
includeReply: true
|
42
41
|
}).then(res => {
|
43
42
|
const twikooArray = res.map(e => ({
|
@@ -51,7 +50,7 @@ script.
|
|
51
50
|
generateHtml(twikooArray)
|
52
51
|
}).catch((err) => {
|
53
52
|
console.error(err);
|
54
|
-
document.querySelector('
|
53
|
+
document.querySelector('.card-recent-comment .aside-list').textContent = "!{_p('newest_comment.error')}"
|
55
54
|
})
|
56
55
|
}
|
57
56
|
if (typeof twikoo === 'object') {
|
@@ -61,8 +60,10 @@ script.
|
|
61
60
|
}
|
62
61
|
}
|
63
62
|
const newestCommentInit = () => {
|
63
|
+
if (!document.querySelector('.card-recent-comment')) return
|
64
64
|
const data = utils.saveToLocal.get('twikoo-newest-comment')
|
65
65
|
data ? generateHtml(data) : getComment()
|
66
66
|
}
|
67
|
-
newestCommentInit
|
68
|
-
|
67
|
+
window.addEventListener('DOMContentLoaded', newestCommentInit, false)
|
68
|
+
window.addEventListener('pjax:complete', newestCommentInit, false);
|
69
|
+
})()
|
@@ -1,5 +1,5 @@
|
|
1
1
|
script.
|
2
|
-
|
2
|
+
(() => {
|
3
3
|
const emojiReg = /:[a-z0-9_\u4e00-\u9fa5]+:/g
|
4
4
|
const changeContent = (content) => {
|
5
5
|
if (content === '') return content;
|
@@ -16,11 +16,12 @@ script.
|
|
16
16
|
|
17
17
|
content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content);
|
18
18
|
|
19
|
-
return content.length > 150 ? content.substring(0,
|
19
|
+
return content.length > 150 ? content.substring(0, 100) + '...' : content;
|
20
20
|
}
|
21
21
|
|
22
|
-
const $asideList = document.querySelector('
|
22
|
+
const $asideList = document.querySelector('.card-recent-comment .aside-list')
|
23
23
|
const newestCommentInit = () => {
|
24
|
+
if (!document.querySelector('.card-recent-comment')) return
|
24
25
|
const data = utils.saveToLocal.get('valine-newest-comment')
|
25
26
|
if (data) {
|
26
27
|
generateHtml(data)
|
@@ -42,7 +43,7 @@ script.
|
|
42
43
|
await fetch('!{theme.valine.serverURLs}/1.1/classes/Comment?limit=8&order=-createdAt', settings).then(res => res.json())
|
43
44
|
.then(async result => {
|
44
45
|
let ls = []
|
45
|
-
for (const i of result.results.slice(0,
|
46
|
+
for (const i of result.results.slice(0, !{limit})) {
|
46
47
|
if (emojiReg.test(i.comment)) continue
|
47
48
|
ls.push({
|
48
49
|
content: changeContent(i.comment),
|
@@ -61,7 +62,7 @@ script.
|
|
61
62
|
}
|
62
63
|
|
63
64
|
const generateHtml = array => {
|
64
|
-
const $dom = document.querySelector('
|
65
|
+
const $dom = document.querySelector('.card-recent-comment .aside-list')
|
65
66
|
$dom.innerHTML = array.length ? array.map(item => `
|
66
67
|
<div class='aside-list-item'>
|
67
68
|
<div onclick='pjax.loadUrl(\"${item.url}\")' class='thumbnail'>
|
@@ -79,5 +80,6 @@ script.
|
|
79
80
|
sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
|
80
81
|
}
|
81
82
|
|
82
|
-
newestCommentInit
|
83
|
-
|
83
|
+
window.addEventListener('DOMContentLoaded', newestCommentInit, false)
|
84
|
+
window.addEventListener('pjax:complete', newestCommentInit, false);
|
85
|
+
})()
|
@@ -1,5 +1,5 @@
|
|
1
1
|
script.
|
2
|
-
|
2
|
+
(() => {
|
3
3
|
const changeContent = (content) => {
|
4
4
|
if (content === '') return content;
|
5
5
|
|
@@ -15,11 +15,12 @@ script.
|
|
15
15
|
|
16
16
|
content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content);
|
17
17
|
|
18
|
-
return content.length > 150 ? content.substring(0,
|
18
|
+
return content.length > 150 ? content.substring(0, 100) + '...' : content;
|
19
19
|
}
|
20
20
|
|
21
|
-
const $asideList = document.querySelector('
|
21
|
+
const $asideList = document.querySelector('.card-recent-comment .aside-list')
|
22
22
|
const newestCommentInit = () => {
|
23
|
+
if (!document.querySelector('.card-recent-comment')) return
|
23
24
|
const data = utils.saveToLocal.get('waline-newest-comment')
|
24
25
|
if (data) {
|
25
26
|
generateHtml(data)
|
@@ -29,7 +30,7 @@ script.
|
|
29
30
|
}
|
30
31
|
|
31
32
|
const getComment = async () => {
|
32
|
-
await fetch('!{theme.waline.envId}/api/comment?type=recent&count
|
33
|
+
await fetch('!{theme.waline.envId}/api/comment?type=recent&count=!{limit}', {method: 'GET'}).then(async res => {
|
33
34
|
const result = await res.json()
|
34
35
|
const walineArray = result.data.map(e => {
|
35
36
|
return {
|
@@ -49,7 +50,7 @@ script.
|
|
49
50
|
}
|
50
51
|
|
51
52
|
const generateHtml = array => {
|
52
|
-
const $dom = document.querySelector('
|
53
|
+
const $dom = document.querySelector('.card-recent-comment .aside-list')
|
53
54
|
$dom.innerHTML = array.length ? array.map(item => `
|
54
55
|
<div class='aside-list-item'>
|
55
56
|
<div onclick='pjax.loadUrl("${item.url}")' class='thumbnail'>
|
@@ -67,5 +68,6 @@ script.
|
|
67
68
|
sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
|
68
69
|
}
|
69
70
|
|
70
|
-
newestCommentInit
|
71
|
-
|
71
|
+
window.addEventListener('DOMContentLoaded', newestCommentInit, false)
|
72
|
+
window.addEventListener('pjax:complete', newestCommentInit, false);
|
73
|
+
})()
|