hexo-theme-solitude 1.3.1 → 1.4.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.
Files changed (274) hide show
  1. package/.github/FUNDING.yml +13 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.yml +107 -0
  3. package/.github/ISSUE_TEMPLATE/config.yml +13 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.yml +14 -0
  5. package/.github/workflows/npm-publish.yml +21 -0
  6. package/CONTRIBUTING.md +0 -0
  7. package/LICENSE +0 -0
  8. package/README.md +60 -43
  9. package/README_EN.md +60 -42
  10. package/_config.yml +602 -451
  11. package/languages/en-US.yml +4 -24
  12. package/languages/zh-CN.yml +4 -24
  13. package/layout/404.pug +1 -1
  14. package/layout/archive.pug +0 -0
  15. package/layout/category.pug +0 -0
  16. package/layout/includes/body/mode.pug +1 -6
  17. package/layout/includes/console.pug +3 -3
  18. package/layout/includes/footer.pug +16 -15
  19. package/layout/includes/head/config.pug +38 -30
  20. package/layout/includes/head/opengraph.pug +0 -0
  21. package/layout/includes/head/pwa.pug +5 -44
  22. package/layout/includes/head.pug +4 -2
  23. package/layout/includes/header.pug +0 -0
  24. package/layout/includes/inject/body.pug +114 -65
  25. package/layout/includes/inject/head.pug +11 -46
  26. package/layout/includes/layout.pug +1 -2
  27. package/layout/includes/loading.pug +0 -0
  28. package/layout/includes/mixins/articleSort.pug +0 -0
  29. package/layout/includes/mixins/pagination.pug +0 -0
  30. package/layout/includes/nav.pug +1 -1
  31. package/layout/includes/page/about.pug +1 -1
  32. package/layout/includes/page/categories.pug +0 -0
  33. package/layout/includes/page/default.pug +0 -0
  34. package/layout/includes/page/equipment.pug +0 -0
  35. package/layout/includes/page/links.pug +2 -2
  36. package/layout/includes/page/music.pug +0 -0
  37. package/layout/includes/page/not_configured.pug +0 -0
  38. package/layout/includes/page/rss.pug +3 -3
  39. package/layout/includes/page/says.pug +15 -15
  40. package/layout/includes/page/tags.pug +0 -0
  41. package/layout/includes/page/tlink.pug +1 -0
  42. package/layout/includes/recent-posts.pug +0 -0
  43. package/layout/includes/sidebar.pug +0 -0
  44. package/layout/includes/widgets/aside/aside.pug +6 -6
  45. package/layout/includes/widgets/aside/asideAllInfo.pug +0 -0
  46. package/layout/includes/widgets/aside/asideArchive.pug +0 -0
  47. package/layout/includes/widgets/aside/asideCustom.pug +1 -1
  48. package/layout/includes/widgets/aside/asideFlipCard.pug +0 -0
  49. package/layout/includes/widgets/aside/asideInfoCard.pug +3 -3
  50. package/layout/includes/widgets/aside/asideNewestPost.pug +0 -0
  51. package/layout/includes/widgets/aside/asideSwitch.pug +0 -4
  52. package/layout/includes/widgets/aside/asideTag.pug +1 -1
  53. package/layout/includes/widgets/aside/asideToc.pug +0 -0
  54. package/layout/includes/widgets/aside/asideWebInfo.pug +2 -2
  55. package/layout/includes/widgets/home/banner.pug +0 -0
  56. package/layout/includes/widgets/home/bb/json.pug +22 -0
  57. package/layout/includes/widgets/home/bb/local.pug +17 -0
  58. package/layout/includes/widgets/home/bb/memos.pug +25 -0
  59. package/layout/includes/widgets/home/bbTimeList.pug +11 -7
  60. package/layout/includes/widgets/home/categoryBar.pug +0 -0
  61. package/layout/includes/widgets/home/categoryGroup.pug +1 -1
  62. package/layout/includes/widgets/home/hometop.pug +0 -0
  63. package/layout/includes/widgets/home/postList.pug +0 -0
  64. package/layout/includes/widgets/home/topGroup.pug +0 -0
  65. package/layout/includes/widgets/nav/left.pug +0 -0
  66. package/layout/includes/widgets/nav/menu.pug +1 -1
  67. package/layout/includes/widgets/nav/right.pug +6 -5
  68. package/layout/includes/widgets/page/about/authorinfo.pug +10 -9
  69. package/layout/includes/widgets/page/about/award.pug +0 -0
  70. package/layout/includes/widgets/page/about/contentinfo.pug +35 -34
  71. package/layout/includes/widgets/page/about/hobbies.pug +21 -17
  72. package/layout/includes/widgets/page/about/motto.pug +17 -16
  73. package/layout/includes/widgets/page/about/other.pug +16 -16
  74. package/layout/includes/widgets/page/about/personalities.pug +15 -14
  75. package/layout/includes/widgets/page/about/skillsinfo.pug +37 -36
  76. package/layout/includes/widgets/page/about/tenyear.pug +0 -0
  77. package/layout/includes/widgets/page/banner.pug +9 -3
  78. package/layout/includes/widgets/page/equipment/content.pug +0 -0
  79. package/layout/includes/widgets/page/links/banner.pug +14 -12
  80. package/layout/includes/widgets/page/links/linksCard.pug +4 -6
  81. package/layout/includes/widgets/page/links/linksDiscn.pug +8 -0
  82. package/layout/includes/widgets/page/links/linksItem.pug +4 -6
  83. package/layout/includes/widgets/page/says/json.pug +78 -0
  84. package/layout/includes/widgets/page/says/local.pug +44 -0
  85. package/layout/includes/widgets/page/says/memos.pug +107 -0
  86. package/layout/includes/widgets/post/award.pug +0 -0
  87. package/layout/includes/widgets/post/copyright.pug +2 -2
  88. package/layout/includes/widgets/post/post-ai.pug +12 -0
  89. package/layout/includes/widgets/post/postMeta.pug +2 -2
  90. package/layout/includes/widgets/post/postNav.pug +0 -0
  91. package/layout/includes/widgets/post/wave.pug +0 -0
  92. package/layout/includes/widgets/randomlink.pug +1 -1
  93. package/layout/includes/widgets/rightside/index.pug +6 -5
  94. package/layout/includes/widgets/third-party/comments/comment.pug +1 -5
  95. package/layout/includes/widgets/third-party/comments/twikoo.pug +1 -1
  96. package/layout/includes/widgets/third-party/comments/waline.pug +9 -11
  97. package/layout/includes/widgets/third-party/music.pug +1 -1
  98. package/layout/includes/widgets/third-party/news-comment/newest-comment.pug +6 -0
  99. package/layout/includes/widgets/third-party/news-comment/twikoo.pug +70 -0
  100. package/layout/includes/widgets/third-party/news-comment/waline.pug +64 -0
  101. package/layout/includes/widgets/third-party/pjax.pug +0 -0
  102. package/layout/includes/widgets/third-party/search/algolia-search.pug +0 -0
  103. package/layout/includes/widgets/third-party/search/index.pug +8 -7
  104. package/layout/includes/widgets/third-party/search/local-search.pug +0 -0
  105. package/layout/index.pug +3 -3
  106. package/layout/page.pug +0 -4
  107. package/layout/post.pug +2 -2
  108. package/layout/tag.pug +0 -0
  109. package/package.json +18 -9
  110. package/plugins.yml +109 -0
  111. package/scripts/event/cdn.js +129 -0
  112. package/scripts/event/init.js +0 -0
  113. package/scripts/event/page.js +1 -21
  114. package/scripts/event/welcome.js +1 -1
  115. package/scripts/filter/checkThemeConfig.js +0 -0
  116. package/scripts/filter/default.js +0 -0
  117. package/scripts/filter/lazyload.js +1 -1
  118. package/scripts/filter/randomPosts.js +0 -0
  119. package/scripts/helper/cdn.js +0 -0
  120. package/scripts/helper/getArchiveLength.js +0 -0
  121. package/scripts/helper/page.js +0 -0
  122. package/scripts/helper/related_post.js +0 -0
  123. package/scripts/helper/stylus.js +0 -0
  124. package/scripts/tags/button.js +0 -0
  125. package/scripts/tags/bvideo.js +0 -0
  126. package/scripts/tags/card.js +0 -0
  127. package/scripts/tags/checkbox.js +0 -0
  128. package/scripts/tags/fold.js +0 -0
  129. package/scripts/tags/image.js +0 -0
  130. package/scripts/tags/inline-image.js +0 -0
  131. package/scripts/tags/label.js +0 -0
  132. package/scripts/tags/link.js +0 -0
  133. package/scripts/tags/media.js +0 -0
  134. package/scripts/tags/note.js +0 -0
  135. package/scripts/tags/span.js +0 -0
  136. package/scripts/tags/tabs.js +0 -0
  137. package/scripts/tags/timeline.js +0 -0
  138. package/scripts/tags/u.js +0 -0
  139. package/source/css/_global/animation.css +0 -0
  140. package/source/css/_global/function.styl +42 -42
  141. package/source/css/_global/index.styl +1 -1
  142. package/source/css/_global/var.styl +0 -0
  143. package/source/css/_layout/basic.styl +16 -13
  144. package/source/css/_layout/header.styl +7 -2
  145. package/source/css/_layout/index.styl +59 -5
  146. package/source/css/_mode/index.styl +1 -17
  147. package/source/css/_page/_home/category-bar.styl +0 -0
  148. package/source/css/_page/_home/home-top.styl +10 -31
  149. package/source/css/_page/_home/index.styl +0 -0
  150. package/source/css/_page/_home/pagination.styl +3 -0
  151. package/source/css/_page/_home/recent-post.styl +10 -3
  152. package/source/css/_page/about/author.styl +94 -0
  153. package/source/css/_page/about/buff.styl +34 -0
  154. package/source/css/_page/about/careers.styl +27 -0
  155. package/source/css/_page/about/contentinfo.styl +78 -0
  156. package/source/css/_page/about/game.styl +41 -0
  157. package/source/css/_page/about/index.styl +39 -1
  158. package/source/css/_page/about/like.styl +29 -0
  159. package/source/css/_page/about/maxim.styl +23 -0
  160. package/source/css/_page/about/myphoto.styl +34 -0
  161. package/source/css/_page/about/oneself.styl +91 -0
  162. package/source/css/_page/about/personalities.styl +25 -0
  163. package/source/css/_page/about/reward.styl +113 -0
  164. package/source/css/_page/about/skills.styl +75 -0
  165. package/source/css/_page/about/statistic.styl +55 -0
  166. package/source/css/_page/about/tenyear.styl +0 -0
  167. package/source/css/_page/category.styl +0 -0
  168. package/source/css/_page/douban.styl +0 -1
  169. package/source/css/_page/equipment.styl +0 -0
  170. package/source/css/_page/error.styl +0 -0
  171. package/source/css/_page/home.styl +0 -0
  172. package/source/css/_page/index.styl +20 -5
  173. package/source/css/_page/links.styl +84 -49
  174. package/source/css/_page/moment.styl +0 -0
  175. package/source/css/_page/music.styl +0 -0
  176. package/source/css/_page/rss.styl +0 -0
  177. package/source/css/_page/says.styl +10 -0
  178. package/source/css/_page/tag.styl +0 -0
  179. package/source/css/_widgets/_aside/allinfo.styl +34 -0
  180. package/source/css/_widgets/_aside/flip.styl +0 -0
  181. package/source/css/_widgets/_aside/index.styl +1 -7
  182. package/source/css/_widgets/_aside/info.styl +0 -0
  183. package/source/css/_widgets/_aside/newPost.styl +0 -0
  184. package/source/css/_widgets/_aside/toc.styl +0 -0
  185. package/source/css/_widgets/_aside/welcome.styl +0 -0
  186. package/source/css/_widgets/_comment/index.styl +0 -0
  187. package/source/css/_widgets/_comment/twikoo.styl +0 -2
  188. package/source/css/_widgets/_comment/waline.styl +0 -0
  189. package/source/css/_widgets/_extra/console.styl +0 -0
  190. package/source/css/_widgets/_extra/fullpage.styl +0 -0
  191. package/source/css/_widgets/_extra/music.styl +1 -1
  192. package/source/css/_widgets/_extra/pace.styl +0 -0
  193. package/source/css/_widgets/_extra/rightmenu.styl +0 -0
  194. package/source/css/_widgets/_mixins/article-sort.styl +0 -0
  195. package/source/css/_widgets/_mixins/footer.styl +1 -2
  196. package/source/css/_widgets/_mixins/other.styl +0 -4
  197. package/source/css/_widgets/_mixins/sidebar.styl +0 -0
  198. package/source/css/_widgets/_post/_highlight/diff.styl +0 -0
  199. package/source/css/_widgets/_post/_highlight/index.styl +0 -1
  200. package/source/css/_widgets/_post/_highlight/theme/default.styl +0 -0
  201. package/source/css/_widgets/_post/_highlight/theme/mac.styl +0 -0
  202. package/source/css/_widgets/_post/_highlight/theme.styl +0 -0
  203. package/source/css/_widgets/_post/commentBarrage.styl +0 -0
  204. package/source/css/_widgets/_post/content.styl +42 -11
  205. package/source/css/_widgets/_post/copyright.styl +0 -0
  206. package/source/css/_widgets/_post/index.styl +1 -1
  207. package/source/css/_widgets/_post/meta.styl +0 -3
  208. package/source/css/_widgets/_post/pagination.styl +1 -1
  209. package/source/css/_widgets/_post/postAI.styl +0 -0
  210. package/source/css/_widgets/_post/relatedPost.styl +0 -0
  211. package/source/css/_widgets/_post/tools.styl +0 -0
  212. package/source/css/_widgets/_search/algolia-search.styl +0 -0
  213. package/source/css/_widgets/_search/local-search.styl +0 -0
  214. package/source/css/_widgets/_tags/button.styl +0 -0
  215. package/source/css/_widgets/_tags/bvideo.styl +0 -0
  216. package/source/css/_widgets/_tags/card.styl +0 -0
  217. package/source/css/_widgets/_tags/checkbox.styl +0 -0
  218. package/source/css/_widgets/_tags/fold.styl +0 -0
  219. package/source/css/_widgets/_tags/image.styl +0 -0
  220. package/source/css/_widgets/_tags/index.styl +0 -0
  221. package/source/css/_widgets/_tags/inline-image.styl +0 -0
  222. package/source/css/_widgets/_tags/label.styl +0 -0
  223. package/source/css/_widgets/_tags/link.styl +4 -2
  224. package/source/css/_widgets/_tags/note.styl +0 -0
  225. package/source/css/_widgets/_tags/span.styl +0 -0
  226. package/source/css/_widgets/_tags/tabs.styl +0 -0
  227. package/source/css/_widgets/_tags/timeline.styl +0 -1
  228. package/source/css/_widgets/index.styl +4 -4
  229. package/source/css/index.styl +0 -0
  230. package/source/img/avatar.png +0 -0
  231. package/source/img/default.png +0 -0
  232. package/source/img/error_load.png +0 -0
  233. package/source/js/{extend/comment/twikoo/commentBarrage.js → comment/twikoo_commentBarrage.js} +0 -0
  234. package/source/js/{extend/comment/waline/commentBarrage.js → comment/waline_commentBarrage.js} +0 -0
  235. package/source/js/covercolor/api.js +92 -0
  236. package/source/js/covercolor/local.js +85 -0
  237. package/source/js/main.js +28 -235
  238. package/source/js/music.js +0 -0
  239. package/source/js/rightside.js +404 -0
  240. package/source/js/{extend/search/algolia-search.js → search/algolia.js} +10 -0
  241. package/source/js/{extend/search/local-search.js → search/local.js} +24 -2
  242. package/source/js/utils.js +75 -1
  243. package/layout/includes/head/fest.pug +0 -22
  244. package/layout/includes/page/echarts.pug +0 -7
  245. package/layout/includes/page/moments.pug +0 -4
  246. package/layout/includes/widgets/aside/asideHistory.pug +0 -8
  247. package/layout/includes/widgets/aside/asideWelcome.pug +0 -12
  248. package/layout/includes/widgets/page/moments/angle.pug +0 -19
  249. package/layout/includes/widgets/page/moments/index.pug +0 -23
  250. package/layout/includes/widgets/page/says/saysBottom.pug +0 -11
  251. package/layout/includes/widgets/page/says/saysContent.pug +0 -6
  252. package/layout/includes/widgets/page/says/saysFunction.pug +0 -10
  253. package/layout/includes/widgets/page/says/saysMeta.pug +0 -7
  254. package/layout/includes/widgets/third-party/ai/index.pug +0 -12
  255. package/layout/includes/widgets/third-party/comments/gitalk.pug +0 -0
  256. package/layout/includes/widgets/third-party/comments/valine.pug +0 -0
  257. package/scripts/helper/echarts.js +0 -407
  258. package/source/css/_page/about.styl +0 -764
  259. package/source/css/_widgets/_aside/history.styl +0 -42
  260. package/source/js/extend/comment/twikoo/twikoo.js +0 -67
  261. package/source/js/extend/comment/waline/waline.js +0 -60
  262. package/source/lib/bundle.min.js +0 -27
  263. package/source/lib/circle.min.js +0 -1
  264. package/source/lib/cover-color.min.js +0 -7
  265. package/source/lib/friends_post.js +0 -4
  266. package/source/lib/lazyload.min.js +0 -1
  267. package/source/lib/rightside.min.js +0 -1
  268. package/source/lib/snackbar.min.css +0 -1
  269. package/source/lib/snackbar.min.js +0 -9
  270. package/source/lib/txmap.min.js +0 -1
  271. package/source/lib/universe.min.js +0 -1
  272. package/source/lib/view-image.min.js +0 -6
  273. package/source/lib/waterfall.min.js +0 -1
  274. /package/source/{lib → js}/sco-ai.min.js +0 -0
@@ -1,12 +0,0 @@
1
- .post-ai
2
- .ai-title
3
- .ai-title-left
4
- i.ai-title-icon.scoicon.sco-robot-fill
5
- .ai-title-text 文章摘要
6
- .ai-tag#ai-tag= theme.thirdparty.ai.modelName
7
- .ai-explanation(style="display: block;")
8
- .ai-suggestions
9
- .ai-bottom
10
- .ai-tips= theme.thirdparty.ai.tips
11
- if theme.thirdparty.ai.report
12
- a.ai-report(title="投诉", href=url_for(theme.thirdparty.ai.report)) 投诉
@@ -1,407 +0,0 @@
1
- hexo.extend.filter.register('after_render:html', function (locals) {
2
- const {config, theme} = this
3
- if (!theme.config.about.echarts.enable) return
4
-
5
- const cheerio = require('cheerio')
6
- const $ = cheerio.load(locals)
7
- const post = $('#posts-chart')
8
- const tag = $('#tags-chart')
9
- const category = $('#categories-chart')
10
- const htmlEncode = false
11
-
12
- if (post.length > 0 || tag.length > 0 || category.length > 0) {
13
- if (post.length > 0 && $('#postsChart').length === 0) {
14
- if (post.attr('data-encode') === 'true') htmlEncode = true
15
- post.after(postsChart(post.attr('data-start')))
16
- }
17
- if (tag.length > 0 && $('#tagsChart').length === 0) {
18
- if (tag.attr('data-encode') === 'true') htmlEncode = true
19
- tag.after(tagsChart(tag.attr('data-length')))
20
- }
21
- if (category.length > 0 && $('#categoriesChart').length === 0) {
22
- if (category.attr('data-encode') === 'true') htmlEncode = true
23
- category.after(categoriesChart(category.attr('data-parent')))
24
- }
25
-
26
- if (htmlEncode) {
27
- return $.root().html().replace(/&#/g, '&#')
28
- } else {
29
- return $.root().html()
30
- }
31
- } else {
32
- return locals
33
- }
34
- }, 15)
35
-
36
- function postsChart(startMonth) {
37
- const moment = require('moment')
38
- const startDate = moment(startMonth || '2020-01')
39
- const endDate = moment()
40
-
41
- const monthMap = new Map()
42
- const dayTime = 3600 * 24 * 1000
43
- for (let time = startDate; time <= endDate; time += dayTime) {
44
- const month = moment(time).format('YYYY-MM')
45
- if (!monthMap.has(month)) {
46
- monthMap.set(month, 0)
47
- }
48
- }
49
- hexo.locals.get('posts').forEach(function (post) {
50
- const month = post.date.format('YYYY-MM')
51
- if (monthMap.has(month)) {
52
- monthMap.set(month, monthMap.get(month) + 1)
53
- }
54
- })
55
- const monthArr = JSON.stringify([...monthMap.keys()])
56
- const monthValueArr = JSON.stringify([...monthMap.values()])
57
-
58
- return `
59
- <script id="postsChart">
60
- var color = document.documentElement.getAttribute('data-theme') === 'light' ? '#4c4948' : 'rgba(255,255,255,0.7)'
61
- var postsChart = echarts.init(document.getElementById('posts-chart'), 'light');
62
- var postsOption = {
63
- title: {
64
- text: '文章发布统计图',
65
- x: 'center',
66
- textStyle: {
67
- color: color
68
- }
69
- },
70
- tooltip: {
71
- trigger: 'axis'
72
- },
73
- xAxis: {
74
- name: '日期',
75
- type: 'category',
76
- boundaryGap: false,
77
- nameTextStyle: {
78
- color: color
79
- },
80
- axisTick: {
81
- show: false
82
- },
83
- axisLabel: {
84
- show: true,
85
- color: color
86
- },
87
- axisLine: {
88
- show: true,
89
- lineStyle: {
90
- color: color
91
- }
92
- },
93
- data: ${monthArr}
94
- },
95
- yAxis: {
96
- name: '文章篇数',
97
- type: 'value',
98
- nameTextStyle: {
99
- color: color
100
- },
101
- splitLine: {
102
- show: false
103
- },
104
- axisTick: {
105
- show: false
106
- },
107
- axisLabel: {
108
- show: true,
109
- color: color
110
- },
111
- axisLine: {
112
- show: true,
113
- lineStyle: {
114
- color: color
115
- }
116
- }
117
- },
118
- series: [{
119
- name: '文章篇数',
120
- type: 'line',
121
- smooth: true,
122
- lineStyle: {
123
- width: 0
124
- },
125
- showSymbol: false,
126
- itemStyle: {
127
- opacity: 1,
128
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
129
- offset: 0,
130
- color: 'rgba(128, 255, 165)'
131
- },
132
- {
133
- offset: 1,
134
- color: 'rgba(1, 191, 236)'
135
- }])
136
- },
137
- areaStyle: {
138
- opacity: 1,
139
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
140
- offset: 0,
141
- color: 'rgba(128, 255, 165)'
142
- }, {
143
- offset: 1,
144
- color: 'rgba(1, 191, 236)'
145
- }])
146
- },
147
- data: ${monthValueArr},
148
- markLine: {
149
- data: [{
150
- name: '平均值',
151
- type: 'average',
152
- label: {
153
- color: color
154
- }
155
- }]
156
- }
157
- }]
158
- };
159
- postsChart.setOption(postsOption);
160
- window.addEventListener('resize', () => {
161
- postsChart.resize();
162
- });
163
- postsChart.on('click', 'series', (event) => {
164
- if (event.componentType === 'series') window.location.href = '/archives/' + event.name.replace('-', '/');
165
- });
166
- </script>`
167
- }
168
-
169
- function tagsChart(len) {
170
- const tagArr = []
171
- hexo.locals.get('tags').map(function (tag) {
172
- tagArr.push({name: tag.name, value: tag.length, path: tag.path})
173
- })
174
- tagArr.sort((a, b) => {
175
- return b.value - a.value
176
- })
177
-
178
- const dataLength = Math.min(tagArr.length, len) || tagArr.length
179
- const tagNameArr = []
180
- for (let i = 0; i < dataLength; i++) {
181
- tagNameArr.push(tagArr[i].name)
182
- }
183
- const tagNameArrJson = JSON.stringify(tagNameArr)
184
- const tagArrJson = JSON.stringify(tagArr)
185
-
186
- return `
187
- <script id="tagsChart">
188
- var color = document.documentElement.getAttribute('data-theme') === 'light' ? '#4c4948' : 'rgba(255,255,255,0.7)'
189
- var tagsChart = echarts.init(document.getElementById('tags-chart'), 'light');
190
- var tagsOption = {
191
- title: {
192
- text: 'Top ${dataLength} 标签统计图',
193
- x: 'center',
194
- textStyle: {
195
- color: color
196
- }
197
- },
198
- tooltip: {},
199
- xAxis: {
200
- name: '标签',
201
- type: 'category',
202
- nameTextStyle: {
203
- color: color
204
- },
205
- axisTick: {
206
- show: false
207
- },
208
- axisLabel: {
209
- show: true,
210
- color: color,
211
- interval: 0
212
- },
213
- axisLine: {
214
- show: true,
215
- lineStyle: {
216
- color: color
217
- }
218
- },
219
- data: ${tagNameArrJson}
220
- },
221
- yAxis: {
222
- name: '文章篇数',
223
- type: 'value',
224
- splitLine: {
225
- show: false
226
- },
227
- nameTextStyle: {
228
- color: color
229
- },
230
- axisTick: {
231
- show: false
232
- },
233
- axisLabel: {
234
- show: true,
235
- color: color
236
- },
237
- axisLine: {
238
- show: true,
239
- lineStyle: {
240
- color: color
241
- }
242
- }
243
- },
244
- series: [{
245
- name: '文章篇数',
246
- type: 'bar',
247
- data: ${tagArrJson},
248
- itemStyle: {
249
- borderRadius: [5, 5, 0, 0],
250
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
251
- offset: 0,
252
- color: 'rgba(128, 255, 165)'
253
- },
254
- {
255
- offset: 1,
256
- color: 'rgba(1, 191, 236)'
257
- }])
258
- },
259
- emphasis: {
260
- itemStyle: {
261
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
262
- offset: 0,
263
- color: 'rgba(128, 255, 195)'
264
- },
265
- {
266
- offset: 1,
267
- color: 'rgba(1, 211, 255)'
268
- }])
269
- }
270
- },
271
- markLine: {
272
- data: [{
273
- name: '平均值',
274
- type: 'average',
275
- label: {
276
- color: color
277
- }
278
- }]
279
- }
280
- }]
281
- };
282
- tagsChart.setOption(tagsOption);
283
- window.addEventListener('resize', () => {
284
- tagsChart.resize();
285
- });
286
- tagsChart.on('click', 'series', (event) => {
287
- if(event.data.path) window.location.href = '/' + event.data.path;
288
- });
289
- </script>`
290
- }
291
-
292
- function categoriesChart(dataParent) {
293
- const categoryArr = []
294
- let categoryParentFlag = false
295
- hexo.locals.get('categories').map(function (category) {
296
- if (category.parent) categoryParentFlag = true
297
- categoryArr.push({
298
- name: category.name,
299
- value: category.length,
300
- path: category.path,
301
- id: category._id,
302
- parentId: category.parent || '0'
303
- })
304
- })
305
- categoryParentFlag = categoryParentFlag && dataParent === 'true'
306
- categoryArr.sort((a, b) => {
307
- return b.value - a.value
308
- })
309
-
310
- function translateListToTree(data, parent) {
311
- let tree = []
312
- let temp
313
- data.forEach((item, index) => {
314
- if (data[index].parentId == parent) {
315
- let obj = data[index];
316
- temp = translateListToTree(data, data[index].id);
317
- if (temp.length > 0) {
318
- obj.children = temp
319
- }
320
- if (tree.indexOf())
321
- tree.push(obj)
322
- }
323
- })
324
- return tree
325
- }
326
-
327
- const categoryNameJson = JSON.stringify(categoryArr.map(function (category) {
328
- return category.name
329
- }))
330
- const categoryArrJson = JSON.stringify(categoryArr)
331
- const categoryArrParentJson = JSON.stringify(translateListToTree(categoryArr, '0'))
332
-
333
- return `
334
- <script id="categoriesChart">
335
- var color = document.documentElement.getAttribute('data-theme') === 'light' ? '#4c4948' : 'rgba(255,255,255,0.7)'
336
- var categoriesChart = echarts.init(document.getElementById('categories-chart'), 'light');
337
- var categoryParentFlag = ${categoryParentFlag}
338
- var categoriesOption = {
339
- title: {
340
- text: '文章分类统计图',
341
- x: 'center',
342
- textStyle: {
343
- color: color
344
- }
345
- },
346
- legend: {
347
- top: 'bottom',
348
- data: ${categoryNameJson},
349
- textStyle: {
350
- color: color
351
- }
352
- },
353
- tooltip: {
354
- trigger: 'item'
355
- },
356
- series: []
357
- };
358
- categoriesOption.series.push(
359
- categoryParentFlag ?
360
- {
361
- nodeClick :false,
362
- name: '文章篇数',
363
- type: 'sunburst',
364
- radius: ['15%', '90%'],
365
- center: ['50%', '55%'],
366
- sort: 'desc',
367
- data: ${categoryArrParentJson},
368
- itemStyle: {
369
- borderColor: '#fff',
370
- borderWidth: 2,
371
- emphasis: {
372
- focus: 'ancestor',
373
- shadowBlur: 10,
374
- shadowOffsetX: 0,
375
- shadowColor: 'rgba(255, 255, 255, 0.5)'
376
- }
377
- }
378
- }
379
- :
380
- {
381
- name: '文章篇数',
382
- type: 'pie',
383
- radius: [30, 80],
384
- roseType: 'area',
385
- label: {
386
- color: color,
387
- formatter: '{b} : {c} ({d}%)'
388
- },
389
- data: ${categoryArrJson},
390
- itemStyle: {
391
- emphasis: {
392
- shadowBlur: 10,
393
- shadowOffsetX: 0,
394
- shadowColor: 'rgba(255, 255, 255, 0.5)'
395
- }
396
- }
397
- }
398
- )
399
- categoriesChart.setOption(categoriesOption);
400
- window.addEventListener('resize', () => {
401
- categoriesChart.resize();
402
- });
403
- categoriesChart.on('click', 'series', (event) => {
404
- if(event.data.path) window.location.href = '/' + event.data.path;
405
- });
406
- </script>`
407
- }