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

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.
package/_config.yml CHANGED
@@ -21,8 +21,6 @@ pwa:
21
21
 
22
22
  # 实验性特性
23
23
  experiments:
24
- gradient: false # 使用CSS渐变作为文章封面
25
- fixedCover: "" # 主页面cover(为空则使用bing随机图片)
26
24
  debug: false # 使用debug模式启动
27
25
  disableThemeComment: false # 禁用主题评论系统(一般用于关闭评论或让插件接管评论系统)
28
26
  usingRelative: false # _image.yml 使用相对路径
@@ -30,6 +28,11 @@ experiments:
30
28
  # 具体见https://docs.kaitaku.xyz/guide/theme.html#%E9%95%BF%E6%96%87%E7%AB%A0%E4%BC%98%E5%8C%96
31
29
  mobileWidth: 820px # 移动版和桌面版导航栏最短切换长度
32
30
 
31
+ homeConfig:
32
+ gradient: false # 使用CSS渐变作为文章封面
33
+ # fixedCover 性能比默认的更好,且开启时将启用LCP优化和预加载 TODO
34
+ fixedCover: "" # 主页面cover(为空则使用bing随机图片)
35
+
33
36
  # ShokaX 模块化分包引入设置
34
37
  # 请关闭所有不使用的模块以优化主题 js 体积和性能
35
38
  modules:
@@ -41,11 +44,17 @@ modules:
41
44
  quiz: true # 启用文章内问题扩展支持
42
45
  fancybox: true # 启用 fancybox 支持(不建议禁用)
43
46
 
47
+ styles:
48
+ postprocess: true # 启用后处理器
49
+ modules:
50
+ mermaid: false
51
+
44
52
  # 优化性能区
45
53
  performance:
46
54
  # 使用preconnect预加载的网址(不建议超过三个)
47
55
  preConnect:
48
56
  - "https://lf9-cdn-tos.bytecdntp.com"
57
+ - "https://at.alicdn.com"
49
58
  # 使用dns-prefetch预解析的网址
50
59
  dnsPrefetch:
51
60
 
@@ -17,25 +17,3 @@ If you would like to customize the default translation, you do not need to modif
17
17
  menu:
18
18
  schedule: Calendar
19
19
  ```
20
-
21
- # Current language packs
22
-
23
- - ### English (en)
24
- - ### 日本語 (ja)
25
- - ### 中文-简体 (zh-CN)
26
- - ### 中文-繁体 (zh-HK)
27
- - ### 中文-台湾 (zh-TW)
28
- - ### Español (es)
29
- - ### Deutsch (de)
30
- - ### Français (fr)
31
- - ### Italiano (it)
32
- - ### Português (pt)
33
- - ### Русский (ru)
34
- - ### العربية (ar)
35
- - ### हिंदी (hi)
36
- - ### 한국어 (ko)
37
- - ### Nederlands (nl)
38
- - ### Polski (pl)
39
- - ### Türkçe (tr)
40
- - ### Bahasa Indonesia (id)
41
- - ### Tiếng Việt (vi)
@@ -1,6 +1,6 @@
1
1
  include postmeta.pug
2
2
 
3
- mixin SMRender(item)
3
+ mixin SMRender(item, lazy)
4
4
  - var link1 = item.link || item.path
5
5
  - var gradient = theme?.experiments?.gradient
6
6
  if item.link
@@ -11,7 +11,10 @@ mixin SMRender(item)
11
11
  div(class="cover" style=`background: linear-gradient(to bottom right, ${random_color()}, ${random_color()});`)
12
12
  else
13
13
  div(class="cover")
14
- != _url(link1, '<img loading="lazy" data-src="'+ _cover(item) +'" alt="article cover">', {itemprop: 'url', title: postText})
14
+ if lazy
15
+ != _url(link1, '<img loading="lazy" decoding="async" data-src="'+ _cover(item) +'" alt="article cover">', {itemprop: 'url', title: postText})
16
+ else
17
+ != _url(link1, '<img loading="eager" decoding="async" src="'+ _cover(item) +'" alt="article cover">', {itemprop: 'url', title: postText})
15
18
  div(class="info")
16
19
  +PMRender(item)
17
20
  h3
@@ -34,7 +34,7 @@ div(class="status")
34
34
  if beianN && RC
35
35
  br
36
36
  a(target="_blank" href=`https://beian.mps.gov.cn/#/query/webSearch?code=${RC}`)
37
- img(src=theme.statics + theme.assets + '/' + theme.footer.icp.icon style="max-width: 2em;display:inline;" width="20" height="20")
37
+ img(loading="lazy" decoding="async" data-src=theme.statics + theme.assets + '/' + theme.footer.icp.icon style="max-width: 2em;display:inline;" width="20" height="20")
38
38
  != beianN
39
39
  != shokax_inject('status')
40
40
 
@@ -42,16 +42,11 @@ each dnsLink in dnslinks
42
42
  if fontConfig
43
43
  != _vendor_font()
44
44
  != _css('app.css')
45
-
46
- if theme.polyfill.enable
47
- script(src=`https://polyfill.io/v3/polyfill.min.js?features=${theme.polyfill.features}` defer)
48
-
49
- != vendor_js()
50
- != _js('siteInit.js')
45
+ != preloadjs()
51
46
 
52
47
  include pwa.pug
53
- else if wl
54
- link(rel="stylesheet" href="https://npm.webcache.cn/@waline/client@v2/dist/waline.css" media="none" onload="this.media='all'")
48
+ if wl
49
+ link(rel="stylesheet" href="https://npm.webcache.cn/@waline/client@3.0.0-alpha.11/dist/waline.css" media="none" onload="this.media='all'")
55
50
 
56
51
  - var qw = theme?.qweather?.enable
57
52
  if qw
@@ -10,7 +10,7 @@ nav(id="nav")
10
10
  a(href=config.root rel="start")
11
11
  != alternate || title
12
12
  ul(class="right" id="rightNav")
13
- li(class="item theme" @click="changeThemeByBtn")
13
+ li(class="item theme")
14
14
  i(class="ic i-sun")
15
15
  li(class="item search")
16
16
  i(class="ic i-search")
@@ -35,18 +35,18 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
35
35
 
36
36
  != partial('_partials/header.pug', {}, {cache: true})
37
37
  div(id="imgs" class="pjax")
38
- if theme.experiments.gradient || theme.experiments.fixedCover
38
+ if theme.homeConfig.gradient || theme.homeConfig.fixedCover
39
39
  //- cover不可用时用Bing随机图片代替
40
- - var coverImage = theme.experiments.fixedCover || "https://7ed.net/bing/api"
41
- img(src=coverImage)
40
+ - var coverImage = theme.homeConfig.fixedCover || "https://7ed.net/bing/api"
41
+ img(src=coverImage loading="eager" decoding="async" fetchpriority="high")
42
42
  else
43
43
  - var covers = _cover_index(page, 6)
44
44
  if covers.length === 6
45
45
  ul
46
46
  each image in covers
47
- li(class="item" data-background-image=image)
47
+ li(class="item" style=`background-image: url("${image}");`)
48
48
  else
49
- img(src=covers)
49
+ img(src=covers loading="eager" decoding="async" fetchpriority="high")
50
50
  div(id="waves")
51
51
  svg(class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto")
52
52
  defs
@@ -119,10 +119,12 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
119
119
  != partial('_partials/third-party/baidu-analytics.pug', {}, {cache: true})
120
120
  != partial('_partials/third-party/clarity.pug', {}, {cache: true})
121
121
  != partial('_partials/third-party/google-analytics.pug', {}, {cache: true})
122
- if theme.twikoo.enable
123
- != _new_comments('twikoo')
124
- else if theme.waline.enable
125
- != _new_comments('waline')
122
+
123
+ != vendor_js()
124
+ if theme.polyfill.enable
125
+ script(src=`https://polyfill.io/v3/polyfill.min.js?features=${theme.polyfill.features}` defer)
126
+
127
+ != _js('siteInit.js')
126
128
 
127
129
  != shokax_inject('bodyEnd')
128
130
 
@@ -11,7 +11,7 @@ article(itemscope itemtype="http://schema.org/Article" class="post block" lang=t
11
11
  if post.photos && post.photos.length
12
12
  div(class="gallery" itemscope itemtype="http://schema.org/ImageGallery")
13
13
  each photo in post.photos
14
- img(loading="lazy" data-src=_image_url(photo, post.path) itemprop="contentUrl")
14
+ img(loading="lazy" decoding="async" data-src=_image_url(photo, post.path) itemprop="contentUrl")
15
15
  if theme.summary.enable && page.layout === 'post'
16
16
  div(class='tabs' id='summary')
17
17
  div(class="show-btn")
@@ -1,6 +1,6 @@
1
1
  div(class="author" itemprop="author" itemscope itemtype="http://schema.org/Person")
2
- img(loading="lazy" class="image" itemprop="image" alt=author
3
- data-src=url_for(theme.statics + theme.assets + '/'+ theme.sidebar.avatar))
2
+ img(loading="eager" decoding="async" class="image" itemprop="image" alt=author
3
+ src=url_for(theme.statics + theme.assets + '/'+ theme.sidebar.avatar))
4
4
  p(class="name" itemprop="name")
5
5
  != author
6
6
  div(class="description" itemprop="description")
package/layout/index.pug CHANGED
@@ -12,7 +12,7 @@ block content
12
12
  - var sticky = page.sticky.toArray()
13
13
  div(class="segments sticky")
14
14
  each post in sticky
15
- +SMRender(post)
15
+ +SMRender(post, false)
16
16
  if page.catlist.length > 0
17
17
  h2(class="divider")
18
18
  != __('index.category')
@@ -27,7 +27,7 @@ block content
27
27
  != __('index.posts')
28
28
  div(class="segments posts")
29
29
  each post in posts
30
- +SMRender(post)
30
+ +SMRender(post, true)
31
31
  include _partials/pagination.pug
32
32
 
33
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.4.0-alpha.3",
3
+ "version": "0.4.0-alpha.4",
4
4
  "description": "a hexo theme based on shoka",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
@@ -62,7 +62,7 @@ hexo.extend.generator.register('script', function (locals) {
62
62
  twikoo: {
63
63
  envId: theme.twikoo.envId,
64
64
  region: theme.twikoo.region
65
- },
65
+ }
66
66
  };
67
67
  if (config?.algolia) {
68
68
  siteConfig.search = {
@@ -151,8 +151,6 @@ hexo.extend.generator.register('script', function (locals) {
151
151
  }
152
152
  });
153
153
  }
154
- node_fs_1.default.unlinkSync(`./shokaxTemp/${file}`);
155
154
  });
156
- node_fs_1.default.rmSync('./shokaxTemp', { force: true, recursive: true });
157
155
  return res;
158
156
  });
@@ -53,17 +53,17 @@ hexo.extend.helper.register('_css', function (...urls) {
53
53
  return urls.map(url => (0, hexo_util_1.htmlTag)('link', {
54
54
  rel: 'stylesheet',
55
55
  href: hexo_util_1.url_for.call(this, `${statics}${css}/${url}?v=${package_json_1.default.version}`)
56
- })).join('');
56
+ }), '').join('');
57
57
  });
58
58
  hexo.extend.helper.register('_js', function (...urls) {
59
59
  const { statics, js } = hexo.theme.config;
60
- return urls.map(url => (0, hexo_util_1.htmlTag)('script', { src: hexo_util_1.url_for.call(this, `${statics}${js}/${url}?v=${package_json_1.default.version}`), type: 'module', fetchpriority: 'high' }, '')).join('');
60
+ return urls.map(url => (0, hexo_util_1.htmlTag)('script', { src: hexo_util_1.url_for.call(this, `${statics}${js}/${url}?v=${package_json_1.default.version}`), type: 'module', fetchpriority: 'high', defer: true }, '')).join('');
61
61
  });
62
62
  hexo.extend.helper.register('vendor_js', function () {
63
63
  const vendors = hexo.theme.config.vendors;
64
64
  let res = '';
65
65
  for (const jsSync in vendors.js) {
66
- res += (0, hexo_util_1.htmlTag)('script', { src: (0, utils_1.getVendorLink)(hexo, vendors.js[jsSync]) }, '');
66
+ res += (0, hexo_util_1.htmlTag)('script', { src: (0, utils_1.getVendorLink)(hexo, vendors.js[jsSync]), async: true }, '');
67
67
  }
68
68
  // for (const jsAsync in vendors.async_js) {
69
69
  // res += htmlTag('script', { src: getVendorLink(hexo, vendors.async_js[jsAsync]), async: true }, '')
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  // @ts-ignore
4
7
  const hexo_util_1 = require("hexo-util");
8
+ const node_fs_1 = __importDefault(require("node:fs"));
5
9
  const randomServer = parseInt(String(Math.random() * 4), 10) + 1;
6
10
  const randomBG = function (count = 1, image_server = null, image_list = []) {
7
11
  let i;
@@ -48,6 +52,16 @@ const randomBG = function (count = 1, image_server = null, image_list = []) {
48
52
  }
49
53
  return parseImage(image_list[Math.floor(Math.random() * image_list.length)], 'mw690');
50
54
  };
55
+ hexo.extend.helper.register('preloadjs', function () {
56
+ const { statics, js } = hexo.theme.config;
57
+ let res = '';
58
+ node_fs_1.default.readdirSync('./shokaxTemp').forEach((file) => {
59
+ if (file.endsWith('.js')) {
60
+ res += (0, hexo_util_1.htmlTag)('link', { rel: 'modulepreload', href: hexo_util_1.url_for.call(this, `${statics}${js}/${file}`) }, '');
61
+ }
62
+ });
63
+ return res;
64
+ });
51
65
  // 注册hexo主题中的URL帮助方法
52
66
  hexo.extend.helper.register('_url', function (path, text, options = {}) {
53
67
  // 如果未提供URL路径,则返回
@@ -96,7 +110,7 @@ hexo.extend.helper.register('_cover_index', function (item) {
96
110
  return this._image_url(item.photos[0], item.path);
97
111
  }
98
112
  else {
99
- return randomBG(1, image_server, index_images.length === 0 ? image_list : index_images);
113
+ return randomBG(6, image_server, index_images.length === 0 ? image_list : index_images);
100
114
  }
101
115
  });
102
116
  // 注册hexo主题的永久链接帮助方法
@@ -37,6 +37,7 @@ const fs = __importStar(require("node:fs"));
37
37
  hexo.on('generateBefore', () => {
38
38
  // 加载`theme_injects`过滤器
39
39
  (0, injects_1.default)(hexo);
40
+ fs.rmSync('./shokaxTemp', { force: true, recursive: true });
40
41
  if (fs.existsSync('request.lock')) {
41
42
  fs.unlinkSync('request.lock');
42
43
  }
@@ -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/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');
152
+ src: url('https://at.alicdn.com/t/c/font_' + $iconfont + '.eot');
153
+ src: url('https://at.alicdn.com/t/c/font_' + $iconfont + '.eot?#iefix') format('embedded-opentype'),
154
+ url('https://at.alicdn.com/t/c/font_' + $iconfont + '.woff2') format('woff2'),
155
+ url('https://at.alicdn.com/t/c/font_' + $iconfont + '.woff') format('woff'),
156
+ url('https://at.alicdn.com/t/c/font_' + $iconfont + '.ttf') format('truetype'),
157
+ url('https://at.alicdn.com/t/c/font_' + $iconfont + '.svg#ic') format('svg');
158
158
  }
159
159
 
160
160
  @font-face {
@@ -22,7 +22,7 @@ import {
22
22
  } from './globalVars'
23
23
  import { changeMetaTheme } from './themeColor'
24
24
  import { Loader } from './thirdparty'
25
- import {getHeight, setWidth} from '../library/proto'
25
+ import { getHeight, setWidth } from '../library/proto'
26
26
 
27
27
  export const resizeHandle = () => {
28
28
  // 获取 siteNav 的高度
@@ -119,5 +119,5 @@ export const visibilityListener = () => {
119
119
  }, 2000))
120
120
  break
121
121
  }
122
- })
122
+ }, { passive: true })
123
123
  }
@@ -5,18 +5,8 @@ import { searchBox, configure, stats, hits, pagination } from 'instantsearch.js/
5
5
  import type { HitHighlightResult } from 'instantsearch.js/es/types/results'
6
6
  import instantsearch from 'instantsearch.js'
7
7
  import algoliasearch from 'algoliasearch/lite'
8
- import {createChild} from "../library/proto";
9
8
 
10
9
  export function algoliaSearch (pjax) {
11
- if (CONFIG.search === null) { return }
12
-
13
- if (!siteSearch) {
14
- setSiteSearch(createChild(BODY, 'div', {
15
- id: 'search',
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>'
17
- }))
18
- }
19
-
20
10
  const search = instantsearch({
21
11
  indexName: CONFIG.search.indexName,
22
12
  searchClient: algoliasearch(CONFIG.search.appID, CONFIG.search.apiKey),
@@ -104,16 +94,6 @@ export function algoliaSearch (pjax) {
104
94
 
105
95
  search.start()
106
96
 
107
- // Handle and trigger popup window
108
- $dom.each('.search', (element) => {
109
- element.addEventListener('click', () => {
110
- document.body.style.overflow = 'hidden'
111
- transition(siteSearch, 'shrinkIn', () => {
112
- $dom('.search-input').focus()
113
- }) // transition.shrinkIn
114
- })
115
- })
116
-
117
97
  // Monitor main search box
118
98
  const onPopupClose = () => {
119
99
  document.body.style.overflow = ''
@@ -76,6 +76,7 @@ export default function domInit () {
76
76
  root: null,
77
77
  threshold: 0.2
78
78
  }).observe(document.getElementById('waves'))
79
+
79
80
  // sakura在视口外时停止动画
80
81
  new IntersectionObserver(([entry]) => {
81
82
  if (entry.isIntersecting) {
@@ -40,6 +40,25 @@ export const siteRefresh = (reload) => {
40
40
  vendorJs('copy_tex')
41
41
  vendorCss('mermaid')
42
42
 
43
+ // 懒加载背景图
44
+ console.log('lazyBg')
45
+ const lazyBg = new IntersectionObserver(function (entries, observer) {
46
+ entries.forEach(entry => {
47
+ if (entry.isIntersecting) {
48
+ const el = entry.target as HTMLElement
49
+ el.style.backgroundImage = `url("${el.getAttribute('data-background-image')}")`
50
+ el.removeAttribute('data-background-image')
51
+ observer.unobserve(el)
52
+ }
53
+ })
54
+ }, {
55
+ root: null,
56
+ threshold: 0.2
57
+ })
58
+ document.querySelectorAll('[data-background-image]').forEach(el => {
59
+ lazyBg.observe(el)
60
+ })
61
+
43
62
  if (reload !== 1) {
44
63
  $dom.each('script[data-pjax]', pjaxScript)
45
64
  }
@@ -53,21 +72,44 @@ export const siteRefresh = (reload) => {
53
72
  sideBarTab()
54
73
  sidebarTOC()
55
74
 
56
- import('../page/post').then(({ postBeauty }) => {
57
- postBeauty()
58
- })
75
+ if (LOCAL.ispost) {
76
+ import('../page/post').then(({ postBeauty }) => {
77
+ postBeauty()
78
+ })
79
+
80
+ const comment = new IntersectionObserver((entries) => {
81
+ entries.forEach((entry) => {
82
+ if (entry.isIntersecting) {
83
+ if (__shokax_waline__) {
84
+ import('../components/comments').then(({ walinePageview, walineComment }) => {
85
+ walinePageview()
86
+ walineComment()
87
+ })
88
+ }
89
+ if (__shokax_twikoo__) {
90
+ import('../components/tcomments').then(({ twikooComment }) => {
91
+ twikooComment()
92
+ })
93
+ }
94
+ comment.disconnect()
95
+ }
96
+ })
97
+ }, {
98
+ root: null,
99
+ threshold: 0.2
100
+ })
101
+
102
+ comment.observe($dom('#copyright'))
103
+ }
59
104
 
60
- if (__shokax_waline__ && LOCAL.ispost) {
61
- import('../components/comments').then(async ({ walineComment, walinePageview, walineRecentComments }) => {
62
- walineComment()
63
- walinePageview()
105
+ if (__shokax_waline__) {
106
+ import('../components/comments').then(async ({ walinePageview, walineRecentComments }) => {
64
107
  await walineRecentComments()
65
108
  })
66
109
  }
67
110
 
68
- if (__shokax_twikoo__ && LOCAL.ispost) {
69
- import('../components/tcomments').then(async ({ twikooComment, twikooRecentComments }) => {
70
- twikooComment()
111
+ if (__shokax_twikoo__) {
112
+ import('../components/tcomments').then(async ({ twikooRecentComments }) => {
71
113
  await twikooRecentComments()
72
114
  })
73
115
  }
@@ -1,13 +1,16 @@
1
1
  import domInit from './domInit'
2
2
  import { pjaxReload, siteRefresh } from './refresh'
3
3
  import { cloudflareInit } from '../library/scriptPjax'
4
- import { CONFIG, pjax, setPjax } from '../globals/globalVars'
4
+ import { BODY, CONFIG, pjax, setPjax, setSiteSearch, siteSearch } from '../globals/globalVars'
5
5
  import { autoDarkmode, themeColorListener } from '../globals/themeColor'
6
6
  import { resizeHandle, scrollHandle, visibilityListener } from '../globals/handles'
7
7
  import { pagePosition } from '../globals/tools'
8
8
  import Pjax from 'theme-shokax-pjax'
9
9
  import { initVue } from '../library/vue'
10
10
  import { lazyLoad } from 'unlazy'
11
+ import { $dom } from '../library/dom'
12
+ import { createChild } from '../library/proto'
13
+ import { transition } from '../library/anime'
11
14
 
12
15
  const siteInit = () => {
13
16
  initVue()
@@ -36,10 +39,32 @@ const siteInit = () => {
36
39
  visibilityListener()
37
40
  }
38
41
  themeColorListener()
42
+
39
43
  if (__shokax_search__) {
40
- import('../page/search').then(({ algoliaSearch }) => {
41
- algoliaSearch(pjax)
42
- })
44
+ $dom('li.item.search > i').addEventListener('click', () => {
45
+ if (CONFIG.search === null) { return }
46
+
47
+ if (!siteSearch) {
48
+ setSiteSearch(createChild(BODY, 'div', {
49
+ id: 'search',
50
+ 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>'
51
+ }))
52
+ }
53
+
54
+ import('../page/search').then(({ algoliaSearch }) => {
55
+ algoliaSearch(pjax)
56
+ })
57
+
58
+ // Handle and trigger popup window
59
+ $dom.each('.search', (element) => {
60
+ element.addEventListener('click', () => {
61
+ document.body.style.overflow = 'hidden'
62
+ transition(siteSearch, 'shrinkIn', () => {
63
+ $dom('.search-input').focus()
64
+ }) // transition.shrinkIn
65
+ })
66
+ })
67
+ }, { once: true, capture: true })
43
68
  }
44
69
 
45
70
  if (__shokax_fireworks__) {
@@ -49,13 +74,21 @@ const siteInit = () => {
49
74
  }
50
75
  lazyLoad()
51
76
 
52
- window.addEventListener('scroll', scrollHandle)
77
+ window.addEventListener('scroll', scrollHandle, {
78
+ passive: true
79
+ })
53
80
 
54
- window.addEventListener('resize', resizeHandle)
81
+ window.addEventListener('resize', resizeHandle, {
82
+ passive: true
83
+ })
55
84
 
56
- window.addEventListener('pjax:send', pjaxReload)
85
+ window.addEventListener('pjax:send', pjaxReload, {
86
+ passive: true
87
+ })
57
88
 
58
- window.addEventListener('pjax:success', siteRefresh) // 默认会传入一个event参数
89
+ window.addEventListener('pjax:success', siteRefresh, {
90
+ passive: true
91
+ }) // 默认会传入一个event参数
59
92
 
60
93
  window.addEventListener('beforeunload', () => {
61
94
  pagePosition()