valaxy-theme-yun 0.11.6 → 0.12.0
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.
@@ -1,7 +1,6 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
2
|
import type { PageData, Post } from 'valaxy'
|
3
3
|
import { useConfig, usePostTitle } from 'valaxy'
|
4
|
-
import { useAddonWaline } from 'valaxy-addon-waline'
|
5
4
|
import { StyleValue, computed, defineAsyncComponent } from 'vue'
|
6
5
|
import { usePostProperty } from '../composables'
|
7
6
|
|
@@ -16,7 +15,8 @@ const title = usePostTitle(computed(() => props.frontmatter))
|
|
16
15
|
|
17
16
|
const aside = computed(() => props.frontmatter.aside !== false)
|
18
17
|
|
19
|
-
|
18
|
+
// not import from 'valaxy-addon-waline' to judge
|
19
|
+
const YunWaline = config.value.runtime.addons['valaxy-addon-waline']
|
20
20
|
? defineAsyncComponent(() => import('./YunWaline.vue'))
|
21
21
|
: () => null
|
22
22
|
|
package/components/YunAside.vue
CHANGED
@@ -21,7 +21,7 @@ const app = useAppStore()
|
|
21
21
|
|
22
22
|
<!-- -->
|
23
23
|
<aside class="va-card aside" :class="app.isRightSidebarOpen && 'open'" m="l-4" text="center">
|
24
|
-
<div class="aside-container" flex="~ col">
|
24
|
+
<div class="aside-container" flex="~ col" overflow="auto">
|
25
25
|
<h2 v-if="frontmatter.toc !== false" m="t-6 b-2" font="serif black">
|
26
26
|
{{ t('sidebar.toc') }}
|
27
27
|
</h2>
|
package/components/YunSearch.vue
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
|
-
import {
|
2
|
+
import { computed } from '@vue/reactivity'
|
3
|
+
import { useConfig } from 'valaxy'
|
4
|
+
import { onMounted, onUnmounted, ref } from 'vue'
|
3
5
|
import { useI18n } from 'vue-i18n'
|
4
6
|
|
5
|
-
const
|
6
|
-
? defineAsyncComponent(() => import('./YunAlgoliaSearchBox.vue'))
|
7
|
-
: () => null
|
8
|
-
|
7
|
+
const config = useConfig()
|
9
8
|
const { t } = useI18n()
|
10
9
|
|
11
10
|
// to avoid loading the docsearch js upfront (which is more than 1/3 of the
|
@@ -18,8 +17,10 @@ function load() {
|
|
18
17
|
loaded.value = true
|
19
18
|
}
|
20
19
|
|
20
|
+
const isAlgolia = computed(() => config.value.search.type === 'algolia')
|
21
|
+
|
21
22
|
onMounted(() => {
|
22
|
-
if (!
|
23
|
+
if (!isAlgolia.value)
|
23
24
|
return
|
24
25
|
|
25
26
|
const handleSearchHotKey = (e: KeyboardEvent) => {
|
@@ -57,7 +58,7 @@ const trigger = () => {
|
|
57
58
|
<!-- <div v-else text="!2xl" i-ri-close-line /> -->
|
58
59
|
</button>
|
59
60
|
|
60
|
-
<
|
61
|
+
<AlgoliaSearchBox v-if="isAlgolia && loaded" />
|
61
62
|
</div>
|
62
63
|
</template>
|
63
64
|
|
package/layouts/layout.vue
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "valaxy-theme-yun",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.12.0",
|
4
4
|
"author": {
|
5
5
|
"email": "me@yunyoujun.cn",
|
6
6
|
"name": "YunYouJun",
|
@@ -17,13 +17,11 @@
|
|
17
17
|
"main": "node/index.ts",
|
18
18
|
"types": "types/index.d.ts",
|
19
19
|
"dependencies": {
|
20
|
-
"@docsearch/css": "^3.3.0",
|
21
|
-
"@docsearch/js": "^3.3.0",
|
22
20
|
"@iconify-json/ant-design": "^1.1.4",
|
23
21
|
"@iconify-json/simple-icons": "^1.1.37",
|
24
22
|
"valaxy-addon-waline": "0.0.6"
|
25
23
|
},
|
26
24
|
"devDependencies": {
|
27
|
-
"valaxy": "0.
|
25
|
+
"valaxy": "0.12.0"
|
28
26
|
}
|
29
27
|
}
|
@@ -1,154 +0,0 @@
|
|
1
|
-
<script setup lang="ts">
|
2
|
-
import '@docsearch/css'
|
3
|
-
import docsearch from '@docsearch/js'
|
4
|
-
import type { DocSearchHit } from '@docsearch/react/dist/esm/types'
|
5
|
-
import { onMounted } from 'vue'
|
6
|
-
import type { AlgoliaSearchOptions } from 'valaxy'
|
7
|
-
import { useConfig } from 'valaxy'
|
8
|
-
import { useRoute, useRouter } from 'vue-router'
|
9
|
-
|
10
|
-
const router = useRouter()
|
11
|
-
const route = useRoute()
|
12
|
-
const config = useConfig()
|
13
|
-
|
14
|
-
onMounted(() => {
|
15
|
-
initialize(config.value.search.algolia)
|
16
|
-
setTimeout(poll, 16)
|
17
|
-
})
|
18
|
-
|
19
|
-
/**
|
20
|
-
* poll until open
|
21
|
-
*/
|
22
|
-
function poll() {
|
23
|
-
// programmatically open the search box after initialize
|
24
|
-
const e = new Event('keydown') as any
|
25
|
-
|
26
|
-
e.key = 'k'
|
27
|
-
e.metaKey = true
|
28
|
-
|
29
|
-
window.dispatchEvent(e)
|
30
|
-
|
31
|
-
setTimeout(() => {
|
32
|
-
if (!document.querySelector('.DocSearch-Modal'))
|
33
|
-
poll()
|
34
|
-
}, 16)
|
35
|
-
}
|
36
|
-
|
37
|
-
function initialize(userOptions: AlgoliaSearchOptions) {
|
38
|
-
// note: multi-lang search support is removed since the theme
|
39
|
-
// doesn't support multiple locales as of now.
|
40
|
-
const options = Object.assign({}, userOptions, {
|
41
|
-
container: '#docsearch',
|
42
|
-
navigator: {
|
43
|
-
navigate({ itemUrl }: { itemUrl: string }) {
|
44
|
-
const { pathname: hitPathname } = new URL(
|
45
|
-
window.location.origin + itemUrl,
|
46
|
-
)
|
47
|
-
// router doesn't handle same-page navigation so we use the native
|
48
|
-
// browser location API for anchor navigation
|
49
|
-
if (route.path === hitPathname)
|
50
|
-
window.location.assign(window.location.origin + itemUrl)
|
51
|
-
|
52
|
-
else
|
53
|
-
router.push(itemUrl)
|
54
|
-
},
|
55
|
-
},
|
56
|
-
transformItems(items: DocSearchHit[]) {
|
57
|
-
return items.map((item) => {
|
58
|
-
return Object.assign({}, item, {
|
59
|
-
url: getRelativePath(item.url),
|
60
|
-
})
|
61
|
-
})
|
62
|
-
},
|
63
|
-
hitComponent({ hit, children }: { hit: DocSearchHit; children: any }) {
|
64
|
-
const relativeHit = hit.url.startsWith('http')
|
65
|
-
? getRelativePath(hit.url as string)
|
66
|
-
: hit.url
|
67
|
-
return {
|
68
|
-
__v: null,
|
69
|
-
type: 'a',
|
70
|
-
ref: undefined,
|
71
|
-
constructor: undefined,
|
72
|
-
key: undefined,
|
73
|
-
props: {
|
74
|
-
href: hit.url,
|
75
|
-
onClick(event: MouseEvent) {
|
76
|
-
if (isSpecialClick(event))
|
77
|
-
return
|
78
|
-
|
79
|
-
// we rely on the native link scrolling when user is already on
|
80
|
-
// the right anchor because Router doesn't support duplicated
|
81
|
-
// history entries.
|
82
|
-
if (route.path === relativeHit)
|
83
|
-
return
|
84
|
-
|
85
|
-
// if the hits goes to another page, we prevent the native link
|
86
|
-
// behavior to leverage the Router loading feature.
|
87
|
-
if (route.path !== relativeHit)
|
88
|
-
event.preventDefault()
|
89
|
-
|
90
|
-
router.push(relativeHit)
|
91
|
-
},
|
92
|
-
children,
|
93
|
-
},
|
94
|
-
}
|
95
|
-
},
|
96
|
-
})
|
97
|
-
docsearch(options)
|
98
|
-
}
|
99
|
-
|
100
|
-
function isSpecialClick(event: MouseEvent) {
|
101
|
-
return (
|
102
|
-
event.button === 1
|
103
|
-
|| event.altKey
|
104
|
-
|| event.ctrlKey
|
105
|
-
|| event.metaKey
|
106
|
-
|| event.shiftKey
|
107
|
-
)
|
108
|
-
}
|
109
|
-
|
110
|
-
function getRelativePath(absoluteUrl: string) {
|
111
|
-
const { pathname, hash } = new URL(absoluteUrl)
|
112
|
-
return pathname + hash
|
113
|
-
}
|
114
|
-
</script>
|
115
|
-
|
116
|
-
<template>
|
117
|
-
<div id="docsearch" class="hidden" />
|
118
|
-
</template>
|
119
|
-
|
120
|
-
<style lang="scss">
|
121
|
-
.DocSearch {
|
122
|
-
--docsearch-primary-color: var(--va-c-primary);
|
123
|
-
--docsearch-highlight-color: var(--docsearch-primary-color);
|
124
|
-
--docsearch-text-color: var(--va-c-text-primary);
|
125
|
-
--docsearch-muted-color: var(--va-c-text-light);
|
126
|
-
--docsearch-searchbox-focus-background: transparent;
|
127
|
-
--docsearch-searchbox-shadow: none;
|
128
|
-
|
129
|
-
--docsearch-key-gradient: transparent;
|
130
|
-
--docsearch-key-shadow: none;
|
131
|
-
|
132
|
-
--docsearch-modal-background: var(--va-c-bg-light);
|
133
|
-
--docsearch-footer-background: var(--va-c-bg);
|
134
|
-
|
135
|
-
input {
|
136
|
-
&::placeholder {
|
137
|
-
color: var(--va-c-text-dark);
|
138
|
-
}
|
139
|
-
}
|
140
|
-
}
|
141
|
-
|
142
|
-
.dark .DocSearch {
|
143
|
-
--docsearch-modal-shadow: none;
|
144
|
-
--docsearch-footer-shadow: none;
|
145
|
-
--docsearch-logo-color: var(--va-c-text-light);
|
146
|
-
--docsearch-hit-background: var(--va-c-bg-mute);
|
147
|
-
--docsearch-hit-color: var(--va-c-text-light);
|
148
|
-
--docsearch-hit-shadow: none;
|
149
|
-
}
|
150
|
-
|
151
|
-
.DocSearch-Form {
|
152
|
-
border: 1px solid var(--va-c-primary);
|
153
|
-
}
|
154
|
-
</style>
|