hexo-theme-solitude 1.7.14 → 1.8.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/README.md +25 -25
- package/{README_zh-cn.md → README_en.md} +25 -25
- package/README_zh-tw.md +3 -3
- package/_config.yml +41 -34
- package/layout/includes/body/mode.pug +6 -3
- package/layout/includes/head/config.pug +0 -33
- package/layout/includes/head/page_config.pug +9 -0
- package/layout/includes/head.pug +4 -1
- package/layout/includes/inject/body.pug +1 -26
- package/layout/includes/inject/head.pug +11 -60
- package/layout/includes/widgets/post/postMeta.pug +24 -24
- package/layout/includes/widgets/third-party/comments/artalk.pug +29 -18
- package/layout/includes/widgets/third-party/comments/comment.pug +48 -12
- package/layout/includes/widgets/third-party/comments/twikoo.pug +61 -39
- package/layout/includes/widgets/third-party/comments/valine.pug +36 -38
- package/layout/includes/widgets/third-party/comments/waline.pug +39 -44
- package/layout/includes/widgets/third-party/news-comment/artalk.pug +57 -67
- package/layout/includes/widgets/third-party/news-comment/newest-comment.pug +6 -6
- package/layout/includes/widgets/third-party/news-comment/twikoo.pug +41 -48
- package/layout/includes/widgets/third-party/news-comment/valine.pug +5 -5
- package/layout/includes/widgets/third-party/news-comment/waline.pug +3 -3
- package/layout/includes/widgets/third-party/pjax.pug +1 -0
- package/package.json +1 -1
- package/plugins.yml +2 -2
- package/scripts/event/merge_config.js +280 -255
- package/scripts/filter/comment.js +13 -0
- package/source/css/_comments/comment.styl +73 -12
- package/source/css/_comments/valine.styl +1 -1
- package/source/css/_highlight/index.styl +1 -0
- package/source/css/_tags/link.styl +7 -2
- package/source/js/main.js +42 -18
- package/source/js/tw_cn.js +3 -3
- package/source/js/utils.js +62 -0
@@ -1,10 +1,10 @@
|
|
1
|
-
if theme.
|
2
|
-
case theme.comment.
|
3
|
-
when '
|
1
|
+
if theme.console_plus && theme.comment.newest_comment.enable
|
2
|
+
case theme.comment.use[0]
|
3
|
+
when 'Twikoo'
|
4
4
|
!=partial('includes/widgets/third-party/news-comment/twikoo',{}, {cache: true})
|
5
|
-
when '
|
5
|
+
when 'Waline'
|
6
6
|
!=partial('includes/widgets/third-party/news-comment/waline',{}, {cache: true})
|
7
|
-
when '
|
7
|
+
when 'Valine'
|
8
8
|
!=partial('includes/widgets/third-party/news-comment/valine',{}, {cache: true})
|
9
|
-
when '
|
9
|
+
when 'Artalk'
|
10
10
|
!=partial('includes/widgets/third-party/news-comment/artalk',{}, {cache: true})
|
@@ -1,8 +1,7 @@
|
|
1
1
|
script.
|
2
2
|
window.addEventListener('load', () => {
|
3
3
|
const changeContent = (content) => {
|
4
|
-
if (content
|
5
|
-
|
4
|
+
if (!content) return '';
|
6
5
|
const replacements = [
|
7
6
|
{regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
|
8
7
|
{
|
@@ -11,65 +10,59 @@ script.
|
|
11
10
|
},
|
12
11
|
{regex: /<pre><code>.*?<\/pre>/gi, replacement: '[!{_p("console.newest_comment.code")}]'},
|
13
12
|
{regex: /<[^>]+>/g, replacement: ''}
|
14
|
-
]
|
15
|
-
content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content)
|
16
|
-
|
17
|
-
return content.length > 150 ? content.substring(0, 150) + '...' : content;
|
13
|
+
]
|
14
|
+
content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content)
|
15
|
+
return content.length > 150 ? `${content.substring(0, 150)}...` : content
|
18
16
|
}
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
const generateHtml = (array) => {
|
18
|
+
const html = array.map(item => `
|
19
|
+
<div class='aside-list-item'>
|
20
|
+
<a onclick='pjax.loadUrl("${item.url}")' class='thumbnail'>
|
21
|
+
<img src='${item.avatar}' alt='${item.nick}'>
|
22
|
+
<div class='name'><span>${item.nick}</span></div>
|
23
|
+
</a>
|
24
|
+
<div class='content'>
|
25
|
+
<a class='comment' onclick='pjax.loadUrl("${item.url}")'>${item.content}</a>
|
26
|
+
<time class="datetime" datetime="${item.date}"></time>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
`).join('')
|
30
|
+
document.querySelector('#card-newest-comments .aside-list').innerHTML = array.length ? html : "!{_p('newest_comment.zero')}"
|
31
|
+
window.lazyLoadInstance?.update()
|
32
|
+
window.pjax?.refresh()
|
33
|
+
sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
|
34
|
+
}
|
35
|
+
const getComment = async () => {
|
23
36
|
const runTwikoo = () => {
|
24
37
|
twikoo.getRecentComments({
|
25
|
-
envId:
|
38
|
+
envId: '!{theme.twikoo.envId}',
|
26
39
|
region: '',
|
27
40
|
pageSize: 6,
|
28
41
|
includeReply: true
|
29
|
-
}).then(
|
42
|
+
}).then(res => {
|
30
43
|
const twikooArray = res.map(e => ({
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
44
|
+
content: changeContent(e.comment),
|
45
|
+
avatar: e.avatar,
|
46
|
+
nick: e.nick,
|
47
|
+
url: `${e.url}#${e.id}`,
|
48
|
+
date: new Date(e.created).toString()
|
36
49
|
}))
|
37
|
-
saveToLocal.set('twikoo-newest-comment', twikooArray, !{theme.comment.newest_comment.storage})
|
50
|
+
utils.saveToLocal.set('twikoo-newest-comment', twikooArray, !{theme.comment.newest_comment.storage})
|
38
51
|
generateHtml(twikooArray)
|
39
|
-
}).catch(
|
40
|
-
console.error(err)
|
41
|
-
|
52
|
+
}).catch((err) => {
|
53
|
+
console.error(err);
|
54
|
+
document.querySelector('#card-newest-comments .aside-list').textContent = "!{_p('newest_comment.error')}"
|
42
55
|
})
|
43
56
|
}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
const generateHtml = array => {
|
48
|
-
$asideList.innerHTML = array.length ? array.map(item => `
|
49
|
-
<div class='aside-list-item'>
|
50
|
-
<a onclick='pjax.loadUrl("${item.url}")' class='thumbnail'>
|
51
|
-
<img src='${item.avatar}' alt='${item.nick}'>
|
52
|
-
<div class='name'><span>${item.nick}</span></div>
|
53
|
-
</a>
|
54
|
-
<div class='content'>
|
55
|
-
<a class='comment' onclick='pjax.loadUrl("${item.url}")'>${item.content}</a>
|
56
|
-
<time class="datetime" datetime="${item.date}"></time>
|
57
|
-
</div>
|
58
|
-
</div>
|
59
|
-
`).join('') : "!{_p('newest_comment.zero')}"
|
60
|
-
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
61
|
-
window.pjax && window.pjax.refresh()
|
62
|
-
sco && sco.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
|
63
|
-
}
|
64
|
-
|
65
|
-
const newestCommentInit = () => {
|
66
|
-
const data = saveToLocal.get('twikoo-newest-comment')
|
67
|
-
if (data) {
|
68
|
-
generateHtml(data)
|
57
|
+
if (typeof twikoo === 'object') {
|
58
|
+
runTwikoo()
|
69
59
|
} else {
|
70
|
-
|
60
|
+
utils.getScript('!{url_for(theme.cdn.twikoo)}').then(runTwikoo)
|
71
61
|
}
|
72
62
|
}
|
73
|
-
|
63
|
+
const newestCommentInit = () => {
|
64
|
+
const data = utils.saveToLocal.get('twikoo-newest-comment')
|
65
|
+
data ? generateHtml(data) : getComment()
|
66
|
+
}
|
74
67
|
newestCommentInit()
|
75
68
|
})
|
@@ -17,7 +17,7 @@ script.
|
|
17
17
|
|
18
18
|
const $asideList = document.querySelector('#card-newest-comments .aside-list')
|
19
19
|
const newestCommentInit = () => {
|
20
|
-
const data = saveToLocal.get('valine-newest-comment')
|
20
|
+
const data = utils.saveToLocal.get('valine-newest-comment')
|
21
21
|
if (data) {
|
22
22
|
generateHtml(data)
|
23
23
|
} else {
|
@@ -30,13 +30,13 @@ script.
|
|
30
30
|
const settings = {
|
31
31
|
"method": "GET",
|
32
32
|
"headers": {
|
33
|
-
"X-LC-Id": '!{theme.
|
34
|
-
"X-LC-Key": '!{theme.
|
33
|
+
"X-LC-Id": '!{theme.valine.appId}',
|
34
|
+
"X-LC-Key": '!{theme.valine.appKey}',
|
35
35
|
"Content-Type": "application/json"
|
36
36
|
},
|
37
37
|
}
|
38
38
|
|
39
|
-
const res = await fetch('!{theme.
|
39
|
+
const res = await fetch('!{theme.valine.serverURLs}/1.1/classes/Comment?limit=8&order=-createdAt', settings)
|
40
40
|
const result = await res.json()
|
41
41
|
window.res = result
|
42
42
|
const valineArray = result.results.map(e => {
|
@@ -48,7 +48,7 @@ script.
|
|
48
48
|
'date': e.updatedAt || e.createdAt
|
49
49
|
}
|
50
50
|
})
|
51
|
-
saveToLocal.set('valine-newest-comment', valineArray, !{theme.comment.newest_comment.storage})
|
51
|
+
utils.saveToLocal.set('valine-newest-comment', valineArray, !{theme.comment.newest_comment.storage})
|
52
52
|
generateHtml(valineArray)
|
53
53
|
} catch (err) {
|
54
54
|
console.error(err)
|
@@ -17,7 +17,7 @@ script.
|
|
17
17
|
|
18
18
|
const $asideList = document.querySelector('#card-newest-comments .aside-list')
|
19
19
|
const newestCommentInit = () => {
|
20
|
-
const data = saveToLocal.get('waline-newest-comment')
|
20
|
+
const data = utils.saveToLocal.get('waline-newest-comment')
|
21
21
|
if (data) {
|
22
22
|
generateHtml(data)
|
23
23
|
} else {
|
@@ -27,7 +27,7 @@ script.
|
|
27
27
|
|
28
28
|
const getComment = async () => {
|
29
29
|
try {
|
30
|
-
const res = await fetch('!{theme.
|
30
|
+
const res = await fetch('!{theme.waline.envId}/api/comment?type=recent&count=8', {method: 'GET'})
|
31
31
|
const result = await res.json()
|
32
32
|
const walineArray = result.data.map(e => {
|
33
33
|
return {
|
@@ -38,7 +38,7 @@ script.
|
|
38
38
|
'date': e.time || e.insertedAt
|
39
39
|
}
|
40
40
|
})
|
41
|
-
saveToLocal.set('waline-newest-comment', walineArray, !{theme.comment.newest_comment.storage})
|
41
|
+
utils.saveToLocal.set('waline-newest-comment', walineArray, !{theme.comment.newest_comment.storage})
|
42
42
|
generateHtml(walineArray)
|
43
43
|
} catch (err) {
|
44
44
|
console.error(err)
|
package/package.json
CHANGED
package/plugins.yml
CHANGED