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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. package/_config.yml +5 -4
  2. package/languages/README.md +22 -0
  3. package/languages/ar.yml +153 -0
  4. package/languages/de.yml +153 -0
  5. package/languages/es.yml +153 -0
  6. package/languages/fr.yml +153 -0
  7. package/languages/hi.yml +153 -0
  8. package/languages/id.yml +153 -0
  9. package/languages/it.yml +153 -0
  10. package/languages/ko.yml +153 -0
  11. package/languages/nl.yml +153 -0
  12. package/languages/pl.yml +153 -0
  13. package/languages/pt.yml +153 -0
  14. package/languages/ru.yml +153 -0
  15. package/languages/tr.yml +153 -0
  16. package/languages/vi.yml +153 -0
  17. package/layout/_mixin/comment.pug +2 -37
  18. package/layout/_partials/footer.pug +1 -1
  19. package/layout/_partials/head/head.pug +7 -3
  20. package/layout/_partials/header.pug +1 -1
  21. package/layout/_partials/layout.pug +1 -10
  22. package/layout/_partials/post/footer.pug +0 -9
  23. package/package.json +8 -2
  24. package/scripts/generaters/archive.js +1 -1
  25. package/scripts/generaters/script.js +63 -39
  26. package/scripts/helpers/asset.js +3 -72
  27. package/scripts/helpers/list_categories.js +0 -4
  28. package/scripts/plugin/lib/injects.js +1 -1
  29. package/source/js/_app/components/comments.ts +60 -0
  30. package/source/js/_app/components/sidebar.ts +7 -5
  31. package/source/js/_app/components/tcomments.ts +41 -0
  32. package/source/js/_app/globals/globalVars.ts +1 -0
  33. package/source/js/_app/globals/handles.ts +6 -5
  34. package/source/js/_app/globals/themeColor.ts +1 -1
  35. package/source/js/_app/globals/thirdparty.ts +1 -1
  36. package/source/js/_app/globals/tools.ts +3 -2
  37. package/source/js/_app/library/anime.ts +6 -5
  38. package/source/js/_app/library/declare.d.ts +25 -9
  39. package/source/js/_app/library/loadFile.ts +3 -1
  40. package/source/js/_app/library/proto.ts +75 -77
  41. package/source/js/_app/library/vue.ts +38 -48
  42. package/source/js/_app/page/fancybox.ts +2 -1
  43. package/source/js/_app/page/post.ts +4 -3
  44. package/source/js/_app/page/search.ts +17 -11
  45. package/source/js/_app/page/tab.ts +3 -2
  46. package/source/js/_app/pjax/domInit.ts +5 -4
  47. package/source/js/_app/pjax/refresh.ts +20 -2
  48. package/source/js/_app/pjax/siteInit.ts +12 -7
  49. package/source/js/_app/player.ts +16 -15
  50. package/scripts/filters/locals.d.ts +0 -1
  51. package/scripts/filters/locals.ts +0 -59
  52. package/scripts/filters/post.d.ts +0 -0
  53. package/scripts/filters/post.ts +0 -6
  54. package/scripts/generaters/archive.d.ts +0 -1
  55. package/scripts/generaters/archive.ts +0 -144
  56. package/scripts/generaters/config.d.ts +0 -1
  57. package/scripts/generaters/config.ts +0 -52
  58. package/scripts/generaters/images.d.ts +0 -1
  59. package/scripts/generaters/images.ts +0 -26
  60. package/scripts/generaters/index.d.ts +0 -1
  61. package/scripts/generaters/index.ts +0 -110
  62. package/scripts/generaters/pages.d.ts +0 -0
  63. package/scripts/generaters/pages.ts +0 -16
  64. package/scripts/generaters/script.d.ts +0 -1
  65. package/scripts/generaters/script.ts +0 -110
  66. package/scripts/helpers/asset.d.ts +0 -1
  67. package/scripts/helpers/asset.ts +0 -158
  68. package/scripts/helpers/engine.d.ts +0 -1
  69. package/scripts/helpers/engine.ts +0 -171
  70. package/scripts/helpers/list_categories.d.ts +0 -1
  71. package/scripts/helpers/list_categories.ts +0 -104
  72. package/scripts/helpers/summary_ai.d.ts +0 -1
  73. package/scripts/helpers/summary_ai.ts +0 -100
  74. package/scripts/helpers/symbols_count_time.d.ts +0 -1
  75. package/scripts/helpers/symbols_count_time.ts +0 -76
  76. package/scripts/plugin/check.d.ts +0 -1
  77. package/scripts/plugin/check.ts +0 -35
  78. package/scripts/plugin/index.d.ts +0 -6
  79. package/scripts/plugin/index.ts +0 -52
  80. package/scripts/plugin/lib/injects-point.d.ts +0 -5
  81. package/scripts/plugin/lib/injects-point.ts +0 -20
  82. package/scripts/plugin/lib/injects.d.ts +0 -2
  83. package/scripts/plugin/lib/injects.ts +0 -101
  84. package/scripts/tags/links.d.ts +0 -1
  85. package/scripts/tags/links.ts +0 -75
  86. package/scripts/tags/media.d.ts +0 -1
  87. package/scripts/tags/media.ts +0 -19
  88. package/source/assets/beian.webp +0 -0
  89. package/source/js/_app/library/libtype.d.ts +0 -4
@@ -3,58 +3,48 @@ import { transition } from './anime'
3
3
  import { $dom } from './dom'
4
4
  import { BODY } from '../globals/globalVars'
5
5
  import { changeTheme } from '../globals/themeColor'
6
-
6
+ import { child, createChild, setDisplay } from './proto'
7
7
  export function initVue () {
8
- Vue.createApp(
9
- {
10
- data () {
11
- return {
12
-
13
- }
14
- },
15
- methods: {
16
- changeThemeByBtn () {
17
- let c: { (): void; (): void; (): void }
18
- const btn = $dom('.theme').child('.ic')
8
+ function changeThemeByBtn () {
9
+ let c: { (): void; (): void; (): void }
10
+ const btn = child($dom('.theme'), '.ic')
19
11
 
20
- const neko = BODY.createChild('div', {
21
- id: 'neko',
22
- innerHTML: '<div class="planet"><div class="sun"></div><div class="moon"></div></div><div class="body"><div class="face"><section class="eyes left"><span class="pupil"></span></section><section class="eyes right"><span class="pupil"></span></section><span class="nose"></span></div></div>'
23
- })
12
+ const neko = createChild(BODY, 'div', {
13
+ id: 'neko',
14
+ innerHTML: '<div class="planet"><div class="sun"></div><div class="moon"></div></div><div class="body"><div class="face"><section class="eyes left"><span class="pupil"></span></section><section class="eyes right"><span class="pupil"></span></section><span class="nose"></span></div></div>'
15
+ })
24
16
 
25
- const hideNeko = () => {
26
- transition(neko, {
27
- // @ts-ignore
28
- delay: 2500,
29
- opacity: 0
30
- }, () => {
31
- BODY.removeChild(neko)
32
- })
33
- }
17
+ const hideNeko = () => {
18
+ transition(neko, {
19
+ // @ts-ignore
20
+ delay: 2500,
21
+ opacity: 0
22
+ }, () => {
23
+ BODY.removeChild(neko)
24
+ })
25
+ }
34
26
 
35
- if (btn.hasClass('i-sun')) {
36
- c = () => {
37
- neko.addClass('dark')
38
- changeTheme('dark')
39
- $storage.set('theme', 'dark')
40
- hideNeko()
41
- }
42
- } else {
43
- neko.addClass('dark')
44
- c = () => {
45
- neko.removeClass('dark')
46
- changeTheme()
47
- $storage.set('theme', 'light')
48
- hideNeko()
49
- }
50
- }
51
- transition(neko, 1, () => {
52
- setTimeout(c, 210)
53
- }, () => {
54
- neko.display('block')
55
- })
56
- }
27
+ if (btn.hasClass('i-sun')) {
28
+ c = () => {
29
+ neko.addClass('dark')
30
+ changeTheme('dark')
31
+ $storage.set('theme', 'dark')
32
+ hideNeko()
33
+ }
34
+ } else {
35
+ neko.addClass('dark')
36
+ c = () => {
37
+ neko.removeClass('dark')
38
+ changeTheme()
39
+ $storage.set('theme', 'light')
40
+ hideNeko()
57
41
  }
58
42
  }
59
- ).mount('#rightNav')
43
+ transition(neko, 1, () => {
44
+ setTimeout(c, 210)
45
+ }, () => {
46
+ setDisplay(neko, 'block')
47
+ })
48
+ }
49
+ child($dom('#rightNav'), '.theme .ic').addEventListener('click', changeThemeByBtn)
60
50
  }
@@ -1,5 +1,6 @@
1
1
  import { $dom } from '../library/dom'
2
2
  import { vendorCss, vendorJs } from '../library/loadFile'
3
+ import { insertAfter } from '../library/proto'
3
4
 
4
5
  export const postFancybox = (p:string) => {
5
6
  if ($dom(p + ' .md img')) {
@@ -38,7 +39,7 @@ export const postFancybox = (p:string) => {
38
39
  const txt = document.createTextNode(info)
39
40
  para.appendChild(txt)
40
41
  para.addClass(captionClass)
41
- element.insertAfter(para)
42
+ insertAfter(element, para)
42
43
  }
43
44
  })
44
45
 
@@ -4,6 +4,7 @@ import { clipBoard, showtip } from '../globals/tools'
4
4
  import { BODY } from '../globals/globalVars'
5
5
  import { pageScroll, transition } from '../library/anime'
6
6
  import { mediaPlayer } from '../player'
7
+ import { getDisplay, setDisplay, wrapObject } from '../library/proto'
7
8
 
8
9
  export const postBeauty = () => {
9
10
  if (!$dom('.md')) { return }
@@ -57,7 +58,7 @@ export const postBeauty = () => {
57
58
  })
58
59
 
59
60
  $dom.each('.md table', (element) => {
60
- element.wrapObject({
61
+ wrapObject(element, {
61
62
  className: 'table-container'
62
63
  })
63
64
  })
@@ -174,11 +175,11 @@ export const postBeauty = () => {
174
175
  element.addEventListener('click', (event) => {
175
176
  event.preventDefault()
176
177
  const qr = $dom('#qr')
177
- if (qr.display() === 'inline-flex') {
178
+ if (getDisplay(qr) === 'inline-flex') {
178
179
  transition(qr, 0)
179
180
  } else {
180
181
  transition(qr, 1, () => {
181
- qr.display('inline-flex')
182
+ setDisplay(qr, 'inline-flex')
182
183
  }) // slideUpBigIn
183
184
  }
184
185
  })
@@ -1,12 +1,17 @@
1
- import { BODY, setSiteSearch, siteSearch } from '../globals/globalVars'
1
+ import { BODY, CONFIG, setSiteSearch, siteSearch } from '../globals/globalVars'
2
2
  import { transition } from '../library/anime'
3
3
  import { $dom } from '../library/dom'
4
+ import { searchBox, configure, stats, hits, pagination } from 'instantsearch.js/es/widgets'
5
+ import type { HitHighlightResult } from 'instantsearch.js/es/types/results'
6
+ import instantsearch from 'instantsearch.js'
7
+ import algoliasearch from 'algoliasearch/lite'
8
+ import {createChild} from "../library/proto";
4
9
 
5
10
  export function algoliaSearch (pjax) {
6
11
  if (CONFIG.search === null) { return }
7
12
 
8
13
  if (!siteSearch) {
9
- setSiteSearch(BODY.createChild('div', {
14
+ setSiteSearch(createChild(BODY, 'div', {
10
15
  id: 'search',
11
16
  innerHTML: '<div class="inner"><div class="header"><span class="icon"><i class="ic i-search"></i></span><div class="search-input-container"></div><span class="close-btn"><i class="ic i-times-circle"></i></span></div><div class="results"><div class="inner"><div id="search-stats"></div><div id="search-hits"></div><div id="search-pagination"></div></div></div></div>'
12
17
  }))
@@ -15,8 +20,9 @@ export function algoliaSearch (pjax) {
15
20
  const search = instantsearch({
16
21
  indexName: CONFIG.search.indexName,
17
22
  searchClient: algoliasearch(CONFIG.search.appID, CONFIG.search.apiKey),
23
+ // TODO 移除弃用函数
18
24
  searchFunction (helper) {
19
- const searchInput = <HTMLInputElement><unknown>$dom('.search-input')
25
+ const searchInput = $dom('.search-input') as HTMLInputElement
20
26
  if (searchInput.value) {
21
27
  helper.search()
22
28
  }
@@ -29,11 +35,11 @@ export function algoliaSearch (pjax) {
29
35
 
30
36
  // Registering Widgets
31
37
  search.addWidgets([
32
- instantsearch.widgets.configure({
38
+ configure({
33
39
  hitsPerPage: CONFIG.search.hits.per_page || 10
34
40
  }),
35
41
 
36
- instantsearch.widgets.searchBox({
42
+ searchBox({
37
43
  container: '.search-input-container',
38
44
  placeholder: LOCAL.search.placeholder,
39
45
  // Hide default icons of algolia search
@@ -45,24 +51,24 @@ export function algoliaSearch (pjax) {
45
51
  }
46
52
  }),
47
53
 
48
- instantsearch.widgets.stats({
54
+ stats({
49
55
  container: '#search-stats',
50
56
  templates: {
51
57
  text (data) {
52
58
  const stats = LOCAL.search.stats
53
- .replace(/\$\{hits}/, data.nbHits)
54
- .replace(/\$\{time}/, data.processingTimeMS)
59
+ .replace(/\$\{hits}/, data.nbHits.toString())
60
+ .replace(/\$\{time}/, data.processingTimeMS.toString())
55
61
  return stats + '<span class="algolia-powered"></span><hr>'
56
62
  }
57
63
  }
58
64
  }),
59
65
 
60
- instantsearch.widgets.hits({
66
+ hits({
61
67
  container: '#search-hits',
62
68
  templates: {
63
69
  item (data) {
64
70
  const cats = data.categories ? '<span>' + data.categories.join('<i class="ic i-angle-right"></i>') + '</span>' : ''
65
- return '<a href="' + CONFIG.root + data.path + '">' + cats + data._highlightResult.title.value + '</a>'
71
+ return '<a href="' + CONFIG.root + data.path + '">' + cats + (data._highlightResult.title as HitHighlightResult).value + '</a>'
66
72
  },
67
73
  empty (data) {
68
74
  return '<div id="hits-empty">' +
@@ -75,7 +81,7 @@ export function algoliaSearch (pjax) {
75
81
  }
76
82
  }),
77
83
 
78
- instantsearch.widgets.pagination({
84
+ pagination({
79
85
  container: '#search-pagination',
80
86
  scrollTo: false,
81
87
  showFirst: false,
@@ -1,5 +1,6 @@
1
1
  import { pageScroll } from '../library/anime'
2
2
  import { $dom } from '../library/dom'
3
+ import { createChild } from '../library/proto'
3
4
 
4
5
  export const tabFormat = () => {
5
6
  // tab
@@ -29,13 +30,13 @@ export const tabFormat = () => {
29
30
 
30
31
  let ul = box.child('.nav ul')
31
32
  if (!ul) {
32
- ul = box.createChild('div', {
33
+ ul = createChild(box, 'div', {
33
34
  className: 'nav',
34
35
  innerHTML: '<ul></ul>'
35
36
  }).child('ul')
36
37
  }
37
38
 
38
- const li = ul.createChild('li', {
39
+ const li = createChild(ul, 'li', {
39
40
  innerHTML: title
40
41
  })
41
42
 
@@ -15,21 +15,22 @@ import {
15
15
  import { Loader } from '../globals/thirdparty'
16
16
  import { $dom } from '../library/dom'
17
17
  import { mediaPlayer } from '../player'
18
+ import { child, createChild } from '../library/proto'
18
19
 
19
20
  export default function domInit () {
20
21
  $dom.each('.overview .menu > .item', (el) => {
21
- siteNav.child('.menu').appendChild(el.cloneNode(true))
22
+ child(siteNav, '.menu').appendChild(el.cloneNode(true))
22
23
  })
23
24
 
24
25
  loadCat.addEventListener('click', Loader.vanish)
25
26
  menuToggle.addEventListener('click', sideBarToggleHandle)
26
27
  $dom('.dimmer').addEventListener('click', sideBarToggleHandle)
27
28
 
28
- quickBtn.child('.down').addEventListener('click', goToBottomHandle)
29
- quickBtn.child('.up').addEventListener('click', backToTopHandle)
29
+ child(quickBtn, '.down').addEventListener('click', goToBottomHandle)
30
+ child(quickBtn, '.up').addEventListener('click', backToTopHandle)
30
31
 
31
32
  if (!toolBtn) {
32
- setToolBtn(siteHeader.createChild('div', {
33
+ setToolBtn(createChild(siteHeader, 'div', {
33
34
  id: 'tool',
34
35
  innerHTML: '<div class="item player"></div><div class="item contents"><i class="ic i-list-ol"></i></div><div class="item chat"><i class="ic i-comments"></i></div><div class="item back-to-top"><i class="ic i-arrow-up"></i><span>0%</span></div>'
35
36
  }))
@@ -1,11 +1,11 @@
1
1
  import { $dom } from '../library/dom'
2
2
  import { cardActive } from '../page/common'
3
- import { postBeauty } from '../page/post'
4
3
  import { pageScroll, transition } from '../library/anime'
5
4
  import { vendorCss, vendorJs } from '../library/loadFile'
6
5
  import { pjaxScript } from '../library/scriptPjax'
7
6
  import { resizeHandle } from '../globals/handles'
8
7
  import {
8
+ CONFIG,
9
9
  loadCat,
10
10
  menuToggle,
11
11
  setLocalHash, setLocalUrl, setOriginTitle,
@@ -53,7 +53,25 @@ export const siteRefresh = (reload) => {
53
53
  sideBarTab()
54
54
  sidebarTOC()
55
55
 
56
- postBeauty()
56
+ import('../page/post').then(({ postBeauty }) => {
57
+ postBeauty()
58
+ })
59
+
60
+ if (__shokax_waline__ && LOCAL.ispost) {
61
+ import('../components/comments').then(async ({ walineComment, walinePageview, walineRecentComments }) => {
62
+ walineComment()
63
+ walinePageview()
64
+ await walineRecentComments()
65
+ })
66
+ }
67
+
68
+ if (__shokax_twikoo__ && LOCAL.ispost) {
69
+ import('../components/tcomments').then(async ({ twikooComment, twikooRecentComments }) => {
70
+ twikooComment()
71
+ await twikooRecentComments()
72
+ })
73
+ }
74
+
57
75
  if (__shokax_tabs__) {
58
76
  tabFormat()
59
77
  }
@@ -1,19 +1,17 @@
1
1
  import domInit from './domInit'
2
2
  import { pjaxReload, siteRefresh } from './refresh'
3
3
  import { cloudflareInit } from '../library/scriptPjax'
4
- import { algoliaSearch } from '../page/search'
5
- import { pjax, setPjax } from '../globals/globalVars'
4
+ import { CONFIG, pjax, setPjax } from '../globals/globalVars'
6
5
  import { autoDarkmode, themeColorListener } from '../globals/themeColor'
7
6
  import { resizeHandle, scrollHandle, visibilityListener } from '../globals/handles'
8
7
  import { pagePosition } from '../globals/tools'
9
8
  import Pjax from 'theme-shokax-pjax'
10
9
  import { initVue } from '../library/vue'
11
10
  import { lazyLoad } from 'unlazy'
12
- import firework from 'mouse-firework'
13
11
 
14
12
  const siteInit = () => {
15
- domInit()
16
13
  initVue()
14
+ domInit()
17
15
 
18
16
  setPjax(new Pjax({
19
17
  selectors: [
@@ -28,7 +26,10 @@ const siteInit = () => {
28
26
  }))
29
27
 
30
28
  CONFIG.quicklink.ignores = LOCAL.ignores
31
- quicklink.listen(CONFIG.quicklink)
29
+ import('quicklink').then(({ listen }) => {
30
+ listen(CONFIG.quicklink)
31
+ })
32
+
32
33
  autoDarkmode()
33
34
 
34
35
  if (__shokax_VL__) {
@@ -36,11 +37,15 @@ const siteInit = () => {
36
37
  }
37
38
  themeColorListener()
38
39
  if (__shokax_search__) {
39
- algoliaSearch(pjax)
40
+ import('../page/search').then(({ algoliaSearch }) => {
41
+ algoliaSearch(pjax)
42
+ })
40
43
  }
41
44
 
42
45
  if (__shokax_fireworks__) {
43
- firework(CONFIG.fireworks)
46
+ import('mouse-firework').then((firework) => {
47
+ firework.default(CONFIG.fireworks)
48
+ })
44
49
  }
45
50
  lazyLoad()
46
51
 
@@ -1,9 +1,10 @@
1
- import { originTitle } from './globals/globalVars'
1
+ import { CONFIG, originTitle } from './globals/globalVars'
2
2
  import { showtip } from './globals/tools'
3
3
  import { pageScroll } from './library/anime'
4
4
  import { $dom } from './library/dom'
5
5
  import { $storage } from './library/storage'
6
6
  import { tabFormat } from './page/tab'
7
+ import { createChild, getLeft, getWidth, setDisplay, setWidth } from './library/proto'
7
8
 
8
9
  let NOWPLAYING = null
9
10
 
@@ -16,7 +17,7 @@ export const mediaPlayer = (t, config?) => {
16
17
  t.player.options.btns.forEach((item) => {
17
18
  if (buttons.el[item]) { return }
18
19
 
19
- buttons.el[item] = t.createChild('div', {
20
+ buttons.el[item] = createChild(t, 'div', {
20
21
  className: item + ' btn',
21
22
  onclick (event) {
22
23
  t.player.fetch().then(() => {
@@ -64,7 +65,7 @@ export const mediaPlayer = (t, config?) => {
64
65
 
65
66
  opt.className = item + opt.className + ' btn'
66
67
 
67
- that.btns[item] = that.el.createChild('div', opt)
68
+ that.btns[item] = createChild(that.el, 'div', opt)
68
69
  })
69
70
 
70
71
  that.btns.volume.bar = that.btns.volume.child('.bar')
@@ -130,10 +131,10 @@ export const mediaPlayer = (t, config?) => {
130
131
  },
131
132
  update (percent) {
132
133
  controller.btns.volume.className = 'volume ' + (!source.muted && percent > 0 ? 'on' : 'off') + ' btn'
133
- controller.btns.volume.bar.changeOrGetWidth(Math.floor(percent * 100) + '%')
134
+ setWidth(controller.btns.volume.bar, Math.floor(percent * 100) + '%')
134
135
  },
135
136
  percent (e, el) {
136
- let percentage = ((e.clientX || e.changedTouches[0].clientX) - el.left()) / el.changeOrGetWidth()
137
+ let percentage = ((e.clientX || e.changedTouches[0].clientX) - getLeft(el)) / getWidth(el)
137
138
  percentage = Math.max(percentage, 0)
138
139
  return Math.min(percentage, 1)
139
140
  }
@@ -151,13 +152,13 @@ export const mediaPlayer = (t, config?) => {
151
152
  progress.el.remove()
152
153
  }
153
154
 
154
- progress.el = current.createChild('div', {
155
+ progress.el = createChild(current, 'div', {
155
156
  className: 'progress'
156
157
  });
157
158
 
158
159
  (progress.el as HTMLElement).setAttribute('data-dtime', utils.secondToTime(0))
159
160
 
160
- progress.bar = progress.el.createChild('div', {
161
+ progress.bar = createChild(progress.el, 'div', {
161
162
  className: 'bar'
162
163
  })
163
164
 
@@ -169,14 +170,14 @@ export const mediaPlayer = (t, config?) => {
169
170
  }
170
171
  },
171
172
  update (percent) {
172
- progress.bar.changeOrGetWidth(Math.floor(percent * 100) + '%');
173
+ setWidth(progress.bar, Math.floor(percent * 100) + '%');
173
174
  (progress.el as HTMLElement).setAttribute('data-ptime', utils.secondToTime(percent * source.duration))
174
175
  },
175
176
  seeking (type) {
176
177
  if (type) { progress.el.addClass('seeking') } else { progress.el.removeClass('seeking') }
177
178
  },
178
179
  percent (e, el) {
179
- let percentage = ((e.clientX || e.changedTouches[0].clientX) - el.left()) / el.changeOrGetWidth()
180
+ let percentage = ((e.clientX || e.changedTouches[0].clientX) - getLeft(el)) / getWidth(el)
180
181
  percentage = Math.max(percentage, 0)
181
182
  return Math.min(percentage, 1)
182
183
  },
@@ -258,7 +259,7 @@ export const mediaPlayer = (t, config?) => {
258
259
  const id = 'list-' + t.player._id + '-' + item.group
259
260
  let tab = $dom('#' + id)
260
261
  if (!tab) {
261
- tab = el.createChild('div', {
262
+ tab = createChild(el, 'div', {
262
263
  id,
263
264
  className: t.player.group ? 'tab' : '',
264
265
  innerHTML: '<ol></ol>'
@@ -269,7 +270,7 @@ export const mediaPlayer = (t, config?) => {
269
270
  }
270
271
  }
271
272
 
272
- item.el = tab.child('ol').createChild('li', {
273
+ item.el = createChild(tab.child('ol'), 'li', {
273
274
  title: item.name + ' - ' + item.artist,
274
275
  innerHTML: '<span class="info"><span>' + item.name + '</span><span>' + item.artist + '</span></span>',
275
276
  onclick (event) {
@@ -329,7 +330,7 @@ export const mediaPlayer = (t, config?) => {
329
330
  create () {
330
331
  if (this.el) { return }
331
332
 
332
- this.el = t.createChild('div', {
333
+ this.el = createChild(t, 'div', {
333
334
  className: 'player-info',
334
335
  innerHTML: (t.player.options.type === 'audio' ? '<div class="preview"></div>' : '') + '<div class="controller"></div><div class="playlist"></div>'
335
336
  }, 'after')
@@ -469,7 +470,7 @@ export const mediaPlayer = (t, config?) => {
469
470
  this.pause()
470
471
  }
471
472
  for (const el in buttons.el) {
472
- buttons.el[el].display(d)
473
+ setDisplay(buttons.el[el], d)
473
474
  }
474
475
  return this
475
476
  },
@@ -662,7 +663,7 @@ export const mediaPlayer = (t, config?) => {
662
663
  lrc += '<p' + (index === 0 ? ' class="current"' : '') + '>' + line[1] + '</p>'
663
664
  })
664
665
 
665
- this.el = box.createChild('div', {
666
+ this.el = createChild(box, 'div', {
666
667
  className: 'inner',
667
668
  innerHTML: lrc
668
669
  }, 'replace')
@@ -783,7 +784,7 @@ export const mediaPlayer = (t, config?) => {
783
784
  buttons.create()
784
785
 
785
786
  // 初始化audio or video
786
- source = t.createChild(t.player.options.type, events)
787
+ source = createChild(t, t.player.options.type, events)
787
788
  // 初始化播放列表、预览、控件按钮等
788
789
  info.create()
789
790
 
@@ -1 +0,0 @@
1
- declare const fmtNum: (num: any) => any;
@@ -1,59 +0,0 @@
1
-
2
- // @ts-ignore
3
- const fmtNum = (num) => {
4
- return num < 10 ? '0' + num : num
5
- }
6
-
7
- hexo.extend.filter.register('template_locals', (locals:localsPlus) => {
8
- const { config } = hexo
9
- const { __, theme } = locals
10
- // @ts-ignore
11
- const { i18n } = hexo.theme
12
-
13
- const pangu = {
14
- spacing: (data) => {
15
- return data
16
- }
17
- }
18
-
19
- // Language & Config
20
- // 根据主题配置的 Creative Commons 许可证生成链接
21
- locals.alternate = theme.alternate
22
- locals.title = pangu.spacing(__('title') !== 'title' ? __('title') : config.title)
23
- locals.subtitle = pangu.spacing(__('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle)
24
- locals.author = __('author') !== 'author' ? __('author') : config.author
25
- locals.description = pangu.spacing(__('description') !== 'description' ? __('description') : config.description)
26
- locals.languages = [...i18n.languages]
27
- locals.languages.splice(locals.languages.indexOf('default'), 1)
28
- locals.page.lang = locals.page.lang || locals.page.language
29
- locals.hostname = new URL(config.url).hostname || config.url
30
-
31
- // Creative Commons
32
- // 根据主题配置的 Creative Commons 许可证生成链接
33
- if (theme.creative_commons.license === 'zero') {
34
- locals.ccURL = 'https://creativecommons.org/' + 'publicdomain/zero/1.0/' + (theme.creative_commons.language || '')
35
- } else {
36
- locals.ccURL = 'https://creativecommons.org/' + 'licenses/' + theme.creative_commons.license + '/4.0/' + (theme.creative_commons.language || '')
37
- }
38
-
39
- if (locals.page.title) {
40
- locals.page.title = pangu.spacing(locals.page.title)
41
- }
42
- locals.page.lastcat = ''
43
- if (locals.page.categories) {
44
- locals.page.categories.map((cat) => {
45
- if (cat.name) {
46
- cat.name = locals.page.lastcat = pangu.spacing(cat.name)
47
- }
48
- return cat
49
- })
50
- }
51
-
52
- if (locals.page.category) {
53
- locals.page.title = pangu.spacing(locals.page.category)
54
- }
55
-
56
- if (locals.page.month) {
57
- locals.page.month = fmtNum(locals.page.month)
58
- }
59
- })
File without changes
@@ -1,6 +0,0 @@
1
- /* global hexo */
2
-
3
- hexo.extend.filter.register('after_post_render', (data) => {
4
- // 使用正则表达式将<img>标签的src属性替换为data-src属性
5
- data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 loading="lazy" data-src=')
6
- }, 0)
@@ -1 +0,0 @@
1
- export {};