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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. package/_config.yml +5 -4
  2. package/layout/_partials/footer.pug +1 -1
  3. package/layout/_partials/head/head.pug +7 -1
  4. package/layout/_partials/header.pug +1 -1
  5. package/layout/_partials/layout.pug +0 -10
  6. package/layout/_partials/post/footer.pug +1 -2
  7. package/package.json +7 -2
  8. package/scripts/generaters/archive.js +1 -1
  9. package/scripts/generaters/script.js +44 -38
  10. package/scripts/helpers/asset.js +1 -1
  11. package/scripts/helpers/list_categories.js +0 -4
  12. package/scripts/plugin/lib/injects.js +1 -1
  13. package/source/js/_app/components/comments.ts +33 -0
  14. package/source/js/_app/components/sidebar.ts +7 -5
  15. package/source/js/_app/globals/globalVars.ts +1 -0
  16. package/source/js/_app/globals/handles.ts +6 -5
  17. package/source/js/_app/globals/themeColor.ts +1 -1
  18. package/source/js/_app/globals/thirdparty.ts +1 -1
  19. package/source/js/_app/globals/tools.ts +3 -2
  20. package/source/js/_app/library/anime.ts +6 -5
  21. package/source/js/_app/library/declare.d.ts +18 -9
  22. package/source/js/_app/library/loadFile.ts +3 -1
  23. package/source/js/_app/library/proto.ts +75 -77
  24. package/source/js/_app/library/vue.ts +38 -48
  25. package/source/js/_app/page/fancybox.ts +2 -1
  26. package/source/js/_app/page/post.ts +4 -3
  27. package/source/js/_app/page/search.ts +17 -11
  28. package/source/js/_app/page/tab.ts +3 -2
  29. package/source/js/_app/pjax/domInit.ts +5 -4
  30. package/source/js/_app/pjax/refresh.ts +5 -2
  31. package/source/js/_app/pjax/siteInit.ts +12 -7
  32. package/source/js/_app/player.ts +16 -15
  33. package/scripts/filters/locals.d.ts +0 -1
  34. package/scripts/filters/locals.ts +0 -59
  35. package/scripts/filters/post.d.ts +0 -0
  36. package/scripts/filters/post.ts +0 -6
  37. package/scripts/generaters/archive.d.ts +0 -1
  38. package/scripts/generaters/archive.ts +0 -144
  39. package/scripts/generaters/config.d.ts +0 -1
  40. package/scripts/generaters/config.ts +0 -52
  41. package/scripts/generaters/images.d.ts +0 -1
  42. package/scripts/generaters/images.ts +0 -26
  43. package/scripts/generaters/index.d.ts +0 -1
  44. package/scripts/generaters/index.ts +0 -110
  45. package/scripts/generaters/pages.d.ts +0 -0
  46. package/scripts/generaters/pages.ts +0 -16
  47. package/scripts/generaters/script.d.ts +0 -1
  48. package/scripts/generaters/script.ts +0 -110
  49. package/scripts/helpers/asset.d.ts +0 -1
  50. package/scripts/helpers/asset.ts +0 -158
  51. package/scripts/helpers/engine.d.ts +0 -1
  52. package/scripts/helpers/engine.ts +0 -171
  53. package/scripts/helpers/list_categories.d.ts +0 -1
  54. package/scripts/helpers/list_categories.ts +0 -104
  55. package/scripts/helpers/summary_ai.d.ts +0 -1
  56. package/scripts/helpers/summary_ai.ts +0 -100
  57. package/scripts/helpers/symbols_count_time.d.ts +0 -1
  58. package/scripts/helpers/symbols_count_time.ts +0 -76
  59. package/scripts/plugin/check.d.ts +0 -1
  60. package/scripts/plugin/check.ts +0 -35
  61. package/scripts/plugin/index.d.ts +0 -6
  62. package/scripts/plugin/index.ts +0 -52
  63. package/scripts/plugin/lib/injects-point.d.ts +0 -5
  64. package/scripts/plugin/lib/injects-point.ts +0 -20
  65. package/scripts/plugin/lib/injects.d.ts +0 -2
  66. package/scripts/plugin/lib/injects.ts +0 -101
  67. package/scripts/tags/links.d.ts +0 -1
  68. package/scripts/tags/links.ts +0 -75
  69. package/scripts/tags/media.d.ts +0 -1
  70. package/scripts/tags/media.ts +0 -19
  71. package/source/assets/beian.webp +0 -0
  72. package/source/js/_app/library/libtype.d.ts +0 -4
@@ -1,52 +0,0 @@
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
- })
@@ -1,5 +0,0 @@
1
- declare const _default: {
2
- views: string[];
3
- styles: string[];
4
- };
5
- export default _default;
@@ -1,20 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- declare const _default: (hexo: any) => void;
2
- export default _default;
@@ -1,101 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,75 +0,0 @@
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 })
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
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>`;
Binary file
@@ -1,4 +0,0 @@
1
- export {}
2
- declare global {
3
- const Vue: typeof import('vue')
4
- }