hexo-theme-shokax 0.3.12 → 0.4.0-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. package/README.md +10 -3
  2. package/README_en.MD +13 -5
  3. package/_config.yml +19 -16
  4. package/layout/_mixin/comment.pug +4 -4
  5. package/layout/_mixin/segment.pug +1 -1
  6. package/layout/_partials/head/head.pug +0 -1
  7. package/layout/_partials/post/post.pug +1 -1
  8. package/layout/_partials/post/reward.pug +1 -1
  9. package/layout/_partials/sidebar/overview.pug +1 -1
  10. package/package.json +11 -11
  11. package/scripts/filters/locals.d.ts +1 -0
  12. package/scripts/filters/locals.ts +59 -0
  13. package/scripts/filters/post.d.ts +0 -0
  14. package/scripts/filters/post.js +1 -1
  15. package/scripts/filters/post.ts +6 -0
  16. package/scripts/generaters/archive.d.ts +1 -0
  17. package/scripts/generaters/archive.ts +144 -0
  18. package/scripts/generaters/config.d.ts +1 -0
  19. package/scripts/generaters/config.ts +52 -0
  20. package/scripts/generaters/images.d.ts +1 -0
  21. package/scripts/generaters/images.ts +26 -0
  22. package/scripts/generaters/index.d.ts +1 -0
  23. package/scripts/generaters/index.ts +110 -0
  24. package/scripts/generaters/pages.d.ts +0 -0
  25. package/scripts/generaters/pages.ts +16 -0
  26. package/scripts/generaters/script.d.ts +1 -0
  27. package/scripts/generaters/script.js +25 -6
  28. package/scripts/generaters/script.ts +110 -0
  29. package/scripts/helpers/asset.d.ts +1 -0
  30. package/scripts/helpers/asset.ts +158 -0
  31. package/scripts/helpers/engine.d.ts +1 -0
  32. package/scripts/helpers/engine.ts +171 -0
  33. package/scripts/helpers/list_categories.d.ts +1 -0
  34. package/scripts/helpers/list_categories.ts +104 -0
  35. package/scripts/helpers/summary_ai.d.ts +1 -0
  36. package/scripts/helpers/summary_ai.js +1 -1
  37. package/scripts/helpers/summary_ai.ts +100 -0
  38. package/scripts/helpers/symbols_count_time.d.ts +1 -0
  39. package/scripts/helpers/symbols_count_time.ts +76 -0
  40. package/scripts/plugin/check.d.ts +1 -0
  41. package/scripts/plugin/check.ts +35 -0
  42. package/scripts/plugin/index.d.ts +6 -0
  43. package/scripts/plugin/index.ts +52 -0
  44. package/scripts/plugin/lib/injects-point.d.ts +5 -0
  45. package/scripts/plugin/lib/injects-point.ts +20 -0
  46. package/scripts/plugin/lib/injects.d.ts +2 -0
  47. package/scripts/plugin/lib/injects.ts +101 -0
  48. package/scripts/tags/links.d.ts +1 -0
  49. package/scripts/tags/links.ts +75 -0
  50. package/scripts/tags/media.d.ts +1 -0
  51. package/scripts/tags/media.ts +19 -0
  52. package/source/css/_common/components/tags/tabs.styl +3 -1
  53. package/source/css/_common/scaffolding/base.styl +6 -6
  54. package/source/css/_iconfont.styl +4 -0
  55. package/source/js/_app/components/sidebar.ts +237 -0
  56. package/source/js/_app/globals/globalVars.ts +98 -0
  57. package/source/js/_app/globals/handles.ts +122 -0
  58. package/source/js/_app/globals/themeColor.ts +64 -0
  59. package/source/js/_app/globals/thirdparty.ts +63 -0
  60. package/source/js/_app/globals/tools.ts +74 -0
  61. package/source/js/_app/library/anime.ts +109 -0
  62. package/source/js/_app/library/declare.d.ts +117 -0
  63. package/source/js/_app/library/dom.ts +26 -0
  64. package/source/js/_app/library/libtype.d.ts +4 -0
  65. package/source/js/_app/library/loadFile.ts +41 -0
  66. package/source/js/_app/library/proto.ts +143 -0
  67. package/source/js/_app/library/scriptPjax.ts +72 -0
  68. package/source/js/_app/library/storage.ts +12 -0
  69. package/source/js/_app/library/vue.ts +60 -0
  70. package/source/js/_app/page/common.ts +42 -0
  71. package/source/js/_app/page/fancybox.ts +70 -0
  72. package/source/js/_app/page/post.ts +265 -0
  73. package/source/js/_app/page/search.ts +129 -0
  74. package/source/js/_app/page/tab.ts +59 -0
  75. package/source/js/_app/pjax/domInit.ts +95 -0
  76. package/source/js/_app/pjax/refresh.ts +75 -0
  77. package/source/js/_app/pjax/siteInit.ts +67 -0
  78. package/source/js/_app/player.ts +798 -0
  79. package/source/css/twikoo.css +0 -2002
  80. package/source/js/_app/components/sidebar.js +0 -210
  81. package/source/js/_app/fireworks.js +0 -10
  82. package/source/js/_app/globals/globalVars.js +0 -80
  83. package/source/js/_app/globals/handles.js +0 -138
  84. package/source/js/_app/globals/themeColor.js +0 -62
  85. package/source/js/_app/globals/thirdparty.js +0 -71
  86. package/source/js/_app/globals/tools.js +0 -92
  87. package/source/js/_app/library/anime.js +0 -109
  88. package/source/js/_app/library/dom.js +0 -34
  89. package/source/js/_app/library/loadFile.js +0 -36
  90. package/source/js/_app/library/proto.js +0 -163
  91. package/source/js/_app/library/scriptPjax.js +0 -70
  92. package/source/js/_app/library/storage.js +0 -12
  93. package/source/js/_app/library/vue.js +0 -53
  94. package/source/js/_app/page/comment.js +0 -23
  95. package/source/js/_app/page/common.js +0 -41
  96. package/source/js/_app/page/fancybox.js +0 -65
  97. package/source/js/_app/page/post.js +0 -244
  98. package/source/js/_app/page/search.js +0 -118
  99. package/source/js/_app/page/tab.js +0 -53
  100. package/source/js/_app/pjax/domInit.js +0 -76
  101. package/source/js/_app/pjax/refresh.js +0 -53
  102. package/source/js/_app/pjax/siteInit.js +0 -49
  103. package/source/js/_app/player.js +0 -774
@@ -0,0 +1,104 @@
1
+ 'use strict'
2
+ /* global hexo */
3
+
4
+ const prepareQuery = (categories, parent) => {
5
+ const query = {
6
+ parent: undefined
7
+ }
8
+
9
+ if (parent) {
10
+ query.parent = parent
11
+ } else {
12
+ query.parent = { $exists: false }
13
+ }
14
+
15
+ return categories.find(query).sort('name', 1).filter(cat => cat.length)
16
+ }
17
+
18
+ hexo.extend.helper.register('_list_categories', function (depth = 0) {
19
+ // let hexo = this
20
+ const categories = this.site.categories
21
+
22
+ if (!categories || !categories.length) return ''
23
+
24
+ const hierarchicalList = (level, parent?) => {
25
+ let result = ''
26
+
27
+ prepareQuery(categories, parent).forEach((cat, i) => {
28
+ let child
29
+
30
+ if (level + 1 < depth) {
31
+ child = hierarchicalList(level + 1, cat._id)
32
+ }
33
+
34
+ const catname = `<a itemprop="url" href="${this.url_for(cat.path)}">${cat.name}</a><small>( ${cat.length} )</small>`
35
+
36
+ switch (level) {
37
+ case 0:
38
+ result += `<div><h2 class="item header">${catname}</h2>`
39
+ break
40
+
41
+ case 1:
42
+ result += `<h3 class="item section">${catname}</h3>`
43
+ break
44
+
45
+ case 2:
46
+ result += `<div class="item normal"><div class="title">${catname}</div></div>`
47
+ break
48
+ }
49
+
50
+ if (child) {
51
+ result += `${child}`
52
+ }
53
+
54
+ if (level === 0) {
55
+ result += '</div>'
56
+ }
57
+ })
58
+
59
+ return result
60
+ }
61
+
62
+ return hierarchicalList(0)
63
+ })
64
+
65
+ hexo.extend.helper.register('_category_prev', function (name) {
66
+ // let hexo = this
67
+ const categories = this.site.categories
68
+ if (!categories || !categories.length) return ''
69
+
70
+ let result = ''
71
+
72
+ categories.find({ name }).forEach((current) => {
73
+ if (current.parent) {
74
+ categories.find({ _id: current.parent }).forEach((cat, i) => {
75
+ result += `<a href="${this.url_for(cat.path)}">${cat.name}</a>`
76
+ })
77
+ }
78
+ })
79
+
80
+ return result
81
+ })
82
+
83
+ hexo.extend.helper.register('_category_posts', function (page) {
84
+ // let hexo = this
85
+ const categories = this.site.categories
86
+ if (!categories || !categories.length || !page.categories || !page.categories.length) return ''
87
+
88
+ let result = ''
89
+ const cat = page.categories.toArray()
90
+
91
+ categories.find({ _id: cat[cat.length - 1]._id }).forEach((category) => {
92
+ if (category.posts) {
93
+ category.posts.sort('date', 1).forEach((post) => {
94
+ let current = ''
95
+ if (post.path === page.path) {
96
+ current = ' class="active"'
97
+ }
98
+ result += `<li ${current}><a href="${this.url_for(post.path)}" rel="bookmark" title="${post.title}">${post.title}</a></li>`
99
+ })
100
+ }
101
+ })
102
+
103
+ return result
104
+ })
@@ -0,0 +1 @@
1
+ export {};
@@ -11,7 +11,7 @@ let db;
11
11
  function postMessage(path, content, dbPath, startMessage) {
12
12
  if (node_fs_1.default.existsSync('summary.json')) {
13
13
  // @ts-ignore
14
- db = JSON.parse(node_fs_1.default.readFileSync('summary.json'));
14
+ db = JSON.parse(node_fs_1.default.readFileSync('summary.json', { encoding: 'utf-8' }));
15
15
  }
16
16
  else {
17
17
  db = {};
@@ -0,0 +1,100 @@
1
+ import fs from 'node:fs'
2
+
3
+ function getContent (post) {
4
+ return post?.raw ?? post?._content ?? post.content
5
+ }
6
+
7
+ let db:object
8
+ function postMessage (path:string, content:string, dbPath:string, startMessage:string) {
9
+ if (fs.existsSync('summary.json')) {
10
+ // @ts-ignore
11
+ db = JSON.parse(fs.readFileSync('summary.json', { encoding: 'utf-8' }))
12
+ } else {
13
+ db = {}
14
+ }
15
+ const config = hexo.theme.config.summary
16
+ if (config.enable) {
17
+ if (typeof db?.[path] !== 'undefined' && typeof db?.[path]?.[dbPath] !== 'undefined') {
18
+ return db[path][dbPath]
19
+ } else {
20
+ if (typeof db?.[path] === 'undefined') {
21
+ db[path] = {}
22
+ } else {
23
+ db[path][dbPath] = ''
24
+ }
25
+ }
26
+ if (config.mode === 'openai') {
27
+ const request = () => {
28
+ fetch(`${config.openai.remote}/v1/chat/completions`, {
29
+ method: 'POST',
30
+ headers: requestHeaders,
31
+ body: JSON.stringify(requestBody)
32
+ }).then((response) => {
33
+ if (!response.ok) {
34
+ throw Error('ERROR: Failed to get summary from Openai API')
35
+ }
36
+ response.json().then((data:object) => {
37
+ // @ts-ignore
38
+ const summary = data.choices[0].message.content
39
+ try {
40
+ db[path][dbPath] = summary
41
+ } catch (e) {
42
+ db ??= {}
43
+ db[path] ??= {}
44
+ db[path][dbPath] ??= ''
45
+ db[path][dbPath] = summary
46
+ }
47
+ fs.writeFileSync('summary.json', JSON.stringify(db))
48
+ if (fs.existsSync('requested.lock')) {
49
+ fs.unlinkSync('requested.lock')
50
+ }
51
+ return summary
52
+ })
53
+ })
54
+ }
55
+
56
+ const checkTime = (waitTime:number) => {
57
+ if (fs.existsSync('request.lock')) {
58
+ if (fs.existsSync('requested.lock')) {
59
+ setTimeout(checkTime, 1000 * waitTime)
60
+ return
61
+ }
62
+ // Openai API 针对个人用户免费试用限制 3 RPM,这里是25s后发送请求
63
+ fs.writeFileSync('requested.lock', '')
64
+ setTimeout(request, 1000 * 2.5 * waitTime)
65
+ fs.unlinkSync('request.lock')
66
+ } else {
67
+ fs.writeFileSync('request.lock', '')
68
+ request()
69
+ }
70
+ }
71
+ const requestHeaders = {
72
+ 'Content-Type': 'application/json',
73
+ Authorization: `Bearer ${config.openai.apikey}`
74
+ }
75
+ const requestBody = {
76
+ model: 'gpt-3.5-turbo',
77
+ messages: [{ role: 'user', content: `${startMessage} ${content}` }],
78
+ temperature: 0.7
79
+ }
80
+ if (config.pricing === 'trial') {
81
+ hexo.log.info('Requesting OpenAI API... (3 RPM mode)')
82
+ hexo.log.info('It may take 20 minutes or more (depending on the number of articles, each one takes 25 seconds)')
83
+ checkTime(10)
84
+ } else {
85
+ hexo.log.info('Requesting OpenAI API... (60 RPM mode)')
86
+ checkTime(0.5)
87
+ }
88
+ } else {
89
+ // custom尚未支持
90
+ }
91
+ }
92
+ }
93
+
94
+ hexo.extend.helper.register('get_summary', (post) => {
95
+ return postMessage(post.path, getContent(post), 'summary', '请为下述文章提供一份200字以内的概括,使用中文回答且尽可能简洁: ')
96
+ })
97
+
98
+ hexo.extend.helper.register('get_introduce', () => {
99
+ return hexo.theme.config.summary.introduce
100
+ })
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +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 or later
6
+ https://github.com/theme-next/hexo-symbols-count-time/blob/master/LICENSE
7
+ */
8
+
9
+ import { stripHTML } from '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)
@@ -0,0 +1 @@
1
+ declare let findProblem: boolean;
@@ -0,0 +1,35 @@
1
+ /* global hexo */
2
+
3
+ let findProblem = false
4
+
5
+ hexo.on('generateBefore', function () {
6
+ if (hexo.config.syntax_highlighter) {
7
+ findProblem = true
8
+ hexo.log.error('[SXEC 101] Highlight.js or Prismjs enabled. The code block will render incomplete')
9
+ }
10
+ if (!hexo.config.markdown) {
11
+ findProblem = true
12
+ hexo.log.error(`[SXEC 102] Critical rendering plugins are missing or incorrectly configured.
13
+ Some features will be disabled or render incorrectly`)
14
+ }
15
+ if (parseInt(process.version.match(/\d{2,3}/)[0]) < 18) {
16
+ findProblem = true
17
+ hexo.log.error('[SXEC 103] Too old Node.js version, install the latest LTS version')
18
+ }
19
+ if (!hexo.config.title || !hexo.config.description || !hexo.config.language || !hexo.config.timezone || !hexo.config.url) {
20
+ findProblem = true
21
+ hexo.log.warn('[SXEC 201] Essential information(title, desc, lang, etc) config incorrectly, Page will render incorrectly')
22
+ }
23
+ if (hexo.theme.config.gitalk?.clientID || hexo.theme.config.giscus?.repo) {
24
+ findProblem = true
25
+ hexo.log.warn('[SXEC 202] You are using an deprecated feature and it was removed in the v0.3.10')
26
+ }
27
+ })
28
+
29
+ hexo.on('generateAfter', function () {
30
+ if (findProblem) {
31
+ hexo.log.warn(`The environment check found some problems that can lead to rendering errors, effect errors,
32
+ performance degradation, not working correctly, etc`)
33
+ hexo.log.warn('ShokaX has output them into console, read them to get more information. You can search error code in docs(For example, SXEC 101)')
34
+ }
35
+ })
@@ -0,0 +1,6 @@
1
+ /*!
2
+ index.js in next-theme/hexo-theme-next by next-theme
3
+ under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
4
+ https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
5
+ */
6
+ export {};
@@ -0,0 +1,52 @@
1
+ /*!
2
+ index.js in next-theme/hexo-theme-next by next-theme
3
+ under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
4
+ https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
5
+ */
6
+
7
+ import injects from './lib/injects'
8
+ import { version } from '../../package.json'
9
+ import * as fs from 'node:fs'
10
+
11
+ hexo.on('generateBefore', () => {
12
+ // 加载`theme_injects`过滤器
13
+ injects(hexo)
14
+ if (fs.existsSync('request.lock')) {
15
+ fs.unlinkSync('request.lock')
16
+ }
17
+ if (fs.existsSync('requested.lock')) {
18
+ fs.unlinkSync('requested.lock')
19
+ }
20
+ })
21
+
22
+ hexo.on('generateAfter', () => {
23
+ // 检查版本更新
24
+ fetch('https://api.github.com/repos/theme-shoka-x/hexo-theme-shokaX/releases/latest').then((res) => {
25
+ res.json().then((resp) => {
26
+ try {
27
+ const latest = resp.tag_name.replace('v', '').split('.')
28
+ const current = version.split('.')
29
+ let isOutdated = false
30
+ for (let i = 0; i < Math.max(latest.length, current.length); i++) {
31
+ if (!current[i] || latest[i] > current[i]) {
32
+ isOutdated = true
33
+ break
34
+ }
35
+ if (latest[i] < current[i]) {
36
+ break
37
+ }
38
+ }
39
+ if (isOutdated) {
40
+ hexo.log.warn(`Your theme ShokaX is outdated. Current version: v${current.join('.')}, latest version: v${latest.join('.')}`)
41
+ hexo.log.warn('Visit https://github.com/theme-shoka-x/hexo-theme-shokaX/releases for more information.')
42
+ }
43
+ } catch (e) {
44
+ hexo.log.warn('Failed to detect version info. Error message:')
45
+ hexo.log.warn(e)
46
+ }
47
+ }).catch((e) => {
48
+ hexo.log.warn('Failed to detect version info. Error message:')
49
+ hexo.log.warn(e)
50
+ })
51
+ })
52
+ })
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ views: string[];
3
+ styles: string[];
4
+ };
5
+ export default _default;
@@ -0,0 +1,20 @@
1
+ 'use strict'
2
+
3
+ export default {
4
+ views: [
5
+ 'head',
6
+ 'sidebar',
7
+ 'rightNav',
8
+ 'postMeta',
9
+ 'postBodyEnd',
10
+ 'footer',
11
+ 'bodyEnd',
12
+ 'comment',
13
+ 'status'
14
+ ],
15
+ styles: [
16
+ 'variable',
17
+ 'mixin',
18
+ 'style'
19
+ ]
20
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: (hexo: any) => void;
2
+ export default _default;
@@ -0,0 +1,101 @@
1
+ 'use strict'
2
+
3
+ /*!
4
+ inject.js in next-theme/hexo-theme-next by next-theme
5
+ under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
6
+ https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
7
+ */
8
+ import fs from 'node:fs'
9
+ import path from 'node:path'
10
+ import points from './injects-point'
11
+ const defaultExtname = '.pug'
12
+
13
+ interface viewConfig {
14
+ layout: string,
15
+ locals: object,
16
+ options: object,
17
+ order: number
18
+ }
19
+ class StylusInject {
20
+ files: Array<string>
21
+ base_dir: string
22
+ constructor (base_dir) {
23
+ this.base_dir = base_dir
24
+ this.files = []
25
+ }
26
+
27
+ push (file) {
28
+ this.files.push(path.resolve(this.base_dir, file))
29
+ }
30
+ }
31
+
32
+ // Defining view types
33
+ class ViewInject {
34
+ base_dir:string
35
+ raws: Array<object>
36
+ constructor (base_dir) {
37
+ this.base_dir = base_dir
38
+ this.raws = []
39
+ }
40
+
41
+ raw (name, raw, ...args) {
42
+ // Set default extname
43
+ if (path.extname(name) === '') {
44
+ name += defaultExtname
45
+ }
46
+ this.raws.push({ name, raw, args })
47
+ }
48
+
49
+ file (name, file, ...args) {
50
+ // Set default extname from file's extname
51
+ if (path.extname(name) === '') {
52
+ name += path.extname(file)
53
+ }
54
+ // Get absolute path base on hexo dir
55
+ this.raw(name, fs.readFileSync(path.resolve(this.base_dir, file), 'utf8'), ...args)
56
+ }
57
+ }
58
+
59
+ // Init injects
60
+ function initInject (base_dir) {
61
+ const injects = {}
62
+ points.styles.forEach(item => {
63
+ injects[item] = new StylusInject(base_dir)
64
+ })
65
+ points.views.forEach(item => {
66
+ injects[item] = new ViewInject(base_dir)
67
+ })
68
+ return injects
69
+ }
70
+
71
+ export default (hexo) => {
72
+ // Exec theme_inject filter
73
+ const injects = initInject(hexo.base_dir)
74
+ hexo.execFilterSync('theme_inject', injects)
75
+ hexo.theme.config.injects = {}
76
+
77
+ // Inject stylus
78
+ points.styles.forEach(type => {
79
+ hexo.theme.config.injects[type] = injects[type].files
80
+ })
81
+
82
+ // Inject views
83
+ points.views.forEach(type => {
84
+ const configs = Object.create(null)
85
+ hexo.theme.config.injects[type] = []
86
+ // Add or override view.
87
+ injects[type].raws.forEach((injectObj, index) => {
88
+ const name = `inject/${type}/${injectObj.name}`
89
+ hexo.theme.setView(name, injectObj.raw)
90
+ configs[name] = {
91
+ layout: name,
92
+ locals: injectObj.args[0],
93
+ options: injectObj.args[1],
94
+ order: injectObj.args[2] || index
95
+ }
96
+ })
97
+ // Views sort.
98
+ hexo.theme.config.injects[type] = Object.values(configs)
99
+ .sort((x:viewConfig, y:viewConfig) => x.order - y.order)
100
+ })
101
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,75 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import yaml from 'js-yaml'
4
+
5
+ /*
6
+ {% links %}
7
+ - site: #main title
8
+ owner: #alternate title for image tooltip (nullable)
9
+ url: #link of site
10
+ desc: #description (nullable)
11
+ image: #icon image (nullable)
12
+ color: #block color (nullable)
13
+ {% endlinks %}
14
+
15
+ {% linksfile [path] %}
16
+ */
17
+
18
+ interface siteLink {
19
+ site: string
20
+ owner?: string
21
+ url: string
22
+ desc?: string
23
+ image?: string
24
+ color?: string
25
+ }
26
+
27
+ function linkGrid (args:string[], content:string) {
28
+ const theme = hexo.theme.config as any
29
+
30
+ if (!args[0] && !content) {
31
+ return
32
+ }
33
+
34
+ if (args[0]) {
35
+ const filepath = path.join(hexo.source_dir, args[0])
36
+ if (fs.existsSync(filepath)) {
37
+ content = fs.readFileSync(filepath, { encoding: 'utf-8' })
38
+ }
39
+ }
40
+
41
+ if (!content) {
42
+ return
43
+ }
44
+
45
+ const list = yaml.load(content) as Array<siteLink>
46
+
47
+ let result = ''
48
+
49
+ list.forEach((item) => {
50
+ if (!item.url || !item.site) {
51
+ return
52
+ }
53
+
54
+ let item_image = item.image || theme.assets + '/404.png'
55
+
56
+ if (!item_image.startsWith('//') && !item_image.startsWith('http')) {
57
+ item_image = theme.statics + item_image
58
+ }
59
+
60
+ item.color = item.color ? ` style="--block-color:${item.color};"` : ''
61
+
62
+ result += `<div class="item" title="${item.owner || item.site}"${item.color}>`
63
+
64
+ result += `<a href="${item.url}" class="image" data-background-image="${item_image}"></a>
65
+ <div class="info">
66
+ <a href="${item.url}" class="title">${item.site}</a>
67
+ <p class="desc">${item.desc || item.url}</p>
68
+ </div></div>`
69
+ })
70
+
71
+ return `<div class="links">${result}</div>`
72
+ }
73
+
74
+ hexo.extend.tag.register('links', linkGrid, { ends: true })
75
+ hexo.extend.tag.register('linksfile', linkGrid, { ends: false, async: true })
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ 'use strict'
2
+ /* global hexo */
3
+ import yaml from '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>`;
@@ -39,12 +39,14 @@
39
39
  width: auto;
40
40
  height: auto;
41
41
  background: none;
42
- border-radius: 10px;
42
+ border-radius: 0;
43
43
  border-bottom: .125rem solid transparent;
44
44
  }
45
45
 
46
46
  &.active::before {
47
47
  border-bottom-color: var(--primary-color);
48
+ left: 0;
49
+ right: 0;
48
50
  }
49
51
  }
50
52
  }
@@ -149,12 +149,12 @@ input, textarea {
149
149
  @font-face {
150
150
  font-family: 'ic';
151
151
  font-display: swap;
152
- src: url('//at.alicdn.com/t/font_' + $iconfont + '.eot');
153
- src: url('//at.alicdn.com/t/font_' + $iconfont + '.eot?#iefix') format('embedded-opentype'),
154
- url('//at.alicdn.com/t/font_' + $iconfont + '.woff2') format('woff2'),
155
- url('//at.alicdn.com/t/font_' + $iconfont + '.woff') format('woff'),
156
- url('//at.alicdn.com/t/font_' + $iconfont + '.ttf') format('truetype'),
157
- url('//at.alicdn.com/t/font_' + $iconfont + '.svg#ic') format('svg');
152
+ src: url('//at.alicdn.com/t/c/font_' + $iconfont + '.eot');
153
+ src: url('//at.alicdn.com/t/c/font_' + $iconfont + '.eot?#iefix') format('embedded-opentype'),
154
+ url('//at.alicdn.com/t/c/font_' + $iconfont + '.woff2') format('woff2'),
155
+ url('//at.alicdn.com/t/c/font_' + $iconfont + '.woff') format('woff'),
156
+ url('//at.alicdn.com/t/c/font_' + $iconfont + '.ttf') format('truetype'),
157
+ url('//at.alicdn.com/t/c/font_' + $iconfont + '.svg#ic') format('svg');
158
158
  }
159
159
 
160
160
  @font-face {
@@ -449,3 +449,7 @@
449
449
  .i-cloud-music:before {
450
450
  content: "\e76a";
451
451
  }
452
+
453
+ .i-gitee:before {
454
+ content: "\e607";
455
+ }