hexo-theme-shokax 0.0.2-alpha1 → 0.0.2-alpha3

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 (159) hide show
  1. package/CODE_OF_CONDUCT.md +128 -0
  2. package/CONTRIBUTING.md +56 -0
  3. package/LICENSE +28 -28
  4. package/LICENSE-shoka +21 -21
  5. package/README.md +46 -53
  6. package/README_en.MD +25 -0
  7. package/_config.yml +392 -355
  8. package/_images.yml +100 -100
  9. package/languages/README.md +19 -19
  10. package/languages/default.yml +1 -1
  11. package/languages/en.yml +151 -151
  12. package/languages/ja.yml +146 -146
  13. package/languages/zh-CN.yml +154 -154
  14. package/languages/zh-HK.yml +146 -146
  15. package/languages/zh-TW.yml +146 -146
  16. package/layout/_alternate/atom.ejs +30 -30
  17. package/layout/_alternate/json.ejs +16 -16
  18. package/layout/_alternate/rss.ejs +34 -34
  19. package/layout/_mixin/breadcrumb.pug +33 -33
  20. package/layout/_mixin/card.pug +37 -37
  21. package/layout/_mixin/comment.pug +66 -12
  22. package/layout/_mixin/postmeta.pug +30 -30
  23. package/layout/_mixin/segment.pug +32 -32
  24. package/layout/_mixin/sidebar.pug +36 -36
  25. package/layout/_mixin/widgets.pug +31 -29
  26. package/layout/_partials/footer.pug +40 -40
  27. package/layout/_partials/head/head.pug +51 -58
  28. package/layout/_partials/head/head_com.pug +17 -17
  29. package/layout/_partials/head/pwa.pug +18 -18
  30. package/layout/_partials/header.pug +18 -20
  31. package/layout/_partials/layout.pug +143 -153
  32. package/layout/_partials/loading.pug +13 -13
  33. package/layout/_partials/pagination.pug +4 -4
  34. package/layout/_partials/post/copyright.pug +20 -20
  35. package/layout/_partials/post/footer.pug +14 -14
  36. package/layout/_partials/post/nav.pug +13 -13
  37. package/layout/_partials/post/post.pug +28 -27
  38. package/layout/_partials/post/reward.pug +18 -18
  39. package/layout/_partials/sidebar/menu.pug +37 -37
  40. package/layout/_partials/sidebar/overview.pug +41 -42
  41. package/layout/_partials/third-party/baidu-analytics.pug +11 -11
  42. package/layout/_partials/third-party/clarity.pug +8 -8
  43. package/layout/archive.pug +118 -118
  44. package/layout/category.pug +63 -63
  45. package/layout/index.pug +33 -33
  46. package/layout/page.pug +56 -56
  47. package/layout/post.pug +35 -35
  48. package/layout/tag.pug +43 -43
  49. package/package.json +35 -35
  50. package/scripts/filters/locals.js +59 -59
  51. package/scripts/filters/post.js +23 -23
  52. package/scripts/generaters/archive.js +141 -141
  53. package/scripts/generaters/config.js +43 -43
  54. package/scripts/generaters/images.js +26 -26
  55. package/scripts/generaters/index.js +110 -110
  56. package/scripts/generaters/pages.js +19 -19
  57. package/scripts/generaters/script.js +89 -89
  58. package/scripts/helpers/asset.js +183 -237
  59. package/scripts/helpers/engine.js +190 -190
  60. package/scripts/helpers/list_categories.js +140 -140
  61. package/scripts/helpers/symbols_count_time.js +76 -76
  62. package/scripts/plugin/index.js +6 -6
  63. package/scripts/plugin/lib/injects-point.js +19 -19
  64. package/scripts/plugin/lib/injects.js +89 -88
  65. package/scripts/tags/links.js +86 -86
  66. package/scripts/tags/media.js +19 -19
  67. package/source/assets/algolia_logo.svg +9 -9
  68. package/source/assets/logo.svg +16 -16
  69. package/source/css/_colors.styl +207 -207
  70. package/source/css/_common/components/components.styl +6 -6
  71. package/source/css/_common/components/highlight/highlight.styl +353 -353
  72. package/source/css/_common/components/highlight/operation.styl +21 -21
  73. package/source/css/_common/components/pages/collapse.styl +119 -119
  74. package/source/css/_common/components/pages/home.styl +385 -385
  75. package/source/css/_common/components/pages/pages.styl +56 -56
  76. package/source/css/_common/components/pages/tag-cloud.styl +12 -12
  77. package/source/css/_common/components/post/breadcrumb.styl +39 -39
  78. package/source/css/_common/components/post/copyright.styl +41 -41
  79. package/source/css/_common/components/post/expand.styl +264 -264
  80. package/source/css/_common/components/post/footer.styl +11 -11
  81. package/source/css/_common/components/post/header.styl +79 -79
  82. package/source/css/_common/components/post/nav.styl +63 -63
  83. package/source/css/_common/components/post/post.styl +29 -29
  84. package/source/css/_common/components/post/reward.styl +50 -50
  85. package/source/css/_common/components/post/rtl.styl +12 -12
  86. package/source/css/_common/components/post/tags.styl +39 -39
  87. package/source/css/_common/components/tags/collapse.styl +72 -72
  88. package/source/css/_common/components/tags/container.styl +49 -49
  89. package/source/css/_common/components/tags/label.styl +12 -12
  90. package/source/css/_common/components/tags/links.styl +77 -77
  91. package/source/css/_common/components/tags/list.styl +131 -131
  92. package/source/css/_common/components/tags/note.styl +70 -70
  93. package/source/css/_common/components/tags/player.styl +361 -361
  94. package/source/css/_common/components/tags/quiz.styl +200 -200
  95. package/source/css/_common/components/tags/tabs.styl +83 -83
  96. package/source/css/_common/components/tags/tags.styl +9 -9
  97. package/source/css/_common/components/third-party/loading.styl +222 -222
  98. package/source/css/_common/components/third-party/mermaid/class.styl +90 -90
  99. package/source/css/_common/components/third-party/mermaid/flowchart.styl +72 -72
  100. package/source/css/_common/components/third-party/mermaid/gantt.styl +251 -251
  101. package/source/css/_common/components/third-party/mermaid/git.styl +7 -7
  102. package/source/css/_common/components/third-party/mermaid/mermaid.styl +37 -37
  103. package/source/css/_common/components/third-party/mermaid/pie.styl +9 -9
  104. package/source/css/_common/components/third-party/mermaid/sequence.styl +95 -95
  105. package/source/css/_common/components/third-party/mermaid/state.styl +130 -130
  106. package/source/css/_common/components/third-party/pace.styl +18 -18
  107. package/source/css/_common/components/third-party/search.styl +167 -167
  108. package/source/css/_common/components/third-party/theme.styl +151 -151
  109. package/source/css/_common/components/third-party/third-party.styl +22 -22
  110. package/source/css/_common/components/third-party/valine.styl +548 -548
  111. package/source/css/_common/components/third-party/widgets.styl +57 -57
  112. package/source/css/_common/outline/footer/footer.styl +69 -69
  113. package/source/css/_common/outline/header/brand.styl +77 -77
  114. package/source/css/_common/outline/header/header.styl +20 -20
  115. package/source/css/_common/outline/header/image.styl +79 -79
  116. package/source/css/_common/outline/header/menu.styl +117 -117
  117. package/source/css/_common/outline/header/nav.styl +81 -81
  118. package/source/css/_common/outline/header/right.styl +15 -15
  119. package/source/css/_common/outline/header/tool.styl +207 -207
  120. package/source/css/_common/outline/header/waves.styl +50 -50
  121. package/source/css/_common/outline/mobile.styl +46 -46
  122. package/source/css/_common/outline/outline.styl +78 -78
  123. package/source/css/_common/outline/sidebar/author.styl +59 -59
  124. package/source/css/_common/outline/sidebar/dimmer.styl +23 -23
  125. package/source/css/_common/outline/sidebar/menu.styl +63 -63
  126. package/source/css/_common/outline/sidebar/quick.styl +43 -43
  127. package/source/css/_common/outline/sidebar/related.styl +56 -56
  128. package/source/css/_common/outline/sidebar/sidebar.styl +75 -75
  129. package/source/css/_common/outline/sidebar/social.styl +69 -69
  130. package/source/css/_common/outline/sidebar/state.styl +37 -37
  131. package/source/css/_common/outline/sidebar/tab.styl +71 -71
  132. package/source/css/_common/outline/sidebar/toc.styl +47 -47
  133. package/source/css/_common/scaffolding/animate.styl +318 -318
  134. package/source/css/_common/scaffolding/base.styl +172 -172
  135. package/source/css/_common/scaffolding/buttons.styl +48 -48
  136. package/source/css/_common/scaffolding/divider.styl +36 -36
  137. package/source/css/_common/scaffolding/iconfont.styl +443 -443
  138. package/source/css/_common/scaffolding/normalize.styl +289 -289
  139. package/source/css/_common/scaffolding/pagination.styl +81 -81
  140. package/source/css/_common/scaffolding/ribbon.styl +38 -38
  141. package/source/css/_common/scaffolding/scaffolding.styl +14 -14
  142. package/source/css/_common/scaffolding/scrollbar.styl +37 -37
  143. package/source/css/_common/scaffolding/tables.styl +50 -50
  144. package/source/css/_common/scaffolding/tip.styl +19 -19
  145. package/source/css/_common/scaffolding/toggles.styl +59 -59
  146. package/source/css/_iconfont.styl +451 -451
  147. package/source/css/_mixins.styl +146 -146
  148. package/source/css/_variables.styl +89 -89
  149. package/source/css/app.styl +36 -38
  150. package/source/css/comment.styl +5 -5
  151. package/source/css/mermaid.styl +5 -5
  152. package/source/js/_app/components.js +330 -330
  153. package/source/js/_app/global.js +317 -317
  154. package/source/js/_app/library.js +302 -302
  155. package/source/js/_app/page.js +623 -623
  156. package/source/js/_app/player.js +748 -748
  157. package/source/js/_app/vue.js +43 -43
  158. package/layout/_partials/third-party/qweather.pug +0 -35
  159. package/source/css/plugin.styl +0 -174
@@ -1,76 +1,76 @@
1
- 'use strict'
2
- /* global hexo */
3
- /*
4
- hexo-symbols-count-time by theme-next
5
- under GNU Lesser General Public License v3.0
6
- https://github.com/theme-next/hexo-symbols-count-time/blob/master/LICENSE
7
- */
8
-
9
- const { stripHTML } = require('hexo-util')
10
-
11
- const config = hexo.config.symbols_count_time = Object.assign({
12
- symbols: true,
13
- time: true,
14
- total_symbols: true,
15
- total_time: true,
16
- exclude_codeblock: false,
17
- awl: 4,
18
- wpm: 275,
19
- suffix: 'mins.'
20
- }, hexo.config.symbols_count_time)
21
-
22
- function getSymbols (post) {
23
- return post?._content?.length ?? post?.content?.length ?? post.length
24
- }
25
-
26
- function getSymbolsTotal (site) {
27
- let symbolsResultCount = 0
28
- site.posts.forEach((post) => {
29
- symbolsResultCount += getSymbols(post)
30
- })
31
- return symbolsResultCount
32
- }
33
-
34
- function getFormatTime (minutes, suffix) {
35
- const fHours = Math.floor(minutes / 60)
36
- let fMinutes = Math.floor(minutes - (fHours * 60))
37
- if (fMinutes < 1) {
38
- fMinutes = 1 // 0 => 1
39
- }
40
- return fHours < 1
41
- ? fMinutes + ' ' + suffix // < 59 => 59 mins.
42
- : fHours + ':' + ('00' + fMinutes).slice(-2) // = 61 => 1:01
43
- }
44
-
45
- hexo.extend.helper.register('symbolsCount', function (post) {
46
- let symbolsResult = getSymbols(post)
47
- if (symbolsResult > 9999) {
48
- symbolsResult = Math.round(symbolsResult / 1000) + 'k' // > 9999 => 11k
49
- } else if (symbolsResult > 999) {
50
- symbolsResult = Math.round(symbolsResult / 100) / 10 + 'k' // > 999 => 1.1k
51
- } // < 999 => 111
52
- return symbolsResult
53
- })
54
-
55
- hexo.extend.helper.register('symbolsTime', function (post, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
56
- const minutes = Math.round(getSymbols(post) / (awl * wpm))
57
- return getFormatTime(minutes, suffix)
58
- })
59
-
60
- hexo.extend.helper.register('symbolsCountTotal', function (site) {
61
- const symbolsResultTotal = getSymbolsTotal(site)
62
- return symbolsResultTotal < 1000000
63
- ? Math.round(symbolsResultTotal / 1000) + 'k' // < 999k => 111k
64
- : Math.round(symbolsResultTotal / 100000) / 10 + 'm' // > 999k => 1.1m
65
- })
66
-
67
- hexo.extend.helper.register('symbolsTimeTotal', function (site, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
68
- const minutes = Math.round(getSymbolsTotal(site) / (awl * wpm))
69
- return getFormatTime(minutes, suffix)
70
- })
71
-
72
- hexo.extend.filter.register('after_post_render', (data) => {
73
- let { content } = data
74
- if (config.exclude_codeblock) content = content.replace(/<pre>.*?<\/pre>/g, '')
75
- data.length = stripHTML(content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '').length
76
- }, 0)
1
+ 'use strict'
2
+ /* global hexo */
3
+ /*
4
+ hexo-symbols-count-time by theme-next
5
+ under GNU Lesser General Public License v3.0
6
+ https://github.com/theme-next/hexo-symbols-count-time/blob/master/LICENSE
7
+ */
8
+
9
+ const { stripHTML } = require('hexo-util')
10
+
11
+ const config = hexo.config.symbols_count_time = Object.assign({
12
+ symbols: true,
13
+ time: true,
14
+ total_symbols: true,
15
+ total_time: true,
16
+ exclude_codeblock: false,
17
+ awl: 4,
18
+ wpm: 275,
19
+ suffix: 'mins.'
20
+ }, hexo.config.symbols_count_time)
21
+
22
+ function getSymbols (post) {
23
+ return post?._content?.length ?? post?.content?.length ?? post.length
24
+ }
25
+
26
+ function getSymbolsTotal (site) {
27
+ let symbolsResultCount = 0
28
+ site.posts.forEach((post) => {
29
+ symbolsResultCount += getSymbols(post)
30
+ })
31
+ return symbolsResultCount
32
+ }
33
+
34
+ function getFormatTime (minutes, suffix) {
35
+ const fHours = Math.floor(minutes / 60)
36
+ let fMinutes = Math.floor(minutes - (fHours * 60))
37
+ if (fMinutes < 1) {
38
+ fMinutes = 1 // 0 => 1
39
+ }
40
+ return fHours < 1
41
+ ? fMinutes + ' ' + suffix // < 59 => 59 mins.
42
+ : fHours + ':' + ('00' + fMinutes).slice(-2) // = 61 => 1:01
43
+ }
44
+
45
+ hexo.extend.helper.register('symbolsCount', function (post) {
46
+ let symbolsResult = getSymbols(post)
47
+ if (symbolsResult > 9999) {
48
+ symbolsResult = Math.round(symbolsResult / 1000) + 'k' // > 9999 => 11k
49
+ } else if (symbolsResult > 999) {
50
+ symbolsResult = Math.round(symbolsResult / 100) / 10 + 'k' // > 999 => 1.1k
51
+ } // < 999 => 111
52
+ return symbolsResult
53
+ })
54
+
55
+ hexo.extend.helper.register('symbolsTime', function (post, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
56
+ const minutes = Math.round(getSymbols(post) / (awl * wpm))
57
+ return getFormatTime(minutes, suffix)
58
+ })
59
+
60
+ hexo.extend.helper.register('symbolsCountTotal', function (site) {
61
+ const symbolsResultTotal = getSymbolsTotal(site)
62
+ return symbolsResultTotal < 1000000
63
+ ? Math.round(symbolsResultTotal / 1000) + 'k' // < 999k => 111k
64
+ : Math.round(symbolsResultTotal / 100000) / 10 + 'm' // > 999k => 1.1m
65
+ })
66
+
67
+ hexo.extend.helper.register('symbolsTimeTotal', function (site, awl = config.awl, wpm = config.wpm, suffix = config.suffix) {
68
+ const minutes = Math.round(getSymbolsTotal(site) / (awl * wpm))
69
+ return getFormatTime(minutes, suffix)
70
+ })
71
+
72
+ hexo.extend.filter.register('after_post_render', (data) => {
73
+ let { content } = data
74
+ if (config.exclude_codeblock) content = content.replace(/<pre>.*?<\/pre>/g, '')
75
+ data.length = stripHTML(content).replace(/\r?\n|\r/g, '').replace(/\s+/g, '').length
76
+ }, 0)
@@ -1,6 +1,6 @@
1
- /* global hexo */
2
-
3
- hexo.on('generateBefore', () => {
4
- // 加载`theme_injects`过滤器
5
- require('./lib/injects')(hexo)
6
- })
1
+ /* global hexo */
2
+
3
+ hexo.on('generateBefore', () => {
4
+ // 加载`theme_injects`过滤器
5
+ require('./lib/injects')(hexo)
6
+ })
@@ -1,19 +1,19 @@
1
- 'use strict'
2
-
3
- module.exports = {
4
- views: [
5
- 'head',
6
- 'sidebar',
7
- 'rightNav',
8
- 'postMeta',
9
- 'postBodyEnd',
10
- 'footer',
11
- 'bodyEnd',
12
- 'comment'
13
- ],
14
- styles: [
15
- 'variable',
16
- 'mixin',
17
- 'style'
18
- ]
19
- }
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ views: [
5
+ 'head',
6
+ 'sidebar',
7
+ 'rightNav',
8
+ 'postMeta',
9
+ 'postBodyEnd',
10
+ 'footer',
11
+ 'bodyEnd',
12
+ 'comment'
13
+ ],
14
+ styles: [
15
+ 'variable',
16
+ 'mixin',
17
+ 'style'
18
+ ]
19
+ }
@@ -1,88 +1,89 @@
1
- 'use strict'
2
-
3
- const fs = require('fs')
4
- const path = require('path')
5
- const points = require('./injects-point')
6
- const defaultExtname = '.pug'
7
-
8
- // Defining stylus types
9
- class StylusInject {
10
- constructor (base_dir) {
11
- this.base_dir = base_dir
12
- this.files = []
13
- }
14
-
15
- push (file) {
16
- // Get absolute path base on hexo dir
17
- this.files.push(path.resolve(this.base_dir, file))
18
- }
19
- }
20
-
21
- // Defining view types
22
- class ViewInject {
23
- constructor (base_dir) {
24
- this.base_dir = base_dir
25
- this.raws = []
26
- }
27
-
28
- raw (name, raw, ...args) {
29
- // Set default extname
30
- if (path.extname(name) === '') {
31
- name += defaultExtname
32
- }
33
- this.raws.push({ name, raw, args })
34
- }
35
-
36
- file (name, file, ...args) {
37
- // Set default extname from file's extname
38
- if (path.extname(name) === '') {
39
- name += path.extname(file)
40
- }
41
- // Get absolute path base on hexo dir
42
- this.raw(name, fs.readFileSync(path.resolve(this.base_dir, file), 'utf8'), ...args)
43
- }
44
- }
45
-
46
- // Init injects
47
- function initInject (base_dir) {
48
- const injects = {}
49
- points.styles.forEach(item => {
50
- injects[item] = new StylusInject(base_dir)
51
- })
52
- points.views.forEach(item => {
53
- injects[item] = new ViewInject(base_dir)
54
- })
55
- return injects
56
- }
57
-
58
- module.exports = (hexo) => {
59
- // Exec theme_inject filter
60
- const injects = initInject(hexo.base_dir)
61
- hexo.execFilterSync('theme_inject', injects)
62
- hexo.theme.config.injects = {}
63
-
64
- // Inject stylus
65
- points.styles.forEach(type => {
66
- hexo.theme.config.injects[type] = injects[type].files
67
- })
68
-
69
- // Inject views
70
- points.views.forEach(type => {
71
- const configs = Object.create(null)
72
- hexo.theme.config.injects[type] = []
73
- // Add or override view.
74
- injects[type].raws.forEach((injectObj, index) => {
75
- const name = `inject/${type}/${injectObj.name}`
76
- hexo.theme.setView(name, injectObj.raw)
77
- configs[name] = {
78
- layout: name,
79
- locals: injectObj.args[0],
80
- options: injectObj.args[1],
81
- order: injectObj.args[2] || index
82
- }
83
- })
84
- // Views sort.
85
- hexo.theme.config.injects[type] = Object.values(configs)
86
- .sort((x, y) => x.order - y.order)
87
- })
88
- }
1
+ 'use strict'
2
+
3
+ // 插件部分参考自theme-next
4
+ const fs = require('fs')
5
+ const path = require('path')
6
+ const points = require('./injects-point')
7
+ const defaultExtname = '.pug'
8
+
9
+ // Defining stylus types
10
+ class StylusInject {
11
+ constructor (base_dir) {
12
+ this.base_dir = base_dir
13
+ this.files = []
14
+ }
15
+
16
+ push (file) {
17
+ // Get absolute path base on hexo dir
18
+ this.files.push(path.resolve(this.base_dir, file))
19
+ }
20
+ }
21
+
22
+ // Defining view types
23
+ class ViewInject {
24
+ constructor (base_dir) {
25
+ this.base_dir = base_dir
26
+ this.raws = []
27
+ }
28
+
29
+ raw (name, raw, ...args) {
30
+ // Set default extname
31
+ if (path.extname(name) === '') {
32
+ name += defaultExtname
33
+ }
34
+ this.raws.push({ name, raw, args })
35
+ }
36
+
37
+ file (name, file, ...args) {
38
+ // Set default extname from file's extname
39
+ if (path.extname(name) === '') {
40
+ name += path.extname(file)
41
+ }
42
+ // Get absolute path base on hexo dir
43
+ this.raw(name, fs.readFileSync(path.resolve(this.base_dir, file), 'utf8'), ...args)
44
+ }
45
+ }
46
+
47
+ // Init injects
48
+ function initInject (base_dir) {
49
+ const injects = {}
50
+ points.styles.forEach(item => {
51
+ injects[item] = new StylusInject(base_dir)
52
+ })
53
+ points.views.forEach(item => {
54
+ injects[item] = new ViewInject(base_dir)
55
+ })
56
+ return injects
57
+ }
58
+
59
+ module.exports = (hexo) => {
60
+ // Exec theme_inject filter
61
+ const injects = initInject(hexo.base_dir)
62
+ hexo.execFilterSync('theme_inject', injects)
63
+ hexo.theme.config.injects = {}
64
+
65
+ // Inject stylus
66
+ points.styles.forEach(type => {
67
+ hexo.theme.config.injects[type] = injects[type].files
68
+ })
69
+
70
+ // Inject views
71
+ points.views.forEach(type => {
72
+ const configs = Object.create(null)
73
+ hexo.theme.config.injects[type] = []
74
+ // Add or override view.
75
+ injects[type].raws.forEach((injectObj, index) => {
76
+ const name = `inject/${type}/${injectObj.name}`
77
+ hexo.theme.setView(name, injectObj.raw)
78
+ configs[name] = {
79
+ layout: name,
80
+ locals: injectObj.args[0],
81
+ options: injectObj.args[1],
82
+ order: injectObj.args[2] || index
83
+ }
84
+ })
85
+ // Views sort.
86
+ hexo.theme.config.injects[type] = Object.values(configs)
87
+ .sort((x, y) => x.order - y.order)
88
+ })
89
+ }
@@ -1,86 +1,86 @@
1
- /* global hexo */
2
- 'use strict'
3
- /*
4
- {% links %}
5
- - site: #main title
6
- owner: #alternate title for image tooltip (nullable)
7
- url: #link of site
8
- desc: #description (nullable)
9
- image: #icon image (nullable)
10
- color: #block color (nullable)
11
- {% endlinks %}
12
-
13
- {% linksfile [path] %}
14
- */
15
-
16
- const fs = require('fs')
17
- const path = require('path')
18
- const yaml = require('js-yaml')
19
- // const url = require('url')
20
-
21
- function linkGrid (args, content) {
22
- const theme = hexo.theme.config
23
-
24
- if (!args[0] && !content) {
25
- return
26
- }
27
-
28
- if (args[0]) {
29
- const filepath = path.join(hexo.source_dir, args[0])
30
- if (fs.existsSync(filepath)) {
31
- content = fs.readFileSync(filepath)
32
- }
33
- }
34
-
35
- if (!content) {
36
- return
37
- }
38
-
39
- const siteHost = new URL(hexo.config.url).hostname || hexo.config.url
40
-
41
- const list = yaml.load(content)
42
-
43
- let result = ''
44
-
45
- list.forEach((item) => {
46
- if (!item.url || !item.site) {
47
- return
48
- }
49
-
50
- let urlparam = {}
51
-
52
- if (item.url) {
53
- urlparam = new URL(item.url)
54
- }
55
-
56
- let item_image = item.image || theme.images + '/404.png'
57
-
58
- if (!item_image.startsWith('//') && !item_image.startsWith('http')) {
59
- item_image = theme.statics + item_image
60
- }
61
-
62
- item.color = item.color ? ` style="--block-color:${item.color};"` : ''
63
-
64
- result += `<div class="item" title="${item.owner || item.site}"${item.color}>`
65
-
66
- if (urlparam.protocol && urlparam.hostname !== siteHost) {
67
- const durl = Buffer.from(item.url).toString('base64')
68
- result += `<span class="exturl image" data-url="${durl}" data-background-image="${item_image}"></span>
69
- <div class="info">
70
- <span class="exturl title" data-url="${durl}">${item.site}</span>
71
- <p class="desc">${item.desc || item.url}</p>
72
- </div></div>`
73
- } else {
74
- result += `<a href="${item.url}" class="image" data-background-image="${item_image}"></a>
75
- <div class="info">
76
- <a href="${item.url}" class="title">${item.site}</a>
77
- <p class="desc">${item.desc || item.url}</p>
78
- </div></div>`
79
- }
80
- })
81
-
82
- return `<div class="links">${result}</div>`
83
- }
84
-
85
- hexo.extend.tag.register('links', linkGrid, { ends: true })
86
- hexo.extend.tag.register('linksfile', linkGrid, { ends: false, async: true })
1
+ /* global hexo */
2
+ 'use strict'
3
+ /*
4
+ {% links %}
5
+ - site: #main title
6
+ owner: #alternate title for image tooltip (nullable)
7
+ url: #link of site
8
+ desc: #description (nullable)
9
+ image: #icon image (nullable)
10
+ color: #block color (nullable)
11
+ {% endlinks %}
12
+
13
+ {% linksfile [path] %}
14
+ */
15
+
16
+ const fs = require('fs')
17
+ const path = require('path')
18
+ const yaml = require('js-yaml')
19
+ // const url = require('url')
20
+
21
+ function linkGrid (args, content) {
22
+ const theme = hexo.theme.config
23
+
24
+ if (!args[0] && !content) {
25
+ return
26
+ }
27
+
28
+ if (args[0]) {
29
+ const filepath = path.join(hexo.source_dir, args[0])
30
+ if (fs.existsSync(filepath)) {
31
+ content = fs.readFileSync(filepath)
32
+ }
33
+ }
34
+
35
+ if (!content) {
36
+ return
37
+ }
38
+
39
+ const siteHost = new URL(hexo.config.url).hostname || hexo.config.url
40
+
41
+ const list = yaml.load(content)
42
+
43
+ let result = ''
44
+
45
+ list.forEach((item) => {
46
+ if (!item.url || !item.site) {
47
+ return
48
+ }
49
+
50
+ let urlparam = {}
51
+
52
+ if (item.url) {
53
+ urlparam = new URL(item.url)
54
+ }
55
+
56
+ let item_image = item.image || theme.images + '/404.png'
57
+
58
+ if (!item_image.startsWith('//') && !item_image.startsWith('http')) {
59
+ item_image = theme.statics + item_image
60
+ }
61
+
62
+ item.color = item.color ? ` style="--block-color:${item.color};"` : ''
63
+
64
+ result += `<div class="item" title="${item.owner || item.site}"${item.color}>`
65
+
66
+ if (urlparam.protocol && urlparam.hostname !== siteHost) {
67
+ const durl = Buffer.from(item.url).toString('base64')
68
+ result += `<span class="exturl image" data-url="${durl}" data-background-image="${item_image}"></span>
69
+ <div class="info">
70
+ <span class="exturl title" data-url="${durl}">${item.site}</span>
71
+ <p class="desc">${item.desc || item.url}</p>
72
+ </div></div>`
73
+ } else {
74
+ result += `<a href="${item.url}" class="image" data-background-image="${item_image}"></a>
75
+ <div class="info">
76
+ <a href="${item.url}" class="title">${item.site}</a>
77
+ <p class="desc">${item.desc || item.url}</p>
78
+ </div></div>`
79
+ }
80
+ })
81
+
82
+ return `<div class="links">${result}</div>`
83
+ }
84
+
85
+ hexo.extend.tag.register('links', linkGrid, { ends: true })
86
+ hexo.extend.tag.register('linksfile', linkGrid, { ends: false, async: true })
@@ -1,19 +1,19 @@
1
- 'use strict'
2
- /* global hexo */
3
- const yaml = require('js-yaml')
4
-
5
- function postMedia (args, content) {
6
- if (!args[0] || !content) {
7
- return
8
- }
9
- const list = yaml.load(content)
10
- switch (args[0]) {
11
- case 'video':
12
- case 'audio':
13
- return `<div class="media-container"><div class="player" data-type="${args[0]}" data-src='${JSON.stringify(list)}'></div></div>`
14
- }
15
- }
16
-
17
- hexo.extend.tag.register('media', postMedia, { ends: true })
18
-
19
- // return `<video src="${args}" preload="metadata" controls playsinline poster="">Sorry, your browser does not support the video tag.</video>`;
1
+ 'use strict'
2
+ /* global hexo */
3
+ const yaml = require('js-yaml')
4
+
5
+ function postMedia (args, content) {
6
+ if (!args[0] || !content) {
7
+ return
8
+ }
9
+ const list = yaml.load(content)
10
+ switch (args[0]) {
11
+ case 'video':
12
+ case 'audio':
13
+ return `<div class="media-container"><div class="player" data-type="${args[0]}" data-src='${JSON.stringify(list)}'></div></div>`
14
+ }
15
+ }
16
+
17
+ hexo.extend.tag.register('media', postMedia, { ends: true })
18
+
19
+ // return `<video src="${args}" preload="metadata" controls playsinline poster="">Sorry, your browser does not support the video tag.</video>`;
@@ -1,9 +1,9 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1366 362">
2
- <linearGradient id="a" x1="428.258" x2="434.145" y1="404.15" y2="409.85" gradientUnits="userSpaceOnUse" gradientTransform="matrix(94.045 0 0 -94.072 -40381.527 38479.52)">
3
- <stop offset="0" stop-color="#00aeff"/>
4
- <stop offset="1" stop-color="#3369e7"/>
5
- </linearGradient>
6
- <path fill="url(#a)" d="M61.8 15.4h242.8c23.9 0 43.4 19.4 43.4 43.4v242.9c0 23.9-19.4 43.4-43.4 43.4H61.8c-23.9 0-43.4-19.4-43.4-43.4v-243c0-23.9 19.4-43.3 43.4-43.3z"/>
7
- <path fill="#FFF" d="M187 98.7c-51.4 0-93.1 41.7-93.1 93.2S135.6 285 187 285s93.1-41.7 93.1-93.2-41.6-93.1-93.1-93.1zm0 158.8c-36.2 0-65.6-29.4-65.6-65.6s29.4-65.6 65.6-65.6 65.6 29.4 65.6 65.6-29.3 65.6-65.6 65.6zm0-117.8v48.9c0 1.4 1.5 2.4 2.8 1.7l43.4-22.5c1-.5 1.3-1.7.8-2.7-9-15.8-25.7-26.6-45-27.3-1 0-2 .8-2 1.9zm-60.8-35.9l-5.7-5.7c-5.6-5.6-14.6-5.6-20.2 0l-6.8 6.8c-5.6 5.6-5.6 14.6 0 20.2l5.6 5.6c.9.9 2.2.7 3-.2 3.3-4.5 6.9-8.8 10.9-12.8 4.1-4.1 8.3-7.7 12.9-11 1-.6 1.1-2 .3-2.9zM217.5 89V77.7c0-7.9-6.4-14.3-14.3-14.3h-33.3c-7.9 0-14.3 6.4-14.3 14.3v11.6c0 1.3 1.2 2.2 2.5 1.9 9.3-2.7 19.1-4.1 29-4.1 9.5 0 18.9 1.3 28 3.8 1.2.3 2.4-.6 2.4-1.9z"/>
8
- <path fill="#182359" d="M842.5 267.6c0 26.7-6.8 46.2-20.5 58.6-13.7 12.4-34.6 18.6-62.8 18.6-10.3 0-31.7-2-48.8-5.8l6.3-31c14.3 3 33.2 3.8 43.1 3.8 15.7 0 26.9-3.2 33.6-9.6s10-15.9 10-28.5v-6.4c-3.9 1.9-9 3.8-15.3 5.8-6.3 1.9-13.6 2.9-21.8 2.9-10.8 0-20.6-1.7-29.5-5.1-8.9-3.4-16.6-8.4-22.9-15-6.3-6.6-11.3-14.9-14.8-24.8s-5.3-27.6-5.3-40.6c0-12.2 1.9-27.5 5.6-37.7 3.8-10.2 9.2-19 16.5-26.3 7.2-7.3 16-12.9 26.3-17s22.4-6.7 35.5-6.7c12.7 0 24.4 1.6 35.8 3.5 11.4 1.9 21.1 3.9 29 6.1v155.2zm-108.7-77.2c0 16.4 3.6 34.6 10.8 42.2 7.2 7.6 16.5 11.4 27.9 11.4 6.2 0 12.1-.9 17.6-2.6 5.5-1.7 9.9-3.7 13.4-6.1v-97.1c-2.8-.6-14.5-3-25.8-3.3-14.2-.4-25 5.4-32.6 14.7-7.5 9.3-11.3 25.6-11.3 40.8zm294.3 0c0 13.2-1.9 23.2-5.8 34.1s-9.4 20.2-16.5 27.9c-7.1 7.7-15.6 13.7-25.6 17.9s-25.4 6.6-33.1 6.6c-7.7-.1-23-2.3-32.9-6.6-9.9-4.3-18.4-10.2-25.5-17.9-7.1-7.7-12.6-17-16.6-27.9s-6-20.9-6-34.1c0-13.2 1.8-25.9 5.8-36.7 4-10.8 9.6-20 16.8-27.7s15.8-13.6 25.6-17.8c9.9-4.2 20.8-6.2 32.6-6.2s22.7 2.1 32.7 6.2c10 4.2 18.6 10.1 25.6 17.8 7.1 7.7 12.6 16.9 16.6 27.7 4.2 10.8 6.3 23.5 6.3 36.7zm-40 .1c0-16.9-3.7-31-10.9-40.8-7.2-9.9-17.3-14.8-30.2-14.8-12.9 0-23 4.9-30.2 14.8-7.2 9.9-10.7 23.9-10.7 40.8 0 17.1 3.6 28.6 10.8 38.5 7.2 10 17.3 14.9 30.2 14.9 12.9 0 23-5 30.2-14.9 7.2-10 10.8-21.4 10.8-38.5zm127.1 86.4c-64.1.3-64.1-51.8-64.1-60.1L1051 32l39.1-6.2v183.6c0 4.7 0 34.5 25.1 34.6v32.9zm68.9 0h-39.3V108.1l39.3-6.2v175zm-19.7-193.5c13.1 0 23.8-10.6 23.8-23.7S1177.6 36 1164.4 36s-23.8 10.6-23.8 23.7 10.7 23.7 23.8 23.7zm117.4 18.6c12.9 0 23.8 1.6 32.6 4.8 8.8 3.2 15.9 7.7 21.1 13.4s8.9 13.5 11.1 21.7c2.3 8.2 3.4 17.2 3.4 27.1v100.6c-6 1.3-15.1 2.8-27.3 4.6s-25.9 2.7-41.1 2.7c-10.1 0-19.4-1-27.7-2.9-8.4-1.9-15.5-5-21.5-9.3-5.9-4.3-10.5-9.8-13.9-16.6-3.3-6.8-5-16.4-5-26.4 0-9.6 1.9-15.7 5.6-22.3 3.8-6.6 8.9-12 15.3-16.2 6.5-4.2 13.9-7.2 22.4-9s17.4-2.7 26.6-2.7c4.3 0 8.8.3 13.6.8s9.8 1.4 15.2 2.7v-6.4c0-4.5-.5-8.8-1.6-12.8-1.1-4.1-3-7.6-5.6-10.7-2.7-3.1-6.2-5.5-10.6-7.2s-10-3-16.7-3c-9 0-17.2 1.1-24.7 2.4-7.5 1.3-13.7 2.8-18.4 4.5l-4.7-32.1c4.9-1.7 12.2-3.4 21.6-5.1s19.5-2.6 30.3-2.6zm3.3 141.9c12 0 20.9-.7 27.1-1.9v-39.8c-2.2-.6-5.3-1.3-9.4-1.9-4.1-.6-8.6-1-13.6-1-4.3 0-8.7.3-13.1 1-4.4.6-8.4 1.8-11.9 3.5s-6.4 4.1-8.5 7.2c-2.2 3.1-3.2 4.9-3.2 9.6 0 9.2 3.2 14.5 9 18 5.9 3.6 13.7 5.3 23.6 5.3zM512.9 103c12.9 0 23.8 1.6 32.6 4.8 8.8 3.2 15.9 7.7 21.1 13.4 5.3 5.8 8.9 13.5 11.1 21.7 2.3 8.2 3.4 17.2 3.4 27.1v100.6c-6 1.3-15.1 2.8-27.3 4.6-12.2 1.8-25.9 2.7-41.1 2.7-10.1 0-19.4-1-27.7-2.9-8.4-1.9-15.5-5-21.5-9.3-5.9-4.3-10.5-9.8-13.9-16.6-3.3-6.8-5-16.4-5-26.4 0-9.6 1.9-15.7 5.6-22.3 3.8-6.6 8.9-12 15.3-16.2 6.5-4.2 13.9-7.2 22.4-9s17.4-2.7 26.6-2.7c4.3 0 8.8.3 13.6.8 4.7.5 9.8 1.4 15.2 2.7v-6.4c0-4.5-.5-8.8-1.6-12.8-1.1-4.1-3-7.6-5.6-10.7-2.7-3.1-6.2-5.5-10.6-7.2-4.4-1.7-10-3-16.7-3-9 0-17.2 1.1-24.7 2.4-7.5 1.3-13.7 2.8-18.4 4.5l-4.7-32.1c4.9-1.7 12.2-3.4 21.6-5.1 9.4-1.8 19.5-2.6 30.3-2.6zm3.4 142c12 0 20.9-.7 27.1-1.9v-39.8c-2.2-.6-5.3-1.3-9.4-1.9-4.1-.6-8.6-1-13.6-1-4.3 0-8.7.3-13.1 1-4.4.6-8.4 1.8-11.9 3.5s-6.4 4.1-8.5 7.2c-2.2 3.1-3.2 4.9-3.2 9.6 0 9.2 3.2 14.5 9 18s13.7 5.3 23.6 5.3zm158.5 31.9c-64.1.3-64.1-51.8-64.1-60.1L610.6 32l39.1-6.2v183.6c0 4.7 0 34.5 25.1 34.6v32.9z"/>
9
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1366 362">
2
+ <linearGradient id="a" x1="428.258" x2="434.145" y1="404.15" y2="409.85" gradientUnits="userSpaceOnUse" gradientTransform="matrix(94.045 0 0 -94.072 -40381.527 38479.52)">
3
+ <stop offset="0" stop-color="#00aeff"/>
4
+ <stop offset="1" stop-color="#3369e7"/>
5
+ </linearGradient>
6
+ <path fill="url(#a)" d="M61.8 15.4h242.8c23.9 0 43.4 19.4 43.4 43.4v242.9c0 23.9-19.4 43.4-43.4 43.4H61.8c-23.9 0-43.4-19.4-43.4-43.4v-243c0-23.9 19.4-43.3 43.4-43.3z"/>
7
+ <path fill="#FFF" d="M187 98.7c-51.4 0-93.1 41.7-93.1 93.2S135.6 285 187 285s93.1-41.7 93.1-93.2-41.6-93.1-93.1-93.1zm0 158.8c-36.2 0-65.6-29.4-65.6-65.6s29.4-65.6 65.6-65.6 65.6 29.4 65.6 65.6-29.3 65.6-65.6 65.6zm0-117.8v48.9c0 1.4 1.5 2.4 2.8 1.7l43.4-22.5c1-.5 1.3-1.7.8-2.7-9-15.8-25.7-26.6-45-27.3-1 0-2 .8-2 1.9zm-60.8-35.9l-5.7-5.7c-5.6-5.6-14.6-5.6-20.2 0l-6.8 6.8c-5.6 5.6-5.6 14.6 0 20.2l5.6 5.6c.9.9 2.2.7 3-.2 3.3-4.5 6.9-8.8 10.9-12.8 4.1-4.1 8.3-7.7 12.9-11 1-.6 1.1-2 .3-2.9zM217.5 89V77.7c0-7.9-6.4-14.3-14.3-14.3h-33.3c-7.9 0-14.3 6.4-14.3 14.3v11.6c0 1.3 1.2 2.2 2.5 1.9 9.3-2.7 19.1-4.1 29-4.1 9.5 0 18.9 1.3 28 3.8 1.2.3 2.4-.6 2.4-1.9z"/>
8
+ <path fill="#182359" d="M842.5 267.6c0 26.7-6.8 46.2-20.5 58.6-13.7 12.4-34.6 18.6-62.8 18.6-10.3 0-31.7-2-48.8-5.8l6.3-31c14.3 3 33.2 3.8 43.1 3.8 15.7 0 26.9-3.2 33.6-9.6s10-15.9 10-28.5v-6.4c-3.9 1.9-9 3.8-15.3 5.8-6.3 1.9-13.6 2.9-21.8 2.9-10.8 0-20.6-1.7-29.5-5.1-8.9-3.4-16.6-8.4-22.9-15-6.3-6.6-11.3-14.9-14.8-24.8s-5.3-27.6-5.3-40.6c0-12.2 1.9-27.5 5.6-37.7 3.8-10.2 9.2-19 16.5-26.3 7.2-7.3 16-12.9 26.3-17s22.4-6.7 35.5-6.7c12.7 0 24.4 1.6 35.8 3.5 11.4 1.9 21.1 3.9 29 6.1v155.2zm-108.7-77.2c0 16.4 3.6 34.6 10.8 42.2 7.2 7.6 16.5 11.4 27.9 11.4 6.2 0 12.1-.9 17.6-2.6 5.5-1.7 9.9-3.7 13.4-6.1v-97.1c-2.8-.6-14.5-3-25.8-3.3-14.2-.4-25 5.4-32.6 14.7-7.5 9.3-11.3 25.6-11.3 40.8zm294.3 0c0 13.2-1.9 23.2-5.8 34.1s-9.4 20.2-16.5 27.9c-7.1 7.7-15.6 13.7-25.6 17.9s-25.4 6.6-33.1 6.6c-7.7-.1-23-2.3-32.9-6.6-9.9-4.3-18.4-10.2-25.5-17.9-7.1-7.7-12.6-17-16.6-27.9s-6-20.9-6-34.1c0-13.2 1.8-25.9 5.8-36.7 4-10.8 9.6-20 16.8-27.7s15.8-13.6 25.6-17.8c9.9-4.2 20.8-6.2 32.6-6.2s22.7 2.1 32.7 6.2c10 4.2 18.6 10.1 25.6 17.8 7.1 7.7 12.6 16.9 16.6 27.7 4.2 10.8 6.3 23.5 6.3 36.7zm-40 .1c0-16.9-3.7-31-10.9-40.8-7.2-9.9-17.3-14.8-30.2-14.8-12.9 0-23 4.9-30.2 14.8-7.2 9.9-10.7 23.9-10.7 40.8 0 17.1 3.6 28.6 10.8 38.5 7.2 10 17.3 14.9 30.2 14.9 12.9 0 23-5 30.2-14.9 7.2-10 10.8-21.4 10.8-38.5zm127.1 86.4c-64.1.3-64.1-51.8-64.1-60.1L1051 32l39.1-6.2v183.6c0 4.7 0 34.5 25.1 34.6v32.9zm68.9 0h-39.3V108.1l39.3-6.2v175zm-19.7-193.5c13.1 0 23.8-10.6 23.8-23.7S1177.6 36 1164.4 36s-23.8 10.6-23.8 23.7 10.7 23.7 23.8 23.7zm117.4 18.6c12.9 0 23.8 1.6 32.6 4.8 8.8 3.2 15.9 7.7 21.1 13.4s8.9 13.5 11.1 21.7c2.3 8.2 3.4 17.2 3.4 27.1v100.6c-6 1.3-15.1 2.8-27.3 4.6s-25.9 2.7-41.1 2.7c-10.1 0-19.4-1-27.7-2.9-8.4-1.9-15.5-5-21.5-9.3-5.9-4.3-10.5-9.8-13.9-16.6-3.3-6.8-5-16.4-5-26.4 0-9.6 1.9-15.7 5.6-22.3 3.8-6.6 8.9-12 15.3-16.2 6.5-4.2 13.9-7.2 22.4-9s17.4-2.7 26.6-2.7c4.3 0 8.8.3 13.6.8s9.8 1.4 15.2 2.7v-6.4c0-4.5-.5-8.8-1.6-12.8-1.1-4.1-3-7.6-5.6-10.7-2.7-3.1-6.2-5.5-10.6-7.2s-10-3-16.7-3c-9 0-17.2 1.1-24.7 2.4-7.5 1.3-13.7 2.8-18.4 4.5l-4.7-32.1c4.9-1.7 12.2-3.4 21.6-5.1s19.5-2.6 30.3-2.6zm3.3 141.9c12 0 20.9-.7 27.1-1.9v-39.8c-2.2-.6-5.3-1.3-9.4-1.9-4.1-.6-8.6-1-13.6-1-4.3 0-8.7.3-13.1 1-4.4.6-8.4 1.8-11.9 3.5s-6.4 4.1-8.5 7.2c-2.2 3.1-3.2 4.9-3.2 9.6 0 9.2 3.2 14.5 9 18 5.9 3.6 13.7 5.3 23.6 5.3zM512.9 103c12.9 0 23.8 1.6 32.6 4.8 8.8 3.2 15.9 7.7 21.1 13.4 5.3 5.8 8.9 13.5 11.1 21.7 2.3 8.2 3.4 17.2 3.4 27.1v100.6c-6 1.3-15.1 2.8-27.3 4.6-12.2 1.8-25.9 2.7-41.1 2.7-10.1 0-19.4-1-27.7-2.9-8.4-1.9-15.5-5-21.5-9.3-5.9-4.3-10.5-9.8-13.9-16.6-3.3-6.8-5-16.4-5-26.4 0-9.6 1.9-15.7 5.6-22.3 3.8-6.6 8.9-12 15.3-16.2 6.5-4.2 13.9-7.2 22.4-9s17.4-2.7 26.6-2.7c4.3 0 8.8.3 13.6.8 4.7.5 9.8 1.4 15.2 2.7v-6.4c0-4.5-.5-8.8-1.6-12.8-1.1-4.1-3-7.6-5.6-10.7-2.7-3.1-6.2-5.5-10.6-7.2-4.4-1.7-10-3-16.7-3-9 0-17.2 1.1-24.7 2.4-7.5 1.3-13.7 2.8-18.4 4.5l-4.7-32.1c4.9-1.7 12.2-3.4 21.6-5.1 9.4-1.8 19.5-2.6 30.3-2.6zm3.4 142c12 0 20.9-.7 27.1-1.9v-39.8c-2.2-.6-5.3-1.3-9.4-1.9-4.1-.6-8.6-1-13.6-1-4.3 0-8.7.3-13.1 1-4.4.6-8.4 1.8-11.9 3.5s-6.4 4.1-8.5 7.2c-2.2 3.1-3.2 4.9-3.2 9.6 0 9.2 3.2 14.5 9 18s13.7 5.3 23.6 5.3zm158.5 31.9c-64.1.3-64.1-51.8-64.1-60.1L610.6 32l39.1-6.2v183.6c0 4.7 0 34.5 25.1 34.6v32.9z"/>
9
+ </svg>