valaxy-theme-press 0.28.4 → 0.28.6
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.
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import type { DocSearchInstance, DocSearchProps } from '@docsearch/js'
|
|
3
3
|
import type { SidepanelInstance, SidepanelProps } from '@docsearch/sidepanel-js'
|
|
4
4
|
import type { AlgoliaSearchOptions } from '../types/algolia'
|
|
5
|
-
import {
|
|
5
|
+
import { useAddonConfig } from 'valaxy'
|
|
6
|
+
import { nextTick, onUnmounted, watch } from 'vue'
|
|
6
7
|
import { useRouter } from 'vue-router'
|
|
7
8
|
|
|
8
9
|
import '../styles/docsearch.css'
|
|
@@ -16,14 +17,7 @@ const props = defineProps<{
|
|
|
16
17
|
|
|
17
18
|
const router = useRouter()
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
const algoliaConfig = ref<{ options?: AlgoliaSearchOptions }>()
|
|
21
|
-
import('valaxy-addon-algolia').then(({ useAddonAlgoliaConfig }) => {
|
|
22
|
-
// Direct assignment — the synchronous watcher below will react to this change
|
|
23
|
-
algoliaConfig.value = useAddonAlgoliaConfig().value
|
|
24
|
-
}).catch(() => {
|
|
25
|
-
console.warn('[valaxy-theme-press] valaxy-addon-algolia is not installed. Algolia search will not work.')
|
|
26
|
-
})
|
|
20
|
+
const algoliaConfig = useAddonConfig<AlgoliaSearchOptions>('valaxy-addon-algolia')
|
|
27
21
|
|
|
28
22
|
let cleanup = () => {}
|
|
29
23
|
let docsearchInstance: DocSearchInstance | undefined
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { AlgoliaSearchOptions } from '../types/algolia'
|
|
3
3
|
import { onKeyStroke } from '@vueuse/core'
|
|
4
|
-
import { useSiteConfig } from 'valaxy'
|
|
4
|
+
import { useAddonConfig, useSiteConfig } from 'valaxy'
|
|
5
5
|
import { computed, defineAsyncComponent, onMounted, ref } from 'vue'
|
|
6
6
|
import PressNavBarAskAiButton from './PressNavBarAskAiButton.vue'
|
|
7
7
|
import PressNavBarSearchButton from './PressNavBarSearchButton.vue'
|
|
@@ -13,15 +13,13 @@ const isFuse = computed(() => siteConfig.value.search.provider === 'fuse')
|
|
|
13
13
|
const isLocal = computed(() => siteConfig.value.search.provider === 'local')
|
|
14
14
|
|
|
15
15
|
// Whether to show the Ask AI button (requires askAi config in addon-algolia)
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
if (isAlgolia.value)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}).catch(() => {})
|
|
24
|
-
}
|
|
16
|
+
const algoliaAddonConfig = useAddonConfig<AlgoliaSearchOptions>('valaxy-addon-algolia')
|
|
17
|
+
const showAskAi = computed(() => {
|
|
18
|
+
if (!isAlgolia.value)
|
|
19
|
+
return false
|
|
20
|
+
const askAi = algoliaAddonConfig.value?.options?.askAi
|
|
21
|
+
return !!askAi
|
|
22
|
+
})
|
|
25
23
|
|
|
26
24
|
const PressAlgoliaSearch = isAlgolia.value
|
|
27
25
|
? defineAsyncComponent(() => import('./PressAlgoliaSearch.vue'))
|
|
@@ -46,7 +44,7 @@ const loaded = ref(false)
|
|
|
46
44
|
const actuallyLoaded = ref(false)
|
|
47
45
|
|
|
48
46
|
// Preconnect to Algolia DSN on idle
|
|
49
|
-
onMounted(
|
|
47
|
+
onMounted(() => {
|
|
50
48
|
if (!isAlgolia.value)
|
|
51
49
|
return
|
|
52
50
|
|
|
@@ -54,28 +52,19 @@ onMounted(async () => {
|
|
|
54
52
|
if (document.getElementById(id))
|
|
55
53
|
return
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
preconnect.rel = 'preconnect'
|
|
71
|
-
preconnect.href = `https://${appId}-dsn.algolia.net`
|
|
72
|
-
preconnect.crossOrigin = ''
|
|
73
|
-
document.head.appendChild(preconnect)
|
|
74
|
-
})
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
// valaxy-addon-algolia not installed, skip preconnect
|
|
78
|
-
}
|
|
55
|
+
const appId = algoliaAddonConfig.value?.options?.appId
|
|
56
|
+
if (!appId)
|
|
57
|
+
return
|
|
58
|
+
|
|
59
|
+
const rIC = window.requestIdleCallback || setTimeout
|
|
60
|
+
rIC(() => {
|
|
61
|
+
const preconnect = document.createElement('link')
|
|
62
|
+
preconnect.id = id
|
|
63
|
+
preconnect.rel = 'preconnect'
|
|
64
|
+
preconnect.href = `https://${appId}-dsn.algolia.net`
|
|
65
|
+
preconnect.crossOrigin = ''
|
|
66
|
+
document.head.appendChild(preconnect)
|
|
67
|
+
})
|
|
79
68
|
})
|
|
80
69
|
|
|
81
70
|
// Keyboard shortcuts for Algolia
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valaxy-theme-press",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.6",
|
|
4
4
|
"description": "Docs Theme for Valaxy",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "me@yunyoujun.cn",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"main": "node/index.ts",
|
|
23
23
|
"types": "types/index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@docsearch/css": "^4.6.
|
|
26
|
-
"@docsearch/js": "^4.6.
|
|
27
|
-
"@docsearch/sidepanel-js": "^4.6.
|
|
28
|
-
"reka-ui": "^2.9.
|
|
25
|
+
"@docsearch/css": "^4.6.3",
|
|
26
|
+
"@docsearch/js": "^4.6.3",
|
|
27
|
+
"@docsearch/sidepanel-js": "^4.6.3",
|
|
28
|
+
"reka-ui": "^2.9.6",
|
|
29
29
|
"vitepress": "^2.0.0-alpha.17"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"valaxy": "0.28.
|
|
32
|
+
"valaxy": "0.28.6"
|
|
33
33
|
}
|
|
34
34
|
}
|