valaxy-theme-yun 0.13.2 → 0.13.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.
@@ -0,0 +1,9 @@
1
+ <script lang="ts" setup>
2
+ import { useAddonAlgolia } from 'valaxy-addon-algolia'
3
+
4
+ const { loaded } = useAddonAlgolia()
5
+ </script>
6
+
7
+ <template>
8
+ <AlgoliaSearchBox v-if="loaded" />
9
+ </template>
@@ -1,23 +1,13 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed } from '@vue/reactivity'
3
3
  import { useSiteConfig } from 'valaxy'
4
- import { ref, watch } from 'vue'
4
+ import { defineAsyncComponent, ref, watch } from 'vue'
5
5
  import { useI18n } from 'vue-i18n'
6
6
  import { useMagicKeys } from '@vueuse/core'
7
7
 
8
8
  const siteConfig = useSiteConfig()
9
9
  const { t } = useI18n()
10
10
 
11
- // to avoid loading the docsearch js upfront (which is more than 1/3 of the
12
- // payload), we delay initializing it until the user has actually clicked or
13
- // hit the hotkey to invoke it.
14
- const loaded = ref(false)
15
-
16
- function load() {
17
- if (!loaded.value)
18
- loaded.value = true
19
- }
20
-
21
11
  const isAlgolia = computed(() => siteConfig.value.search.type === 'algolia')
22
12
 
23
13
  const open = ref(false)
@@ -29,11 +19,13 @@ const togglePopup = () => {
29
19
  const { Meta_K } = useMagicKeys()
30
20
 
31
21
  watch(Meta_K, (val) => {
32
- if (val) {
22
+ if (val)
33
23
  togglePopup()
34
- load()
35
- }
36
24
  })
25
+
26
+ const YunAlgoliaSearch = isAlgolia
27
+ ? defineAsyncComponent(() => import('./YunAlgoliaSearch.vue'))
28
+ : () => null
37
29
  </script>
38
30
 
39
31
  <template>
@@ -42,7 +34,7 @@ watch(Meta_K, (val) => {
42
34
  <div v-else text="!2xl" i-ri-close-line />
43
35
  </button>
44
36
 
45
- <AlgoliaSearchBox v-if="isAlgolia && loaded" />
37
+ <YunAlgoliaSearch v-if="isAlgolia" />
46
38
  <YunFuseSearch v-else-if="siteConfig.search.type === 'fuse'" :open="open" @close="open = false" />
47
39
  </template>
48
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valaxy-theme-yun",
3
- "version": "0.13.2",
3
+ "version": "0.13.4",
4
4
  "author": {
5
5
  "email": "me@yunyoujun.cn",
6
6
  "name": "YunYouJun",
@@ -22,6 +22,6 @@
22
22
  "valaxy-addon-waline": "0.0.9"
23
23
  },
24
24
  "devDependencies": {
25
- "valaxy": "0.13.2"
25
+ "valaxy": "0.13.4"
26
26
  }
27
27
  }
package/valaxy.config.ts CHANGED
@@ -34,7 +34,11 @@ export default defineValaxyTheme<ThemeConfig>((options) => {
34
34
  build: {
35
35
  rollupOptions: {
36
36
  // add on demand external
37
- external: ['valaxy-addon-twikoo', 'valaxy-addon-waline'],
37
+ external: [
38
+ 'valaxy-addon-algolia',
39
+ 'valaxy-addon-twikoo',
40
+ 'valaxy-addon-waline',
41
+ ],
38
42
  },
39
43
  },
40
44
  plugins: [ThemeVitePlugin(options)],