hexo-theme-solitude 1.7.13 → 1.7.14

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.
Files changed (29) hide show
  1. package/_config.yml +7 -3
  2. package/languages/en.yml +4 -0
  3. package/languages/zh-CN.yml +4 -0
  4. package/languages/zh-TW.yml +4 -0
  5. package/layout/includes/head/config.pug +5 -0
  6. package/layout/includes/inject/body.pug +8 -11
  7. package/layout/includes/inject/head.pug +8 -35
  8. package/layout/includes/widgets/nav/right.pug +4 -41
  9. package/layout/includes/widgets/post/postMeta.pug +6 -0
  10. package/layout/includes/widgets/third-party/comments/artalk.pug +50 -0
  11. package/layout/includes/widgets/third-party/comments/comment.pug +3 -1
  12. package/layout/includes/widgets/third-party/comments/twikoo.pug +31 -2
  13. package/layout/includes/widgets/third-party/comments/valine.pug +44 -12
  14. package/layout/includes/widgets/third-party/comments/waline.pug +41 -14
  15. package/layout/includes/widgets/third-party/news-comment/artalk.pug +98 -0
  16. package/layout/includes/widgets/third-party/news-comment/newest-comment.pug +3 -1
  17. package/layout/includes/widgets/third-party/news-comment/twikoo.pug +7 -7
  18. package/layout/includes/widgets/third-party/news-comment/valine.pug +3 -3
  19. package/layout/includes/widgets/third-party/news-comment/waline.pug +3 -3
  20. package/package.json +1 -1
  21. package/plugins.yml +8 -4
  22. package/scripts/event/cdn.js +2 -12
  23. package/source/css/_layout/header.styl +48 -48
  24. package/source/js/barrage_comment.js +78 -0
  25. package/source/js/main.js +46 -1
  26. package/source/js/third_party/efu_ai.min.js +1 -1
  27. package/source/js/commentBarrage/twikoo.js +0 -151
  28. package/source/js/commentBarrage/valine.js +0 -156
  29. package/source/js/commentBarrage/waline.js +0 -153
package/_config.yml CHANGED
@@ -64,7 +64,6 @@ nav:
64
64
  right:
65
65
  random: false # 随机文章跳转 / random post button
66
66
  console: false #控制台 / console
67
- top: false # 进度球 / Progress Ball
68
67
  # 自定义按钮
69
68
  # custom button
70
69
  # 左至右
@@ -711,7 +710,7 @@ katex:
711
710
  # comment
712
711
  comment:
713
712
  enable: false
714
- type: # waline, twikoo
713
+ type: # waline, twikoo, valine, artalk
715
714
  commentBarrage: false # 热评开关 / Hot comment switch
716
715
  lazyload: true # 懒加载
717
716
  count: true # 评论数展示
@@ -740,7 +739,12 @@ comment:
740
739
  avatar:
741
740
  visitor: false
742
741
  option: # options list
743
-
742
+ # artalk 配置信息
743
+ # artalk settings
744
+ artalk:
745
+ server: # server url / 后端地址
746
+ site: # site name / 站点名
747
+ option: # options
744
748
 
745
749
  # 中控台扩展 : 最新评论 + 标签 + 文章
746
750
  console_plus: false
package/languages/en.yml CHANGED
@@ -101,6 +101,10 @@ console:
101
101
  switch_keyboard: Keyboard operation
102
102
  switch_music: Music switch
103
103
  archive_unit: Posts
104
+ newest_comment:
105
+ image: Image
106
+ link: Link
107
+ code: Code
104
108
 
105
109
  sidebar:
106
110
  function: Function
@@ -103,6 +103,10 @@ console:
103
103
  switch_keyboard: 键盘快捷键
104
104
  switch_music: 音乐开关
105
105
  archive_unit: 篇
106
+ newest_comment:
107
+ image: 图片
108
+ link: 链接
109
+ code: 代码
106
110
 
107
111
  sidebar:
108
112
  function: 功能
@@ -103,6 +103,10 @@ console:
103
103
  switch_keyboard: 鍵盤快捷鍵
104
104
  switch_music: 音樂開關
105
105
  archive_unit: 篇
106
+ newest_comment:
107
+ image: 圖片
108
+ link: 連結
109
+ code: 代碼
106
110
 
107
111
  sidebar:
108
112
  function: 功能
@@ -56,6 +56,11 @@
56
56
  item: '.vemojis i'
57
57
  }
58
58
  break
59
+ case "artalk":
60
+ comment.owo = {
61
+ body: '.atk-grp',
62
+ item: '.atk-item'
63
+ }
59
64
  default:
60
65
  break
61
66
  }
@@ -16,10 +16,6 @@ div
16
16
  script(src=url_for(theme.cdn.waterfall))
17
17
  script(src=url_for(theme.cdn.pjax))
18
18
 
19
- if theme.comment.enable && theme.comment.type === 'valine'
20
- // md5
21
- script(src=url_for(theme.cdn.blueimp_md5))
22
-
23
19
  if theme.mermaid
24
20
  script(src=url_for(theme.cdn.mermaid_js))
25
21
 
@@ -73,14 +69,15 @@ div
73
69
  case theme.comment.type
74
70
  when 'twikoo'
75
71
  script(src=url_for(theme.cdn.twikoo))
72
+ when 'waline'
73
+ script(src=url_for(theme.cdn.waline_js))
74
+ when 'valine'
75
+ script(src=url_for(theme.cdn.blueimp_md5))
76
+ script(src=url_for(theme.cdn.valine))
77
+ when 'artalk'
78
+ script(src=url_for(theme.cdn.artalk_js))
76
79
  if theme.comment.commentBarrage
77
- case theme.comment.type
78
- when 'twikoo'
79
- script(src=url_for(theme.cdn.twikoo_commentBarrage))
80
- when 'waline'
81
- script(src=url_for(theme.cdn.waline_commentBarrage))
82
- when 'valine'
83
- script(src=url_for(theme.cdn.valine_commentBarrage))
80
+ script(src=url_for(theme.cdn.commentBarrage))
84
81
 
85
82
  if theme.music.enable
86
83
  script(src=url_for(theme.cdn.music_js))
@@ -17,6 +17,13 @@ if theme.lightbox && theme.fancybox
17
17
  if theme.katex && theme.katex.enable
18
18
  link(rel="stylesheet", href=url_for(theme.cdn.katex))
19
19
 
20
+ if theme.comment.enable
21
+ case theme.comment.type
22
+ when 'waline'
23
+ link(rel="stylesheet" href=url_for(theme.cdn.waline_css))
24
+ when 'artalk'
25
+ link(rel="stylesheet" href=url_for(theme.cdn.artalk_css))
26
+
20
27
  // Open Graph
21
28
  include ../head/opengraph.pug
22
29
 
@@ -73,45 +80,11 @@ script.
73
80
  document.documentElement.classList.remove('hide-aside')
74
81
  }
75
82
  }
76
-
77
- win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
78
- const link = document.createElement('link')
79
- link.rel = 'stylesheet'
80
- link.href = url
81
- if (id) link.id = id
82
- link.onerror = reject
83
- link.onload = link.onreadystatechange = function () {
84
- const loadState = this.readyState
85
- if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
86
- link.onload = link.onreadystatechange = null
87
- resolve()
88
- }
89
- document.head.appendChild(link)
90
- })
91
-
92
- win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
93
- const script = document.createElement('script')
94
- script.src = url
95
- script.async = true
96
- script.onerror = reject
97
- script.onload = script.onreadystatechange = function () {
98
- const loadState = this.readyState
99
- if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
100
- script.onload = script.onreadystatechange = null
101
- resolve()
102
- }
103
-
104
- Object.keys(attr).forEach(key => {
105
- script.setAttribute(key, attr[key])
106
- })
107
-
108
- document.head.appendChild(script)
109
- })
110
83
  }
111
84
  )(window)
112
85
 
113
86
  console.log(
114
- "%c Program: Hexo %c Theme: Solitude %c Version: v1.7.13",
87
+ "%c Program: Hexo %c Theme: Solitude %c Version: v1.7.14",
115
88
  "border-radius:5px 0 0 5px;padding: 5px 10px;color:white;background:#ff3842;",
116
89
  "padding: 5px 10px;color:white;background:#3e9f50;",
117
90
  "border-radius:0 5px 5px 0;padding: 5px 10px;background:#0084ff;color:white;"
@@ -15,47 +15,10 @@ if theme.nav.right.console
15
15
  .nav-button#nav-console
16
16
  a.console_switchbutton(onclick="sco.showConsole()", title=_p('nav.console'), href="javascript:void(0);")
17
17
  i.solitude.st-dashboard-fill
18
- if theme.nav.right.top
19
- .nav-button#nav-totop(onclick="sco.toTop()")
20
- a.totopbtn
21
- i.solitude.st-arrow-up-line
22
- span#percent= "0"
23
-
24
- script.
25
- document.addEventListener('DOMContentLoaded', () => {
26
- const percent = () => {
27
- let scrollTop = document.documentElement.scrollTop || window.pageYOffset
28
- let totalHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight) - document.documentElement.clientHeight
29
- let scrollPercent = Math.round(scrollTop / totalHeight * 100)
30
- let percentElement = document.querySelector("#percent")
31
- let viewportBottom = window.scrollY + document.documentElement.clientHeight
32
- let remainingScroll = totalHeight - scrollTop
33
-
34
- if ((document.getElementById("post-comment") || document.getElementById("footer")).offsetTop < viewportBottom || scrollPercent > 90) {
35
- document.querySelector("#nav-totop").classList.add("long")
36
- percentElement.innerHTML = GLOBAL_CONFIG.lang.backtop
37
- } else {
38
- document.querySelector("#nav-totop").classList.remove("long")
39
- if (scrollPercent >= 0) {
40
- percentElement.innerHTML = scrollPercent + ""
41
- }
42
- }
43
-
44
- let elementsToHide = document.querySelectorAll(".needEndHide")
45
- if (remainingScroll < 100) {
46
- elementsToHide.forEach(function (element) {
47
- element.classList.add("hide")
48
- })
49
- } else {
50
- elementsToHide.forEach(function (element) {
51
- element.classList.remove("hide")
52
- })
53
- }
54
-
55
- window.onscroll = percent
56
- }
57
- percent()
58
- })
18
+ .nav-button#nav-totop(onclick="sco.toTop()")
19
+ a.totopbtn
20
+ i.solitude.st-arrow-up-line
21
+ span#percent= "0"
59
22
  #toggle-menu
60
23
  a.site-page
61
24
  i.solitude.st-menu-line
@@ -52,6 +52,9 @@
52
52
  span.leancloud_visitors(id=url_for(page.path))
53
53
  span.leancloud-visitors-count
54
54
  i.solitude.st-loading-line
55
+ when 'artalk'
56
+ span#ArtalkPV
57
+ i.solitude.st-loading-line
55
58
  else if theme.busuanzi
56
59
  span#busuanzi_value_page_pv
57
60
  i.solitude.st-loading-line
@@ -69,5 +72,8 @@
69
72
  when "valine"
70
73
  span.valine-comment-count(data-xid=url_for(page.path) itemprop="commentCount")
71
74
  i.solitude.st-loading-line
75
+ when 'artalk'
76
+ span.waline-comment-count#ArtalkCount
77
+ i.solitude.st-loading-line
72
78
 
73
79
  include ./wave
@@ -0,0 +1,50 @@
1
+ - const { server, site, option } = theme.comment.artalk
2
+ - const { lazyload, count } = theme.comment
3
+
4
+ script.
5
+ async function initComment() {
6
+ let artalkItem = null
7
+ const initArtalk = () => {
8
+ artalkItem = Artalk.init({
9
+ el: '#comment',
10
+ server: '!{server}',
11
+ site: "!{site}",
12
+ pageKey: location.pathname,
13
+ darkMode: document.documentElement.getAttribute('data-theme') === 'dark',
14
+ }, !{JSON.stringify(option)})
15
+
16
+ if (GLOBAL_CONFIG.lightbox === 'null') return
17
+ artalkItem.on('list-loaded', () => {
18
+ const array = []
19
+ artalkItem.ctx.get('list').getCommentNodes().forEach(comment => {
20
+ array.push({
21
+ nick: comment.data.nick,
22
+ content: comment.data.content_marked,
23
+ mailMd5: comment.data.email_encrypted,
24
+ })
25
+ const $content = comment.getRender().$content
26
+ utils.lightbox($content.querySelectorAll('img:not([atk-emoticon])'))
27
+ sco.owoBig()
28
+ })
29
+ GLOBAL_CONFIG.comment.commentBarrage && PAGE_CONFIG.comment && initializeCommentBarrage(array)
30
+ })
31
+
32
+ const destroyArtalk = () => {
33
+ artalkItem.destroy()
34
+ }
35
+
36
+ utils.addGlobalFn('pjax', destroyArtalk, 'destroyArtalk')
37
+ }
38
+
39
+ const artalkChangeMode = theme => {
40
+ const artalkWrap = document.getElementById('comment')
41
+ console.log(artalkWrap, artalkWrap.children.length)
42
+ if (!(artalkWrap && artalkWrap.children.length)) return
43
+ const isDark = theme === 'dark'
44
+ artalkItem.setDarkMode(!isDark)
45
+ }
46
+
47
+ utils.addGlobalFn('themeChange', artalkChangeMode, 'artalk')
48
+
49
+ initArtalk()
50
+ }
@@ -12,4 +12,6 @@
12
12
  when 'waline'
13
13
  !=partial('includes/widgets/third-party/comments/waline',{}, {cache: true})
14
14
  when 'valine'
15
- !=partial('includes/widgets/third-party/comments/valine',{}, {cache: true})
15
+ !=partial('includes/widgets/third-party/comments/valine',{}, {cache: true})
16
+ when 'artalk'
17
+ !=partial('includes/widgets/third-party/comments/artalk',{}, {cache: true})
@@ -1,12 +1,13 @@
1
1
  script.
2
2
  async function initComment() {
3
- var initOptions = Object.assign(
3
+ const initOptions = Object.assign(
4
4
  !{JSON.stringify(theme.comment.twikoo || {})},
5
5
  {
6
6
  el: '#comment',
7
- onCommentLoaded: function () {
7
+ onCommentLoaded: async function () {
8
8
  GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
9
9
  sco.owoBig()
10
+ GLOBAL_CONFIG.comment.commentBarrage && PAGE_CONFIG.comment && initializeCommentBarrage(await fetchComments())
10
11
  },
11
12
  lang: '#{theme.comment.twikoo.lang}',
12
13
  }
@@ -28,4 +29,32 @@ script.
28
29
  document.getElementById('twikoo-count').innerText = '加载错误'
29
30
  }
30
31
  }
32
+
33
+ async function fetchComments() {
34
+ try {
35
+ const response = await fetch("!{theme.comment.twikoo.envId}", {
36
+ method: "POST",
37
+ headers: {
38
+ "Content-Type": "application/json"
39
+ },
40
+ body: JSON.stringify({
41
+ event: "COMMENT_GET",
42
+ accessToken: "!{theme.comment.twikoo.accessToken}",
43
+ url: window.location.pathname
44
+ })
45
+ });
46
+ if (!response.ok) {
47
+ throw new Error("HTTP error! status: " + response.status);
48
+ }
49
+ const data = await response.json();
50
+ return (data.data).map(item => Object.assign({
51
+ content: item.comment,
52
+ nick: item.nick,
53
+ mailMd5: item.mailMd5,
54
+ id: item.id
55
+ }))
56
+ } catch (error) {
57
+ console.error("An error occurred while fetching comments: ", error);
58
+ }
59
+ }
31
60
  }
@@ -7,7 +7,7 @@ if site.data.valine
7
7
 
8
8
  script.
9
9
  async function initComment() {
10
- const initValine = () => {
10
+ const initValine = async () => {
11
11
  const valine = new Valine(Object.assign({
12
12
  el: '#comment',
13
13
  appId: '#{appId}',
@@ -25,20 +25,52 @@ script.
25
25
  }
26
26
 
27
27
  sco.owoBig();
28
- }
29
-
30
- const loadValine = async () => {
31
- if (typeof Valine === 'function') initValine()
32
- else {
33
- await getScript('!{url_for(theme.cdn.valine)}')
34
- initValine()
35
- }
28
+ GLOBAL_CONFIG.comment.commentBarrage && PAGE_CONFIG.comment && initializeCommentBarrage(await fetchComments())
36
29
  }
37
30
 
38
31
  if (!!{lazyload}) {
39
- if (!{lazyload}) utils.loadComment(document.getElementById('comment'), loadValine)
40
- else setTimeout(loadValine, 0)
32
+ if (!{lazyload}) utils.loadComment(document.getElementById('comment'), initValine)
33
+ else setTimeout(initValine, 0)
41
34
  } else {
42
- await loadValine()
35
+ await initValine()
36
+ }
37
+
38
+ async function fetchComments() {
39
+ const url = new URL('#{serverURLs}' + '/1.1/classes/Comment');
40
+ const params = {
41
+ url: window.location.pathname,
42
+ order: '-createdAt'
43
+ };
44
+
45
+ for (const [key, value] of Object.entries(params)) {
46
+ url.searchParams.append(key, value);
47
+ }
48
+
49
+ try {
50
+ const response = await fetch(url, {
51
+ method: "GET",
52
+ headers: {
53
+ "X-LC-Id": "#{appId}",
54
+ "X-LC-Key": '#{appKey}',
55
+ "Content-Type": "application/json"
56
+ },
57
+ });
58
+
59
+ if (!response.ok) {
60
+ throw new Error(`HTTP error! status: ${response.status}`);
61
+ }
62
+
63
+ const data = await response.json();
64
+ return (data.results.filter(item => item.url === window.location.pathname)).map(item =>
65
+ Object.assign({
66
+ content: item.comment,
67
+ nick: item.nick,
68
+ mailMd5: md5(item.mail),
69
+ id: item.objectId
70
+ })
71
+ )
72
+ } catch (error) {
73
+ console.error("An error occurred while fetching comments: ", error);
74
+ }
43
75
  }
44
76
  }
@@ -19,27 +19,54 @@ script.
19
19
  const walineInstance = Fn(walineOptions);
20
20
 
21
21
  utils.addGlobalFn('pjax', () => walineInstance.destroy(), 'destroyWaline');
22
- }
23
22
 
24
- async function loadWalineCSSAndJS() {
25
- if (!walineInitFunction) {
26
- await getCSS('!{url_for(theme.cdn.waline_css)}');
27
- const {init} = await import('!{url_for(theme.cdn.waline_js)}');
28
- walineInitFunction = init || Waline.init;
29
- window.walineFn = walineInitFunction;
23
+ if (GLOBAL_CONFIG.lightbox) {
24
+ utils.lightbox(document.querySelectorAll('#comment .wl-content img:not(.wl-emoji)'));
30
25
  }
31
- initWaline(walineInitFunction);
26
+
27
+ sco.owoBig();
28
+
29
+ GLOBAL_CONFIG.comment.commentBarrage && PAGE_CONFIG.comment && initializeCommentBarrage(await fetchComments())
32
30
  }
33
31
 
34
32
  if (isLazyLoad) {
35
- utils.loadComment(document.getElementById('comment'),loadWalineCSSAndJS);
33
+ utils.loadComment(document.getElementById('comment'), initWaline(walineInitFunction));
36
34
  } else {
37
- await loadWalineCSSAndJS();
35
+ await initWaline(walineInitFunction);
38
36
  }
39
37
 
40
- if (GLOBAL_CONFIG.lightbox) {
41
- utils.lightbox(document.querySelectorAll('#comment .wl-content img:not(.wl-emoji)'));
42
- }
38
+ async function fetchComments() {
39
+ const url = new URL('#{envId}/api/comment');
40
+ const params = {
41
+ path: window.location.pathname,
42
+ sortBy: 'insertedAt_asc'
43
+ };
43
44
 
44
- sco.owoBig();
45
+ for (const [key, value] of Object.entries(params)) {
46
+ url.searchParams.append(key, value);
47
+ }
48
+
49
+ try {
50
+ const response = await fetch(url, {
51
+ method: "GET",
52
+ headers: {
53
+ "Content-Type": "application/json"
54
+ },
55
+ });
56
+
57
+ if (!response.ok) {
58
+ throw new Error(`HTTP error! status: ${response.status}`);
59
+ }
60
+
61
+ const data = await response.json();
62
+ return (data.data).map(item => Object.assign({
63
+ nick: item.nick,
64
+ mailId: item.avatar,
65
+ content: item.comment,
66
+ id: item.objectId
67
+ }))
68
+ } catch (error) {
69
+ console.error("An error occurred while fetching comments: ", error);
70
+ }
71
+ }
45
72
  }
@@ -0,0 +1,98 @@
1
+ - const { server, site, option } = theme.comment.artalk
2
+ - const avatarCdn = option !== null && option.gravatar && option.gravatar.mirror
3
+ - const avatarDefault = option !== null && option.gravatar && (option.gravatar.params || option.gravatar.default)
4
+
5
+ script.
6
+ window.addEventListener('load', () => {
7
+ const changeContent = (content) => {
8
+ if (content === '') return content
9
+
10
+ const replacements = [
11
+ {regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
12
+ {regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,replacement: '[!{_p("console.newest_comment.link")}]'},
13
+ {regex: /<pre><code>.*?<\/pre>/gi, replacement: '[!{_p("console.newest_comment.code")}]'},
14
+ {regex: /<[^>]+>/g, replacement: ''}
15
+ ];
16
+
17
+ content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content);
18
+
19
+ return content.length > 150 ? content.substring(0, 150) + '...' : content;
20
+ }
21
+
22
+ const $asideList = document.querySelector('#card-newest-comments .aside-list')
23
+
24
+ const generateHtml = array => {
25
+ $asideList.innerHTML = array.length ? array.map(item => `
26
+ <div class='aside-list-item'>
27
+ <a onclick='pjax.loadUrl("${item.url}")' class='thumbnail'>
28
+ <img src='${item.avatar}' alt='${item.nick}'>
29
+ <div class='name'><span>${item.nick}</span></div>
30
+ </a>
31
+ <div class='content'>
32
+ <a class='comment' onclick='pjax.loadUrl("${item.url}")'>${item.content}</a>
33
+ <time class="datetime" datetime="${item.date}"></time>
34
+ </div>
35
+ </div>
36
+ `).join('') : "!{_p('newest_comment.zero')}"
37
+ window.lazyLoadInstance && window.lazyLoadInstance.update()
38
+ window.pjax && window.pjax.refresh()
39
+ sco && sco.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
40
+ }
41
+
42
+ const getSetting = async () => {
43
+ try {
44
+ const res = await fetch('!{server}/api/v2/conf', {method: 'GET'})
45
+ return await res.json()
46
+ } catch (e) {
47
+ console.log(e)
48
+ }
49
+ }
50
+
51
+ const headerList = {
52
+ method: 'GET',
53
+ }
54
+
55
+ const searchParams = new URLSearchParams({
56
+ 'site_name': "!{site}",
57
+ 'limit': '6',
58
+ })
59
+
60
+ const getComment = async () => {
61
+ try {
62
+ const res = await fetch(`!{server}/api/v2/stats/latest_comments?${searchParams}`, headerList)
63
+ const result = await res.json()
64
+ const avatarStr = await getSetting()
65
+ const {mirror, params, default: defaults} = avatarStr.frontend_conf.gravatar
66
+ const avatarCdn = !{avatarCdn} || mirror
67
+ let avatarDefault = !{avatarDefault} || params || defaults
68
+ avatarDefault = avatarDefault.startsWith('d=') ? avatarDefault : `d=${avatarDefault}`
69
+ const artalk = result.data.map(function (e) {
70
+ return {
71
+ 'avatar': `${avatarCdn}${e.email_encrypted}?${avatarDefault}`,
72
+ 'content': changeContent(e.content_marked),
73
+ 'nick': e.nick,
74
+ 'url': e.page_url,
75
+ 'date': e.date,
76
+ }
77
+ })
78
+ saveToLocal.set('artalk-newest-comments', artalk, !{theme.comment.newest_comment.storage})
79
+ generateHtml(artalk)
80
+ } catch (e) {
81
+ console.log(e)
82
+ $asideList.textContent = "!{_p('newest_comment.error')}"
83
+ }
84
+ }
85
+
86
+ const newestCommentInit = () => {
87
+ if ($asideList) {
88
+ const data = saveToLocal.get('artalk-newest-comments')
89
+ if (data) {
90
+ generateHtml(data)
91
+ } else {
92
+ getComment()
93
+ }
94
+ }
95
+ }
96
+ newestCommentInit()
97
+ utils.addGlobalFn('pjaxComplete', newestCommentInit, 'artalk_newestComment')
98
+ })
@@ -5,4 +5,6 @@ if theme.comment.enable && theme.console_plus && theme.comment.newest_comment.en
5
5
  when 'waline'
6
6
  !=partial('includes/widgets/third-party/news-comment/waline',{}, {cache: true})
7
7
  when 'valine'
8
- !=partial('includes/widgets/third-party/news-comment/valine',{}, {cache: true})
8
+ !=partial('includes/widgets/third-party/news-comment/valine',{}, {cache: true})
9
+ when 'artalk'
10
+ !=partial('includes/widgets/third-party/news-comment/artalk',{}, {cache: true})
@@ -4,14 +4,14 @@ script.
4
4
  if (content === '') return content;
5
5
 
6
6
  const replacements = [
7
- {regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '<i class="solitude st-image-fill"></i>'},
8
- {regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, replacement: '<i class="solitude st-link"></i>'},
9
- {regex: /<pre><code>.*?<\/pre>/gi, replacement: '<i class="solitude st-code-box-fill"></i>'},
10
- {regex: /<p>|<\/p>/g, replacement: ''}
7
+ {regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
8
+ {
9
+ regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,
10
+ replacement: '[!{_p("console.newest_comment.link")}]'
11
+ },
12
+ {regex: /<pre><code>.*?<\/pre>/gi, replacement: '[!{_p("console.newest_comment.code")}]'},
13
+ {regex: /<[^>]+>/g, replacement: ''}
11
14
  ];
12
-
13
- console.log(content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '<i class="solitude st-gallery-image">'))
14
-
15
15
  content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content);
16
16
 
17
17
  return content.length > 150 ? content.substring(0, 150) + '...' : content;
@@ -4,9 +4,9 @@ script.
4
4
  if (content === '') return content;
5
5
 
6
6
  const replacements = [
7
- {regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '<i class="solitude st-image-fill"></i>'},
8
- {regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, replacement: '<i class="solitude st-link"></i>'},
9
- {regex: /```[\s\S]*?```/g, replacement: '<i class="solitude st-code-box-fill"></i>'},
7
+ {regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
8
+ {regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, replacement: '[!{_p("console.newest_comment.link")}]'},
9
+ {regex: /```[\s\S]*?```/g, replacement: '[!{_p("console.newest_comment.code")}]'},
10
10
  {regex: /<[^>]+>/g, replacement: ""}
11
11
  ];
12
12
 
@@ -4,9 +4,9 @@ script.
4
4
  if (content === '') return content;
5
5
 
6
6
  const replacements = [
7
- {regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '<i class="solitude st-image-fill"></i>'},
8
- {regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, replacement: '<i class="solitude st-link"></i>'},
9
- {regex: /<pre><code>.*?<\/pre>/gi, replacement: '<i class="solitude st-code-box-fill"></i>'},
7
+ {regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
8
+ {regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, replacement: '[!{_p("console.newest_comment.link")}]'},
9
+ {regex: /<pre><code>.*?<\/pre>/gi, replacement: '[!{_p("console.newest_comment.code")}]'},
10
10
  {regex: /<[^>]+>/g, replacement: ""}
11
11
  ];
12
12