hexo-theme-solitude 1.0.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.
Files changed (173) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +56 -0
  3. package/_config.yml +432 -0
  4. package/languages/en-US.yml +39 -0
  5. package/languages/zh-CN.yml +39 -0
  6. package/layout/404.ejs +34 -0
  7. package/layout/archive.ejs +10 -0
  8. package/layout/category.ejs +18 -0
  9. package/layout/index.ejs +20 -0
  10. package/layout/layout.ejs +35 -0
  11. package/layout/page/about.ejs +13 -0
  12. package/layout/page/categories.ejs +12 -0
  13. package/layout/page/circle.ejs +5 -0
  14. package/layout/page/echarts.ejs +14 -0
  15. package/layout/page/equipment.ejs +2 -0
  16. package/layout/page/links.ejs +57 -0
  17. package/layout/page/page.ejs +3 -0
  18. package/layout/page/rss.ejs +37 -0
  19. package/layout/page/says.ejs +16 -0
  20. package/layout/page/tags.ejs +12 -0
  21. package/layout/page/tlink.ejs +11 -0
  22. package/layout/page.ejs +45 -0
  23. package/layout/partial/body.ejs +8 -0
  24. package/layout/partial/compoment/about/authorinfo.ejs +18 -0
  25. package/layout/partial/compoment/about/award.ejs +57 -0
  26. package/layout/partial/compoment/about/contentinfo.ejs +33 -0
  27. package/layout/partial/compoment/about/hobbies.ejs +44 -0
  28. package/layout/partial/compoment/about/motto.ejs +17 -0
  29. package/layout/partial/compoment/about/other.ejs +68 -0
  30. package/layout/partial/compoment/about/personalities.ejs +11 -0
  31. package/layout/partial/compoment/about/skillsinfo.ejs +62 -0
  32. package/layout/partial/compoment/aside/aside.ejs +28 -0
  33. package/layout/partial/compoment/aside/asideAllInfo.ejs +6 -0
  34. package/layout/partial/compoment/aside/asideArchive.ejs +11 -0
  35. package/layout/partial/compoment/aside/asideFlipCard.ejs +8 -0
  36. package/layout/partial/compoment/aside/asideInfoCard.ejs +39 -0
  37. package/layout/partial/compoment/aside/asideNewestPost.ejs +31 -0
  38. package/layout/partial/compoment/aside/asidePower.ejs +31 -0
  39. package/layout/partial/compoment/aside/asideSwitch.ejs +35 -0
  40. package/layout/partial/compoment/aside/asideTag.ejs +5 -0
  41. package/layout/partial/compoment/aside/asideToc.ejs +11 -0
  42. package/layout/partial/compoment/aside/asideWebInfo.ejs +60 -0
  43. package/layout/partial/compoment/circle/angle.ejs +26 -0
  44. package/layout/partial/compoment/circle/banner.ejs +11 -0
  45. package/layout/partial/compoment/circle/content.ejs +22 -0
  46. package/layout/partial/compoment/dorakika/rightmenu.ejs +115 -0
  47. package/layout/partial/compoment/equipment/list.ejs +37 -0
  48. package/layout/partial/compoment/home/homeCategoryBar.ejs +11 -0
  49. package/layout/partial/compoment/home/postList.ejs +37 -0
  50. package/layout/partial/compoment/hometop/bbTimeList.ejs +15 -0
  51. package/layout/partial/compoment/hometop/categoryGroup.ejs +19 -0
  52. package/layout/partial/compoment/hometop/groupTag.ejs +30 -0
  53. package/layout/partial/compoment/hometop/topGroup.ejs +48 -0
  54. package/layout/partial/compoment/inject/body.ejs +57 -0
  55. package/layout/partial/compoment/inject/head.ejs +19 -0
  56. package/layout/partial/compoment/links/banner.ejs +42 -0
  57. package/layout/partial/compoment/links/linksCard.ejs +27 -0
  58. package/layout/partial/compoment/links/linksItem.ejs +21 -0
  59. package/layout/partial/compoment/mixins/articleSort.ejs +26 -0
  60. package/layout/partial/compoment/mixins/pagination.ejs +11 -0
  61. package/layout/partial/compoment/nav/left.ejs +22 -0
  62. package/layout/partial/compoment/nav/menu.ejs +25 -0
  63. package/layout/partial/compoment/nav/right.ejs +42 -0
  64. package/layout/partial/compoment/post/award.ejs +52 -0
  65. package/layout/partial/compoment/post/copyright.ejs +37 -0
  66. package/layout/partial/compoment/post/postMeta.ejs +83 -0
  67. package/layout/partial/compoment/post/postNav.ejs +41 -0
  68. package/layout/partial/compoment/post/wave.ejs +14 -0
  69. package/layout/partial/compoment/says/banner.ejs +10 -0
  70. package/layout/partial/compoment/says/saysBottom.ejs +18 -0
  71. package/layout/partial/compoment/says/saysContent.ejs +11 -0
  72. package/layout/partial/compoment/third-party/comments/comment.ejs +12 -0
  73. package/layout/partial/compoment/third-party/comments/twikoo.ejs +29 -0
  74. package/layout/partial/compoment/third-party/comments/twikoo_k.ejs +29 -0
  75. package/layout/partial/compoment/third-party/music.ejs +5 -0
  76. package/layout/partial/compoment/third-party/pjax.ejs +31 -0
  77. package/layout/partial/compoment/third-party/search/algolia-search.ejs +20 -0
  78. package/layout/partial/compoment/third-party/search/index.ejs +10 -0
  79. package/layout/partial/compoment/third-party/search/local-search.ejs +22 -0
  80. package/layout/partial/compoment/tlink/banner.ejs +10 -0
  81. package/layout/partial/console.ejs +62 -0
  82. package/layout/partial/footer.ejs +107 -0
  83. package/layout/partial/head.ejs +37 -0
  84. package/layout/partial/header.ejs +6 -0
  85. package/layout/partial/hometop.ejs +15 -0
  86. package/layout/partial/loading.ejs +86 -0
  87. package/layout/partial/nav.ejs +34 -0
  88. package/layout/partial/pwa.ejs +40 -0
  89. package/layout/partial/sidebar.ejs +31 -0
  90. package/layout/post.ejs +36 -0
  91. package/layout/tag.ejs +19 -0
  92. package/package.json +24 -0
  93. package/scripts/event/init.js +22 -0
  94. package/scripts/event/page.js +40 -0
  95. package/scripts/event/welcome.js +15 -0
  96. package/scripts/filter/checkThemeConfig.js +18 -0
  97. package/scripts/filter/default.js +23 -0
  98. package/scripts/filter/katex.js +25 -0
  99. package/scripts/filter/lazyload.js +11 -0
  100. package/scripts/filter/randomPosts.js +9 -0
  101. package/scripts/helper/charts.js +397 -0
  102. package/scripts/helper/getArchiveLength.js +18 -0
  103. package/scripts/helper/randomLinks.js +16 -0
  104. package/scripts/helper/related_post.js +91 -0
  105. package/scripts/helper/themeJsExport.js +77 -0
  106. package/scripts/tags/bvideo.js +42 -0
  107. package/scripts/tags/expand.js +4 -0
  108. package/scripts/tags/fold.js +19 -0
  109. package/scripts/tags/link.js +17 -0
  110. package/scripts/tags/note.js +3 -0
  111. package/scripts/tags/tabs.js +61 -0
  112. package/scripts/tags/timeline.js +35 -0
  113. package/source/css/commentBarrage.css +174 -0
  114. package/source/css/custom.css +901 -0
  115. package/source/css/main.css +16471 -0
  116. package/source/css/search/algolia-search.css +141 -0
  117. package/source/css/search/local-search.css +138 -0
  118. package/source/css/var.css +186 -0
  119. package/source/img/default.png +0 -0
  120. package/source/img/loading.gif +0 -0
  121. package/source/img/power.png +0 -0
  122. package/source/img/pwa/180.png +0 -0
  123. package/source/img/pwa/192.png +0 -0
  124. package/source/img/pwa/512.png +0 -0
  125. package/source/img/pwa/logo.png +0 -0
  126. package/source/img/pwa/siteicon/splash-1125x2436.png +0 -0
  127. package/source/img/pwa/siteicon/splash-1136x640.png +0 -0
  128. package/source/img/pwa/siteicon/splash-1170x2532.png +0 -0
  129. package/source/img/pwa/siteicon/splash-1179x2556.png +0 -0
  130. package/source/img/pwa/siteicon/splash-1242x2208.png +0 -0
  131. package/source/img/pwa/siteicon/splash-1242x2688.png +0 -0
  132. package/source/img/pwa/siteicon/splash-1248x2778.png +0 -0
  133. package/source/img/pwa/siteicon/splash-1290x2796.png +0 -0
  134. package/source/img/pwa/siteicon/splash-1334x750.png +0 -0
  135. package/source/img/pwa/siteicon/splash-1536x2048.png +0 -0
  136. package/source/img/pwa/siteicon/splash-1620x2160.png +0 -0
  137. package/source/img/pwa/siteicon/splash-1668x2224.png +0 -0
  138. package/source/img/pwa/siteicon/splash-1668x2388.png +0 -0
  139. package/source/img/pwa/siteicon/splash-1792x828.png +0 -0
  140. package/source/img/pwa/siteicon/splash-2048x1536.png +0 -0
  141. package/source/img/pwa/siteicon/splash-2048x2732.png +0 -0
  142. package/source/img/pwa/siteicon/splash-2160x1620.png +0 -0
  143. package/source/img/pwa/siteicon/splash-2208x1242.png +0 -0
  144. package/source/img/pwa/siteicon/splash-2224x1668.png +0 -0
  145. package/source/img/pwa/siteicon/splash-2388x1668.png +0 -0
  146. package/source/img/pwa/siteicon/splash-2436x1125.png +0 -0
  147. package/source/img/pwa/siteicon/splash-2532x1170.png +0 -0
  148. package/source/img/pwa/siteicon/splash-2556x1179.png +0 -0
  149. package/source/img/pwa/siteicon/splash-2688x1242.png +0 -0
  150. package/source/img/pwa/siteicon/splash-2732x2048.png +0 -0
  151. package/source/img/pwa/siteicon/splash-2778x1248.png +0 -0
  152. package/source/img/pwa/siteicon/splash-2796x1290.png +0 -0
  153. package/source/img/pwa/siteicon/splash-640x1136.png +0 -0
  154. package/source/img/pwa/siteicon/splash-750x1334.png +0 -0
  155. package/source/img/pwa/siteicon/splash-828x1792.png +0 -0
  156. package/source/img/theme/avatar.png +0 -0
  157. package/source/js/circle.js +1828 -0
  158. package/source/js/commentBarrage.js +148 -0
  159. package/source/js/extend/console/comment.js +99 -0
  160. package/source/js/extend/covercolor/local.js +150 -0
  161. package/source/js/extend/covercolor/web.js +137 -0
  162. package/source/js/extend/search/algolia-search.js +136 -0
  163. package/source/js/extend/search/local-search.js +160 -0
  164. package/source/js/main.js +705 -0
  165. package/source/js/post_ai.js +517 -0
  166. package/source/js/utils.js +153 -0
  167. package/source/lib/bundle.js +27 -0
  168. package/source/lib/friends_post.js +98 -0
  169. package/source/lib/lazyload.js +1 -0
  170. package/source/lib/snackbar.js +16 -0
  171. package/source/lib/snackbar.min.css +1 -0
  172. package/source/lib/view-image.js +13 -0
  173. package/source/lib/waterfall.min.js +1 -0
package/layout/tag.ejs ADDED
@@ -0,0 +1,19 @@
1
+ <main class="layout" id="content-inner">
2
+ <div id="tag">
3
+ <div id="tag-page-tags">
4
+ <% site.tags.data.forEach(data => { %>
5
+ <a href="<%= url_for(data.path) %>" class="<%= data.name === page.tag ? 'select' : '' %>">
6
+ <span class="tags-punctuation"></span>
7
+ <%= data.name %>
8
+ <span class="tagsPageCount"><%= data.length %></span>
9
+ </a>
10
+ <% }) %>
11
+ </div>
12
+ <div class="article-sort-title"><%= page.tag %></div>
13
+ <div class="article-sort">
14
+ <%- partial('partial/compoment/mixins/articleSort') %>
15
+ </div>
16
+ <%- partial('partial/compoment/mixins/pagination') %>
17
+ </div>
18
+ <%- partial('partial/compoment/aside/aside') %>
19
+ </main>
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "hexo-theme-solitude",
3
+ "version": "1.0.0",
4
+ "description": "A beautiful, powerful, and efficient Hexo theme developed by the hexo-theme-Solitude team",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/DuoSco/hexo-theme-solitude.git"
11
+ },
12
+ "keywords": [
13
+ "hexo",
14
+ "theme",
15
+ "hexo-theme-solitude"
16
+ ],
17
+ "author": "Hexo-Theme-Solitude <wleelw@sondy.top>",
18
+ "license": "MIT",
19
+ "bugs": {
20
+ "url": "https://github.com/DuoSco/Hexo-theme-solitude/issues"
21
+ },
22
+ "homepage": "https://github.com/DuoSco/hexo-theme-solitude#readme",
23
+ "main": "index.js"
24
+ }
@@ -0,0 +1,22 @@
1
+ hexo.extend.filter.register('before_generate', () => {
2
+ // Get first two digits of the Hexo version number
3
+ const hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1')
4
+ const nodeVer = process.version.replace(/^v/, '');
5
+ const [majorVer] = nodeVer.split('.');
6
+ const logger = hexo.log, config = hexo.config
7
+
8
+ if (hexoVer < 5.3) {
9
+ logger.error('请把 Hexo 升级到 V5.3.0 或更高的版本!')
10
+ process.exit(-1)
11
+ }
12
+
13
+ if(config.prismjs.enable){
14
+ logger.error('主题尚未支持 prismjs 请使用 highlightjs !')
15
+ process.exit(-1)
16
+ }
17
+ if (Number(majorVer) < 14) {
18
+ logger.error('请将 Node.js 升级到 v14.0.0 或更高的版本!');
19
+ process.exit(-1);
20
+ }
21
+ }
22
+ )
@@ -0,0 +1,40 @@
1
+ hexo.extend.generator.register('404', function (locals) {
2
+ if(!this.theme.config.page.error)return
3
+ return {
4
+ path: '404.html',
5
+ layout: ['404'],
6
+ data: {
7
+ title: '404',
8
+ type: '404',
9
+ comment: false
10
+ }
11
+ }
12
+ })
13
+
14
+ // generate tags Page
15
+ hexo.extend.generator.register('tags', function(locals) {
16
+ if(!this.theme.config.page.tags)return
17
+ return {
18
+ path: 'tags/index.html',
19
+ layout: ['page'],
20
+ data: {
21
+ title: 'tags',
22
+ type: 'tags',
23
+ comment: false
24
+ }
25
+ };
26
+ });
27
+
28
+ // generate categories Page
29
+ hexo.extend.generator.register('categories', function(locals) {
30
+ if(!this.theme.config.page.categories)return
31
+ return {
32
+ path: 'categories/index.html',
33
+ layout: ['page'],
34
+ data: {
35
+ title: 'categories',
36
+ type: 'categories',
37
+ comment: false
38
+ }
39
+ };
40
+ });
@@ -0,0 +1,15 @@
1
+ hexo.on('ready', () => {
2
+ const { version } = require('../../package.json')
3
+ hexo.log.info(`
4
+ ===================================================================
5
+ ##### # # #### ##### ###### ## #####
6
+ # # # # # # # # # # # # #
7
+ ##### # # # ##### ###### # # ######
8
+ # # # # # ### # # # ###### # #
9
+ # # # # # # # # # # # # #
10
+ ##### #### ### ##### ###### # # # #
11
+ ${version}
12
+ ===================================================================
13
+ 主题链接:https://github.com/DuoSco/Hexo-theme-solitude
14
+ 主题开发:王卓Sco`)
15
+ })
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ hexo.extend.filter.register('before_post_render', () => {
4
+
5
+ const logger = hexo.log;
6
+ const theme = hexo.theme.config;
7
+ const config = hexo.config;
8
+ if (theme.hometop.banner.enable && !theme.hometop.banner.icon) {
9
+ logger.error('\n 启用banner的情况下,必须提供 icon 图片!\n 请在主题配置文件中设置 hometop.banner.icon 选项。');
10
+ logger.error('\n If banner is enabled, icon image must be supplied! \n Please set the hometop.banner.icon option in the theme configuration file.');
11
+ process.exit(-1);
12
+ }
13
+ if (config.language !== 'zh-CN' && config.language !== 'en-US') {
14
+ logger.error('\n 请在站点配置文件中设置 language 选项为 zh-CN 或 en-US。');
15
+ process.exit(-1);
16
+ }
17
+ }
18
+ );
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ hexo.extend.filter.register('after_post_render', function(data){
4
+ const config = hexo.theme.config
5
+ data.title = data.title || '无标题';
6
+ if(data.layout === 'post'){
7
+ data.locate = data.locate || config.post.default.locate
8
+ data.cc = data.cc || config.post.default.copyright
9
+ data.cover = data.cover || config.post.default.cover
10
+ data.excerpt = data.description || data.excerpt
11
+ if(config.aside.toc.post && data.toc !== false)data.toc = true
12
+ else data.toc = false
13
+ }
14
+ if(data.layout === 'page'){
15
+ data.cover = data.cover || config.page.default.cover
16
+ data.excerpt = data.title
17
+ if(config.aside.toc.page && data.toc !== false && data.aside)data.toc = true
18
+ else data.toc = false
19
+ }
20
+ if(config.comment.enable && data.comment !== false)data.comment = true
21
+ else data.comment = false
22
+ return data;
23
+ });
@@ -0,0 +1,25 @@
1
+ const katex = require('katex');
2
+
3
+ hexo.extend.filter.register('marked:extensions', function(extensions) {
4
+ // Info: `extensions` is an array.
5
+ extensions.push({
6
+ name: 'blockMath',
7
+ level: 'block',
8
+ tokenizer(src) {
9
+ const cap = /^\s{0,3}\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/.exec(src);
10
+
11
+ if (cap !== null) {
12
+ return {
13
+ type: 'blockMath',
14
+ raw: cap[0],
15
+ math: cap[1]
16
+ };
17
+ }
18
+
19
+ return undefined;
20
+ },
21
+ renderer(token) {
22
+ return `<p>${katex.renderToString(token.math, {displayMode: true})}</p>\n`;
23
+ }
24
+ });
25
+ });
@@ -0,0 +1,11 @@
1
+ const urlFor = require('hexo-util').url_for.bind(hexo)
2
+
3
+ hexo.extend.filter.register('after_render:html', function (data) {
4
+ const config = hexo.theme.config.lazyload
5
+ if (!config.enable) return
6
+ const bg = config.placeholder ? urlFor(config.placeholder) : 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
7
+ return data.replace(
8
+ /(<img(?!.*?class[\t]*=[\t]*['"].*?nolazyload.*?['"]).*? src=)/gi,
9
+ `$1 "${bg}" data-lazy-src=`
10
+ )
11
+ })
@@ -0,0 +1,9 @@
1
+ hexo.extend.filter.register('after_render:html', function (data) {
2
+ const posts = []
3
+ hexo.locals.get('posts').map(function (post) {
4
+ if (post.random !== false) posts.push(post.path)
5
+ })
6
+ data += `<script>const posts=${JSON.stringify(posts)};function toRandomPost(){ pjax.loadUrl('/'+posts[Math.floor(Math.random()*posts.length)]); };</script>`
7
+ //data += `<script>const posts=${JSON.stringify(posts)};function toRandomPost(){ window.pjax ? : window.open('/'+posts[Math.floor(Math.random()*posts.length)], "_self"); };</script>`
8
+ return data
9
+ })
@@ -0,0 +1,397 @@
1
+ const cheerio = require('cheerio')
2
+ const moment = require('moment')
3
+
4
+ hexo.extend.filter.register('after_render:html', function (locals) {
5
+ const $ = cheerio.load(locals)
6
+ const post = $('#posts-chart')
7
+ const tag = $('#tags-chart')
8
+ const category = $('#categories-chart')
9
+ const htmlEncode = false
10
+
11
+ if (post.length > 0 || tag.length > 0 || category.length > 0) {
12
+ if (post.length > 0 && $('#postsChart').length === 0) {
13
+ if (post.attr('data-encode') === 'true') htmlEncode = true
14
+ post.after(postsChart(post.attr('data-start')))
15
+ }
16
+ if (tag.length > 0 && $('#tagsChart').length === 0) {
17
+ if (tag.attr('data-encode') === 'true') htmlEncode = true
18
+ tag.after(tagsChart(tag.attr('data-length')))
19
+ }
20
+ if (category.length > 0 && $('#categoriesChart').length === 0) {
21
+ if (category.attr('data-encode') === 'true') htmlEncode = true
22
+ category.after(categoriesChart(category.attr('data-parent')))
23
+ }
24
+
25
+ if (htmlEncode) {
26
+ return $.root().html().replace(/&amp;#/g, '&#')
27
+ } else {
28
+ return $.root().html()
29
+ }
30
+ } else {
31
+ return locals
32
+ }
33
+ }, 15)
34
+
35
+ function postsChart (startMonth) {
36
+ const startDate = moment(startMonth || '2020-01')
37
+ const endDate = moment()
38
+
39
+ const monthMap = new Map()
40
+ const dayTime = 3600 * 24 * 1000
41
+ for (let time = startDate; time <= endDate; time += dayTime) {
42
+ const month = moment(time).format('YYYY-MM')
43
+ if (!monthMap.has(month)) {
44
+ monthMap.set(month, 0)
45
+ }
46
+ }
47
+ hexo.locals.get('posts').forEach(function (post) {
48
+ const month = post.date.format('YYYY-MM')
49
+ if (monthMap.has(month)) {
50
+ monthMap.set(month, monthMap.get(month) + 1)
51
+ }
52
+ })
53
+ const monthArr = JSON.stringify([...monthMap.keys()])
54
+ const monthValueArr = JSON.stringify([...monthMap.values()])
55
+
56
+ return `
57
+ <script id="postsChart">
58
+ var color = document.documentElement.getAttribute('data-theme') === 'light' ? '#4c4948' : 'rgba(255,255,255,0.7)'
59
+ var postsChart = echarts.init(document.getElementById('posts-chart'), 'light');
60
+ var postsOption = {
61
+ title: {
62
+ text: '文章发布统计图',
63
+ x: 'center',
64
+ textStyle: {
65
+ color: color
66
+ }
67
+ },
68
+ tooltip: {
69
+ trigger: 'axis'
70
+ },
71
+ xAxis: {
72
+ name: '日期',
73
+ type: 'category',
74
+ boundaryGap: false,
75
+ nameTextStyle: {
76
+ color: color
77
+ },
78
+ axisTick: {
79
+ show: false
80
+ },
81
+ axisLabel: {
82
+ show: true,
83
+ color: color
84
+ },
85
+ axisLine: {
86
+ show: true,
87
+ lineStyle: {
88
+ color: color
89
+ }
90
+ },
91
+ data: ${monthArr}
92
+ },
93
+ yAxis: {
94
+ name: '文章篇数',
95
+ type: 'value',
96
+ nameTextStyle: {
97
+ color: color
98
+ },
99
+ splitLine: {
100
+ show: false
101
+ },
102
+ axisTick: {
103
+ show: false
104
+ },
105
+ axisLabel: {
106
+ show: true,
107
+ color: color
108
+ },
109
+ axisLine: {
110
+ show: true,
111
+ lineStyle: {
112
+ color: color
113
+ }
114
+ }
115
+ },
116
+ series: [{
117
+ name: '文章篇数',
118
+ type: 'line',
119
+ smooth: true,
120
+ lineStyle: {
121
+ width: 0
122
+ },
123
+ showSymbol: false,
124
+ itemStyle: {
125
+ opacity: 1,
126
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
127
+ offset: 0,
128
+ color: 'rgba(128, 255, 165)'
129
+ },
130
+ {
131
+ offset: 1,
132
+ color: 'rgba(1, 191, 236)'
133
+ }])
134
+ },
135
+ areaStyle: {
136
+ opacity: 1,
137
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
138
+ offset: 0,
139
+ color: 'rgba(128, 255, 165)'
140
+ }, {
141
+ offset: 1,
142
+ color: 'rgba(1, 191, 236)'
143
+ }])
144
+ },
145
+ data: ${monthValueArr},
146
+ markLine: {
147
+ data: [{
148
+ name: '平均值',
149
+ type: 'average',
150
+ label: {
151
+ color: color
152
+ }
153
+ }]
154
+ }
155
+ }]
156
+ };
157
+ postsChart.setOption(postsOption);
158
+ window.addEventListener('resize', () => {
159
+ postsChart.resize();
160
+ });
161
+ postsChart.on('click', 'series', (event) => {
162
+ if (event.componentType === 'series') window.location.href = '/archives/' + event.name.replace('-', '/');
163
+ });
164
+ </script>`
165
+ }
166
+
167
+ function tagsChart (len) {
168
+ const tagArr = []
169
+ hexo.locals.get('tags').map(function (tag) {
170
+ tagArr.push({ name: tag.name, value: tag.length, path: tag.path })
171
+ })
172
+ tagArr.sort((a, b) => { return b.value - a.value })
173
+
174
+ const dataLength = Math.min(tagArr.length, len) || tagArr.length
175
+ const tagNameArr = []
176
+ for (let i = 0; i < dataLength; i++) {
177
+ tagNameArr.push(tagArr[i].name)
178
+ }
179
+ const tagNameArrJson = JSON.stringify(tagNameArr)
180
+ const tagArrJson = JSON.stringify(tagArr)
181
+
182
+ return `
183
+ <script id="tagsChart">
184
+ var color = document.documentElement.getAttribute('data-theme') === 'light' ? '#4c4948' : 'rgba(255,255,255,0.7)'
185
+ var tagsChart = echarts.init(document.getElementById('tags-chart'), 'light');
186
+ var tagsOption = {
187
+ title: {
188
+ text: 'Top ${dataLength} 标签统计图',
189
+ x: 'center',
190
+ textStyle: {
191
+ color: color
192
+ }
193
+ },
194
+ tooltip: {},
195
+ xAxis: {
196
+ name: '标签',
197
+ type: 'category',
198
+ nameTextStyle: {
199
+ color: color
200
+ },
201
+ axisTick: {
202
+ show: false
203
+ },
204
+ axisLabel: {
205
+ show: true,
206
+ color: color,
207
+ interval: 0
208
+ },
209
+ axisLine: {
210
+ show: true,
211
+ lineStyle: {
212
+ color: color
213
+ }
214
+ },
215
+ data: ${tagNameArrJson}
216
+ },
217
+ yAxis: {
218
+ name: '文章篇数',
219
+ type: 'value',
220
+ splitLine: {
221
+ show: false
222
+ },
223
+ nameTextStyle: {
224
+ color: color
225
+ },
226
+ axisTick: {
227
+ show: false
228
+ },
229
+ axisLabel: {
230
+ show: true,
231
+ color: color
232
+ },
233
+ axisLine: {
234
+ show: true,
235
+ lineStyle: {
236
+ color: color
237
+ }
238
+ }
239
+ },
240
+ series: [{
241
+ name: '文章篇数',
242
+ type: 'bar',
243
+ data: ${tagArrJson},
244
+ itemStyle: {
245
+ borderRadius: [5, 5, 0, 0],
246
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
247
+ offset: 0,
248
+ color: 'rgba(128, 255, 165)'
249
+ },
250
+ {
251
+ offset: 1,
252
+ color: 'rgba(1, 191, 236)'
253
+ }])
254
+ },
255
+ emphasis: {
256
+ itemStyle: {
257
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
258
+ offset: 0,
259
+ color: 'rgba(128, 255, 195)'
260
+ },
261
+ {
262
+ offset: 1,
263
+ color: 'rgba(1, 211, 255)'
264
+ }])
265
+ }
266
+ },
267
+ markLine: {
268
+ data: [{
269
+ name: '平均值',
270
+ type: 'average',
271
+ label: {
272
+ color: color
273
+ }
274
+ }]
275
+ }
276
+ }]
277
+ };
278
+ tagsChart.setOption(tagsOption);
279
+ window.addEventListener('resize', () => {
280
+ tagsChart.resize();
281
+ });
282
+ tagsChart.on('click', 'series', (event) => {
283
+ if(event.data.path) window.location.href = '/' + event.data.path;
284
+ });
285
+ </script>`
286
+ }
287
+
288
+ function categoriesChart (dataParent) {
289
+ const categoryArr = []
290
+ let categoryParentFlag = false
291
+ hexo.locals.get('categories').map(function (category) {
292
+ if (category.parent) categoryParentFlag = true
293
+ categoryArr.push({
294
+ name: category.name,
295
+ value: category.length,
296
+ path: category.path,
297
+ id: category._id,
298
+ parentId: category.parent || '0'
299
+ })
300
+ })
301
+ categoryParentFlag = categoryParentFlag && dataParent === 'true'
302
+ categoryArr.sort((a, b) => { return b.value - a.value })
303
+ function translateListToTree (data, parent) {
304
+ let tree = []
305
+ let temp
306
+ data.forEach((item, index) => {
307
+ if (data[index].parentId == parent) {
308
+ let obj = data[index];
309
+ temp = translateListToTree(data, data[index].id);
310
+ if (temp.length > 0) {
311
+ obj.children = temp
312
+ }
313
+ if (tree.indexOf())
314
+ tree.push(obj)
315
+ }
316
+ })
317
+ return tree
318
+ }
319
+ const categoryNameJson = JSON.stringify(categoryArr.map(function (category) { return category.name }))
320
+ const categoryArrJson = JSON.stringify(categoryArr)
321
+ const categoryArrParentJson = JSON.stringify(translateListToTree(categoryArr, '0'))
322
+
323
+ return `
324
+ <script id="categoriesChart">
325
+ var color = document.documentElement.getAttribute('data-theme') === 'light' ? '#4c4948' : 'rgba(255,255,255,0.7)'
326
+ var categoriesChart = echarts.init(document.getElementById('categories-chart'), 'light');
327
+ var categoryParentFlag = ${categoryParentFlag}
328
+ var categoriesOption = {
329
+ title: {
330
+ text: '文章分类统计图',
331
+ x: 'center',
332
+ textStyle: {
333
+ color: color
334
+ }
335
+ },
336
+ legend: {
337
+ top: 'bottom',
338
+ data: ${categoryNameJson},
339
+ textStyle: {
340
+ color: color
341
+ }
342
+ },
343
+ tooltip: {
344
+ trigger: 'item'
345
+ },
346
+ series: []
347
+ };
348
+ categoriesOption.series.push(
349
+ categoryParentFlag ?
350
+ {
351
+ nodeClick :false,
352
+ name: '文章篇数',
353
+ type: 'sunburst',
354
+ radius: ['15%', '90%'],
355
+ center: ['50%', '55%'],
356
+ sort: 'desc',
357
+ data: ${categoryArrParentJson},
358
+ itemStyle: {
359
+ borderColor: '#fff',
360
+ borderWidth: 2,
361
+ emphasis: {
362
+ focus: 'ancestor',
363
+ shadowBlur: 10,
364
+ shadowOffsetX: 0,
365
+ shadowColor: 'rgba(255, 255, 255, 0.5)'
366
+ }
367
+ }
368
+ }
369
+ :
370
+ {
371
+ name: '文章篇数',
372
+ type: 'pie',
373
+ radius: [30, 80],
374
+ roseType: 'area',
375
+ label: {
376
+ color: color,
377
+ formatter: '{b} : {c} ({d}%)'
378
+ },
379
+ data: ${categoryArrJson},
380
+ itemStyle: {
381
+ emphasis: {
382
+ shadowBlur: 10,
383
+ shadowOffsetX: 0,
384
+ shadowColor: 'rgba(255, 255, 255, 0.5)'
385
+ }
386
+ }
387
+ }
388
+ )
389
+ categoriesChart.setOption(categoriesOption);
390
+ window.addEventListener('resize', () => {
391
+ categoriesChart.resize();
392
+ });
393
+ categoriesChart.on('click', 'series', (event) => {
394
+ if(event.data.path) window.location.href = '/' + event.data.path;
395
+ });
396
+ </script>`
397
+ }
@@ -0,0 +1,18 @@
1
+ const moment = require('moment')
2
+
3
+ hexo.extend.helper.register('getArchiveLength', function (type) {
4
+ if (type !== 'year' && type !== 'month') {
5
+ type = 'year';
6
+ }
7
+ const posts = this.site.posts.sort('-date').data
8
+ let archive = {}
9
+ posts.forEach(post => {
10
+ const postdate = type === 'year' ? moment(post.date).format('YYYY') : moment(post.date).format('YYYY/MM');
11
+ if(!archive[postdate]){
12
+ archive[postdate] = 1
13
+ } else {
14
+ archive[postdate] ++
15
+ }
16
+ });
17
+ return archive
18
+ });
@@ -0,0 +1,16 @@
1
+ hexo.extend.helper.register('randomLinks', function(){
2
+ const links = []
3
+ const data = this.site.data.links.links
4
+ if(!data)return
5
+ data.forEach(x => {
6
+ if(x.type === "item"){
7
+ x.link_list.forEach(y => {
8
+ links.push({
9
+ name: y.name,
10
+ link: y.link
11
+ })
12
+ })
13
+ }
14
+ });
15
+ return `<script>const links=${JSON.stringify(links)};function travelling(){const link=links[utils.randomNum(links.length)];utils.snackbarShow('您即将前往 ⌈ '+link.name+' ⌋ , 安全性未知',false,3000);setTimeout(()=>{window.open(link.link,"_blank")},3000)};function randomLinksList(){let data='';for(let i=1;i<=3;i++){const link=links[utils.randomNum(links.length)];data+='<a class="footer-item" href="'+link.link+'" target="_blank" rel="noopener nofollow">'+link.name+'</a>'};document.getElementById('friend-links-in-footer').innerHTML=data + '<a class="footer-item" href="/links/">更多</a>'};</script>`
16
+ })