valaxy-theme-yun 1.2.2 → 1.3.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.
- package/App.vue +21 -9
- package/client/components/YunArtalk.vue +12 -0
- package/client/components/YunFireworks.vue +29 -0
- package/client/components/YunFuseSearch.vue +418 -0
- package/client/components/YunTwikoo.vue +14 -0
- package/client/components/YunWaline.vue +17 -0
- package/components/YunBanner.vue +12 -3
- package/components/YunCloud.vue +14 -1
- package/components/YunFireworks.vue +4 -27
- package/components/YunFuseSearch.vue +4 -476
- package/components/YunPostCategories.vue +6 -3
- package/components/YunPostDateMeta.vue +26 -9
- package/components/YunSearchTrigger.vue +8 -2
- package/components/author/YunAuthorAvatar.vue +2 -0
- package/components/collection/YunCollectionCard.vue +6 -18
- package/components/menu/YunNavMenuItem.vue +4 -1
- package/components/prologue/YunPrologueSquare.vue +41 -88
- package/components/theme/nimbo/YunNimboNavMenu.vue +56 -79
- package/components/theme/strato/YunStratoNavMenu.vue +25 -46
- package/components/third/YunArtalk.vue +4 -10
- package/components/third/YunTwikoo.vue +4 -12
- package/components/third/YunWaline.vue +4 -15
- package/layouts/home.vue +45 -23
- package/layouts/post.vue +14 -5
- package/package.json +2 -2
- package/stores/app.ts +3 -3
- package/styles/common/nav.scss +3 -3
- package/styles/index.ts +1 -0
- package/styles/widgets/search.scss +57 -0
- package/utils/animation.ts +4 -8
- package/utils/scroll.ts +7 -0
|
@@ -1,478 +1,6 @@
|
|
|
1
|
-
<script lang="ts"
|
|
2
|
-
import {
|
|
3
|
-
import { DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle, VisuallyHidden } from 'reka-ui'
|
|
4
|
-
import { useFuseSearch } from 'valaxy'
|
|
5
|
-
import { computed, nextTick, shallowRef, watch } from 'vue'
|
|
6
|
-
import { useI18n } from 'vue-i18n'
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineAsyncComponent } from 'vue'
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const { t, locale } = useI18n()
|
|
11
|
-
const zh = computed(() => locale.value.startsWith('zh'))
|
|
12
|
-
const input = shallowRef('')
|
|
13
|
-
const query = computed(() => input.value.trim())
|
|
14
|
-
const { results, fetchFuseListData } = useFuseSearch(query)
|
|
15
|
-
const dialog = shallowRef<HTMLElement>()
|
|
16
|
-
const searchInput = shallowRef<HTMLInputElement>()
|
|
17
|
-
const resultsContainer = shallowRef<HTMLElement>()
|
|
18
|
-
const { arrivedState, measure } = useScroll(resultsContainer, { offset: { bottom: 1 } })
|
|
19
|
-
useResizeObserver(resultsContainer, measure)
|
|
20
|
-
watch(results, () => nextTick(measure), { flush: 'post' })
|
|
21
|
-
const activeIndex = shallowRef(0)
|
|
22
|
-
const loading = shallowRef(false)
|
|
23
|
-
const failed = shallowRef(false)
|
|
24
|
-
let loaded = false
|
|
25
|
-
|
|
26
|
-
async function load() {
|
|
27
|
-
if (loaded || loading.value)
|
|
28
|
-
return
|
|
29
|
-
loading.value = true
|
|
30
|
-
failed.value = false
|
|
31
|
-
try {
|
|
32
|
-
await fetchFuseListData()
|
|
33
|
-
loaded = true
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
failed.value = true
|
|
37
|
-
}
|
|
38
|
-
finally {
|
|
39
|
-
loading.value = false
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
watch(() => props.open, (open) => {
|
|
44
|
-
if (open)
|
|
45
|
-
void load()
|
|
46
|
-
}, { immediate: true })
|
|
47
|
-
watch(query, () => {
|
|
48
|
-
activeIndex.value = 0
|
|
49
|
-
})
|
|
50
|
-
function onKeydown(event: KeyboardEvent) {
|
|
51
|
-
if (event.isComposing || !results.value.length)
|
|
52
|
-
return
|
|
53
|
-
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
54
|
-
event.preventDefault()
|
|
55
|
-
activeIndex.value = (activeIndex.value + (event.key === 'ArrowDown' ? 1 : -1) + results.value.length) % results.value.length
|
|
56
|
-
nextTick(() => dialog.value?.querySelectorAll<HTMLElement>('.yun-search-result')[activeIndex.value]?.focus())
|
|
57
|
-
}
|
|
58
|
-
else if (event.key === 'Enter' && event.target === searchInput.value) {
|
|
59
|
-
event.preventDefault()
|
|
60
|
-
dialog.value?.querySelectorAll<HTMLElement>('.yun-search-result')[activeIndex.value]?.click()
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function onBackdrop(event: MouseEvent) {
|
|
65
|
-
if (event.target !== dialog.value)
|
|
66
|
-
return
|
|
67
|
-
emit('close')
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function excerpt(text: string = '') {
|
|
71
|
-
return text.replace(/<!--[\s\S]*?(?:-->|$)/g, '').replace(/!\[[^\]]*\]\([^)]*\)/g, '').replace(/\[([^\]]+)\]\([^)]*\)/g, '$1').replace(/<[^>]*>/g, '').replace(/[#*>`_]/g, '').replace(/\s+/g, ' ').trim().slice(0, 180)
|
|
72
|
-
}
|
|
4
|
+
// Keep the public component auto-imported so site/addon overrides still win.
|
|
5
|
+
export default defineAsyncComponent(() => import('../client/components/YunFuseSearch.vue'))
|
|
73
6
|
</script>
|
|
74
|
-
|
|
75
|
-
<template>
|
|
76
|
-
<DialogRoot :open="open" @update:open="value => !value && emit('close')">
|
|
77
|
-
<DialogPortal to="#valaxy-teleports">
|
|
78
|
-
<DialogOverlay class="yun-search-backdrop" />
|
|
79
|
-
<DialogContent as-child @open-auto-focus.prevent="searchInput?.focus()">
|
|
80
|
-
<div ref="dialog" class="yun-fuse-dialog" @click="onBackdrop" @keydown="onKeydown">
|
|
81
|
-
<VisuallyHidden as-child>
|
|
82
|
-
<DialogTitle>{{ zh ? '搜索文章' : 'Search articles' }}</DialogTitle>
|
|
83
|
-
</VisuallyHidden>
|
|
84
|
-
<VisuallyHidden as-child>
|
|
85
|
-
<DialogDescription>{{ zh ? '搜索标题、正文或标签,使用方向键选择结果,按 Enter 打开。' : 'Search titles, content, or tags. Use arrow keys to select and Enter to open.' }}</DialogDescription>
|
|
86
|
-
</VisuallyHidden>
|
|
87
|
-
<div class="yun-search-field">
|
|
88
|
-
<span class="i-ri-search-line" aria-hidden="true" />
|
|
89
|
-
<input
|
|
90
|
-
ref="searchInput" v-model="input" type="search" autocomplete="off"
|
|
91
|
-
:placeholder="zh ? '搜索文章…' : 'Search articles…'" :aria-label="zh ? '搜索文章' : 'Search articles'"
|
|
92
|
-
>
|
|
93
|
-
<DialogClose class="yun-search-dismiss yun-icon-btn yun-search-action" :aria-label="zh ? '关闭搜索' : 'Close search'">
|
|
94
|
-
<div class="i-ri-close-line" aria-hidden="true" />
|
|
95
|
-
</DialogClose>
|
|
96
|
-
</div>
|
|
97
|
-
<div class="yun-search-status" role="status" aria-live="polite">
|
|
98
|
-
<template v-if="loading">
|
|
99
|
-
{{ zh ? '正在加载文章…' : 'Loading articles…' }}
|
|
100
|
-
</template>
|
|
101
|
-
<template v-else-if="failed">
|
|
102
|
-
{{ zh ? '文章加载失败。' : 'Unable to load articles.' }}
|
|
103
|
-
<button type="button" @click="load">
|
|
104
|
-
{{ zh ? '重试' : 'Retry' }}
|
|
105
|
-
</button>
|
|
106
|
-
</template>
|
|
107
|
-
<template v-else-if="query">
|
|
108
|
-
{{ t('search.hits', results.length) }}
|
|
109
|
-
</template>
|
|
110
|
-
<template v-else>
|
|
111
|
-
{{ zh ? '搜索标题、正文或标签' : 'Search titles, content, or tags' }}
|
|
112
|
-
</template>
|
|
113
|
-
</div>
|
|
114
|
-
<div
|
|
115
|
-
v-if="query && results.length" ref="resultsContainer" class="yun-search-results"
|
|
116
|
-
:style="{ '--yun-search-fade-bottom': arrivedState.bottom ? '0px' : '56px' }"
|
|
117
|
-
>
|
|
118
|
-
<AppLink
|
|
119
|
-
v-for="(result, index) in results" :key="result.item.link" :to="result.item.link"
|
|
120
|
-
class="yun-search-result" :class="{ 'is-selected': index === activeIndex }"
|
|
121
|
-
@focus="activeIndex = index" @click="emit('close')"
|
|
122
|
-
>
|
|
123
|
-
<span class="yun-search-result-title">{{ result.item.title }}</span>
|
|
124
|
-
<span v-if="result.item.excerpt" class="yun-search-result-excerpt">{{ excerpt(result.item.excerpt) }}</span>
|
|
125
|
-
<span class="yun-search-result-path">{{ result.item.link }}</span>
|
|
126
|
-
</AppLink>
|
|
127
|
-
</div>
|
|
128
|
-
<p v-else-if="query && !loading && !failed" class="yun-search-empty">
|
|
129
|
-
{{ zh ? '没有匹配的文章,试试更短的关键词。' : 'No matching articles. Try a shorter keyword.' }}
|
|
130
|
-
</p>
|
|
131
|
-
<footer class="yun-search-footer">
|
|
132
|
-
<span>{{ zh ? '站内搜索' : 'Site search' }}</span>
|
|
133
|
-
<span class="yun-search-shortcuts"><kbd>↑</kbd><kbd>↓</kbd> {{ zh ? '选择' : 'Select' }} <kbd>↵</kbd> {{ zh ? '打开' : 'Open' }} <kbd>esc</kbd> {{ zh ? '关闭' : 'Close' }}</span>
|
|
134
|
-
</footer>
|
|
135
|
-
</div>
|
|
136
|
-
</DialogContent>
|
|
137
|
-
</DialogPortal>
|
|
138
|
-
</DialogRoot>
|
|
139
|
-
</template>
|
|
140
|
-
|
|
141
|
-
<style lang="scss">
|
|
142
|
-
.yun-search-popup {
|
|
143
|
-
position: fixed;
|
|
144
|
-
top: 0;
|
|
145
|
-
left: 0;
|
|
146
|
-
width: 100%;
|
|
147
|
-
height: 100%;
|
|
148
|
-
backdrop-filter: blur(30px);
|
|
149
|
-
/* stylelint-disable-next-line property-no-vendor-prefix */
|
|
150
|
-
-webkit-backdrop-filter: blur(30px);
|
|
151
|
-
text-align: center;
|
|
152
|
-
margin: 0;
|
|
153
|
-
z-index: var(--yun-z-search-popup);
|
|
154
|
-
transition: opacity var(--va-transition-duration-fast);
|
|
155
|
-
background-color: var(--va-c-bg-opacity);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.yun-search-input {
|
|
159
|
-
background: transparent;
|
|
160
|
-
color: var(--va-c-text);
|
|
161
|
-
font-size: 1.5rem;
|
|
162
|
-
border-radius: 3rem;
|
|
163
|
-
padding: 1rem 1.5rem;
|
|
164
|
-
border: 1px solid var(--va-c-gray);
|
|
165
|
-
box-sizing: border-box;
|
|
166
|
-
width: 90%;
|
|
167
|
-
max-width: 800px;
|
|
168
|
-
font-family: var(--va-font-serif);
|
|
169
|
-
font-weight: 900;
|
|
170
|
-
text-align: center;
|
|
171
|
-
transition: border-color var(--va-transition-duration-fast);
|
|
172
|
-
|
|
173
|
-
&:focus {
|
|
174
|
-
border-color: var(--va-c-text);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.yun-popup {
|
|
179
|
-
.search-icon, .close-icon {
|
|
180
|
-
display: inline-block;
|
|
181
|
-
width: 2rem;
|
|
182
|
-
height: 2rem;
|
|
183
|
-
padding: 0.5rem;
|
|
184
|
-
|
|
185
|
-
.icon {
|
|
186
|
-
width: 2rem;
|
|
187
|
-
height: 2rem;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.yun-fuse-search {
|
|
193
|
-
.yun-fuse-result-item {
|
|
194
|
-
// padding: 0.5rem;
|
|
195
|
-
cursor: pointer;
|
|
196
|
-
border-top: 1px dashed #ccc;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
</style>
|
|
200
|
-
|
|
201
|
-
<style lang="scss" scoped>
|
|
202
|
-
.yun-fuse-dialog {
|
|
203
|
-
--search-line: rgb(30 40 60 / 0.14);
|
|
204
|
-
--search-selection: rgb(0 102 204 / 0.05);
|
|
205
|
-
--search-muted: #626b77;
|
|
206
|
-
|
|
207
|
-
position: fixed;
|
|
208
|
-
z-index: 1001;
|
|
209
|
-
inset: 0;
|
|
210
|
-
width: 100%;
|
|
211
|
-
height: 100dvh;
|
|
212
|
-
max-width: none;
|
|
213
|
-
max-height: none;
|
|
214
|
-
margin: 0;
|
|
215
|
-
padding: clamp(64px, 10vh, 100px) 24px 24px;
|
|
216
|
-
overflow: hidden;
|
|
217
|
-
border: 0;
|
|
218
|
-
border-radius: 0;
|
|
219
|
-
color: var(--va-c-text);
|
|
220
|
-
background: transparent;
|
|
221
|
-
box-shadow: none;
|
|
222
|
-
font-family: var(--va-font-sans, sans-serif);
|
|
223
|
-
font-weight: 400;
|
|
224
|
-
line-height: 1.5;
|
|
225
|
-
text-align: left;
|
|
226
|
-
box-sizing: border-box;
|
|
227
|
-
|
|
228
|
-
&[data-state="open"] {
|
|
229
|
-
display: flex;
|
|
230
|
-
flex-direction: column;
|
|
231
|
-
align-items: center;
|
|
232
|
-
animation: search-appear 180ms ease-out;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
button {
|
|
236
|
-
font: inherit;
|
|
237
|
-
cursor: pointer;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
button:focus-visible, a:focus-visible {
|
|
241
|
-
outline: 2px solid var(--yun-focus-color, #06c);
|
|
242
|
-
outline-offset: -2px;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
:global(html.dark .yun-fuse-dialog) {
|
|
247
|
-
--search-line: rgb(255 255 255 / 0.14);
|
|
248
|
-
--search-selection: rgb(100 181 246 / 0.07);
|
|
249
|
-
--search-muted: #aeb6c2;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
.yun-search-backdrop {
|
|
253
|
-
position: fixed;
|
|
254
|
-
inset: 0;
|
|
255
|
-
z-index: 1000;
|
|
256
|
-
background: rgb(250 251 253 / 0.84);
|
|
257
|
-
backdrop-filter: blur(30px);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
:global(html.dark .yun-search-backdrop) {
|
|
261
|
-
background: rgb(22 24 29 / 0.84);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
.yun-search-field {
|
|
265
|
-
width: min(100%, 960px);
|
|
266
|
-
flex-shrink: 0;
|
|
267
|
-
|
|
268
|
-
> span {
|
|
269
|
-
display: none;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
input {
|
|
273
|
-
box-sizing: border-box;
|
|
274
|
-
width: 100%;
|
|
275
|
-
min-width: 0;
|
|
276
|
-
padding: 20px 40px;
|
|
277
|
-
border: 1px solid var(--search-line);
|
|
278
|
-
outline: none;
|
|
279
|
-
border-radius: 999px;
|
|
280
|
-
background: transparent;
|
|
281
|
-
color: inherit;
|
|
282
|
-
font-family: var(--va-font-serif, serif);
|
|
283
|
-
font-weight: 500;
|
|
284
|
-
font-size: clamp(26px, 3vw, 36px);
|
|
285
|
-
line-height: 1.5;
|
|
286
|
-
text-align: center;
|
|
287
|
-
transition: border-color 160ms ease, box-shadow 160ms ease;
|
|
288
|
-
|
|
289
|
-
&::placeholder {
|
|
290
|
-
color: var(--search-muted);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
&:focus {
|
|
294
|
-
border-color: var(--yun-focus-color, #06c);
|
|
295
|
-
box-shadow: 0 0 0 1px var(--yun-focus-color, #06c);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
&::-webkit-search-cancel-button {
|
|
299
|
-
display: none;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
.yun-search-dismiss {
|
|
305
|
-
position: absolute;
|
|
306
|
-
top: calc((var(--yun-nav-height, 50px) - 3rem) / 2);
|
|
307
|
-
right: 0;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
.yun-search-status {
|
|
311
|
-
padding: 24px 0 20px;
|
|
312
|
-
font-size: 13px;
|
|
313
|
-
letter-spacing: 0.04em;
|
|
314
|
-
color: var(--search-muted);
|
|
315
|
-
flex-shrink: 0;
|
|
316
|
-
text-align: center;
|
|
317
|
-
|
|
318
|
-
button {
|
|
319
|
-
color: var(--va-c-link);
|
|
320
|
-
margin-left: 4px;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
.yun-search-results {
|
|
325
|
-
mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - var(--yun-search-fade-bottom, 0px)), transparent 100%);
|
|
326
|
-
width: min(100%, 800px);
|
|
327
|
-
padding: 0 8px;
|
|
328
|
-
overflow-y: auto;
|
|
329
|
-
overscroll-behavior: contain;
|
|
330
|
-
min-height: 0;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
.yun-search-result {
|
|
334
|
-
display: flex;
|
|
335
|
-
flex-direction: column;
|
|
336
|
-
gap: 8px;
|
|
337
|
-
padding: 22px 16px;
|
|
338
|
-
border-top: 1px solid var(--search-line);
|
|
339
|
-
border-radius: 0;
|
|
340
|
-
color: inherit;
|
|
341
|
-
text-decoration: none;
|
|
342
|
-
overflow-wrap: anywhere;
|
|
343
|
-
font-weight: 400;
|
|
344
|
-
|
|
345
|
-
&.is-selected, &:hover {
|
|
346
|
-
background: var(--search-selection);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
&.is-selected .yun-search-result-title {
|
|
350
|
-
color: var(--va-c-link);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
.yun-search-result-title {
|
|
355
|
-
font-family: var(--va-font-serif, serif);
|
|
356
|
-
font-size: 22px;
|
|
357
|
-
font-weight: 600;
|
|
358
|
-
line-height: 1.5;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
.yun-search-result-excerpt {
|
|
362
|
-
font-size: 14px;
|
|
363
|
-
line-height: 1.8;
|
|
364
|
-
color: var(--search-muted);
|
|
365
|
-
display: -webkit-box;
|
|
366
|
-
-webkit-box-orient: vertical;
|
|
367
|
-
-webkit-line-clamp: 2;
|
|
368
|
-
overflow: hidden;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
.yun-search-result-path {
|
|
372
|
-
font-size: 12px;
|
|
373
|
-
color: var(--search-muted);
|
|
374
|
-
white-space: nowrap;
|
|
375
|
-
overflow: hidden;
|
|
376
|
-
text-overflow: ellipsis;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
.yun-search-empty {
|
|
380
|
-
margin: 0;
|
|
381
|
-
padding: 32px 0;
|
|
382
|
-
font-size: 14px;
|
|
383
|
-
color: var(--search-muted);
|
|
384
|
-
text-align: center;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
.yun-search-footer {
|
|
388
|
-
display: flex;
|
|
389
|
-
justify-content: center;
|
|
390
|
-
align-items: center;
|
|
391
|
-
gap: 24px;
|
|
392
|
-
padding-top: 24px;
|
|
393
|
-
margin-top: auto;
|
|
394
|
-
color: var(--search-muted);
|
|
395
|
-
font-size: 11px;
|
|
396
|
-
flex-shrink: 0;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
.yun-search-shortcuts {
|
|
400
|
-
display: flex;
|
|
401
|
-
align-items: center;
|
|
402
|
-
gap: 6px;
|
|
403
|
-
|
|
404
|
-
kbd {
|
|
405
|
-
font: inherit;
|
|
406
|
-
min-width: 16px;
|
|
407
|
-
text-align: center;
|
|
408
|
-
border: 1px solid var(--search-line);
|
|
409
|
-
border-radius: 4px;
|
|
410
|
-
padding: 0 3px;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
@keyframes search-appear {
|
|
415
|
-
from {
|
|
416
|
-
opacity: 0;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
to {
|
|
420
|
-
opacity: 1;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
@media (width <= 640px) {
|
|
425
|
-
.yun-fuse-dialog {
|
|
426
|
-
padding: max(76px, calc(env(safe-area-inset-top) + 60px)) 20px max(20px, env(safe-area-inset-bottom));
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
.yun-search-field input {
|
|
430
|
-
padding: 14px 24px;
|
|
431
|
-
font-size: 26px;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
.yun-search-status {
|
|
435
|
-
padding: 20px 0;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
.yun-search-results {
|
|
439
|
-
padding: 0;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
.yun-search-result {
|
|
443
|
-
padding: 18px 8px;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
.yun-search-result-title {
|
|
447
|
-
font-size: 19px;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
.yun-search-footer {
|
|
451
|
-
padding-top: 16px;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
.yun-search-shortcuts {
|
|
455
|
-
display: none;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
@media (prefers-reduced-motion: reduce) {
|
|
460
|
-
.yun-fuse-dialog[data-state="open"] {
|
|
461
|
-
animation: none;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
.yun-search-field input {
|
|
465
|
-
transition: none;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
@media (prefers-reduced-transparency: reduce) {
|
|
470
|
-
.yun-search-backdrop {
|
|
471
|
-
backdrop-filter: none;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
.yun-fuse-dialog {
|
|
475
|
-
background: var(--va-c-bg);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
</style>
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { Post } from 'valaxy'
|
|
3
3
|
import { useValaxyI18n } from 'valaxy'
|
|
4
|
+
import { computed } from 'vue'
|
|
4
5
|
|
|
5
|
-
defineProps<{
|
|
6
|
-
categories
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
categories?: Post['categories']
|
|
7
8
|
}>()
|
|
8
9
|
|
|
9
10
|
const { $tCategory } = useValaxyI18n()
|
|
11
|
+
const categoryPath = computed(() => Array.isArray(props.categories) ? props.categories.join('/') : props.categories)
|
|
10
12
|
</script>
|
|
11
13
|
|
|
12
14
|
<template>
|
|
13
15
|
<RouterLink
|
|
16
|
+
v-if="categoryPath?.trim()"
|
|
14
17
|
:to="{
|
|
15
18
|
path: '/categories',
|
|
16
|
-
query: { category:
|
|
19
|
+
query: { category: categoryPath },
|
|
17
20
|
}"
|
|
18
21
|
class="transition post-category inline-flex-center text-xs border-$va-c-divider"
|
|
19
22
|
px-2 h="7"
|
|
@@ -1,30 +1,47 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { Post } from 'valaxy'
|
|
3
|
-
import {
|
|
3
|
+
import { toZonedDayjs } from 'valaxy'
|
|
4
|
+
import { computed } from 'vue'
|
|
4
5
|
import { useI18n } from 'vue-i18n'
|
|
5
|
-
import { formatTimestamp } from '../utils'
|
|
6
6
|
|
|
7
|
-
defineProps<{
|
|
7
|
+
const props = defineProps<{
|
|
8
8
|
// FrontMatter
|
|
9
9
|
frontmatter: Post
|
|
10
10
|
}>()
|
|
11
11
|
|
|
12
12
|
const { t } = useI18n()
|
|
13
|
+
|
|
14
|
+
function formatPostDate(date: NonNullable<Post['date']>) {
|
|
15
|
+
const zonedDate = toZonedDayjs(date)
|
|
16
|
+
return {
|
|
17
|
+
label: zonedDate.format('YYYY-MM-DD'),
|
|
18
|
+
timestamp: zonedDate.format('YYYY-MM-DD HH:mm:ss'),
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const posted = computed(() => {
|
|
23
|
+
const { date } = props.frontmatter
|
|
24
|
+
return date ? formatPostDate(date) : undefined
|
|
25
|
+
})
|
|
26
|
+
const edited = computed(() => {
|
|
27
|
+
const { date, updated } = props.frontmatter
|
|
28
|
+
return updated && updated !== date ? formatPostDate(updated) : undefined
|
|
29
|
+
})
|
|
13
30
|
</script>
|
|
14
31
|
|
|
15
32
|
<template>
|
|
16
|
-
<div v-if="
|
|
17
|
-
<span class="posted-time inline-flex-center gap-1" :title="t('post.posted') +
|
|
33
|
+
<div v-if="posted" class="post-time flex items-center gap-4">
|
|
34
|
+
<span class="posted-time inline-flex-center gap-1" :title="t('post.posted') + posted.timestamp">
|
|
18
35
|
<div class="inline-block" i-ri-calendar-line />
|
|
19
|
-
<time class="op-80">{{
|
|
36
|
+
<time class="op-80">{{ posted.label }}</time>
|
|
20
37
|
</span>
|
|
21
38
|
|
|
22
39
|
<span
|
|
23
|
-
v-if="
|
|
24
|
-
class="edited-time inline-flex-center gap-1" :title="t('post.edited') +
|
|
40
|
+
v-if="edited"
|
|
41
|
+
class="edited-time inline-flex-center gap-1" :title="t('post.edited') + edited.timestamp"
|
|
25
42
|
>
|
|
26
43
|
<div i-ri-calendar-2-line />
|
|
27
|
-
<time class="op-80">{{
|
|
44
|
+
<time class="op-80">{{ edited.label }}</time>
|
|
28
45
|
</span>
|
|
29
46
|
</div>
|
|
30
47
|
</template>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { useSiteConfig } from 'valaxy'
|
|
3
|
-
import { computed, defineAsyncComponent, onMounted, ref } from 'vue'
|
|
3
|
+
import { computed, defineAsyncComponent, onMounted, ref, watch } from 'vue'
|
|
4
4
|
import { useHotKey } from '../composables'
|
|
5
5
|
|
|
6
6
|
const siteConfig = useSiteConfig()
|
|
@@ -10,6 +10,12 @@ const isFuse = computed(() => siteConfig.value.search.provider === 'fuse')
|
|
|
10
10
|
const isLocal = computed(() => siteConfig.value.search.provider === 'local')
|
|
11
11
|
|
|
12
12
|
const open = ref(false)
|
|
13
|
+
// Keep the dialog mounted after its first use to preserve the query and index.
|
|
14
|
+
const searchLoaded = ref(false)
|
|
15
|
+
watch(open, (value) => {
|
|
16
|
+
if (value)
|
|
17
|
+
searchLoaded.value = true
|
|
18
|
+
})
|
|
13
19
|
|
|
14
20
|
function togglePopup() {
|
|
15
21
|
open.value = !open.value
|
|
@@ -44,6 +50,6 @@ const YunAlgoliaSearch = isAlgolia.value
|
|
|
44
50
|
<YunSearchBtn :open="open && !isAlgolia" @open="openSearch" @close="closeSearch" />
|
|
45
51
|
|
|
46
52
|
<YunAlgoliaSearch v-if="isAlgolia" ref="algoliaRef" :open="open" @close="closeSearch" />
|
|
47
|
-
<YunFuseSearch v-else-if="isFuse" :open="open" @close="closeSearch" />
|
|
53
|
+
<YunFuseSearch v-else-if="isFuse && searchLoaded" :open="open" @close="closeSearch" />
|
|
48
54
|
<YunLocalSearch v-else-if="isLocal" :open="open" @close="closeSearch" />
|
|
49
55
|
</template>
|
|
@@ -11,6 +11,8 @@ const siteConfig = useSiteConfig()
|
|
|
11
11
|
class="rounded-full size-full bg-white dark:bg-white/20 p-1 m-0 absolute"
|
|
12
12
|
:src="withBase(siteConfig.author.avatar)"
|
|
13
13
|
alt="avatar"
|
|
14
|
+
width="100" height="100"
|
|
15
|
+
fetchpriority="high"
|
|
14
16
|
>
|
|
15
17
|
<span
|
|
16
18
|
v-if="siteConfig.author.status.emoji"
|
|
@@ -15,6 +15,7 @@ const { $tO } = useValaxyI18n()
|
|
|
15
15
|
const cover = computed(() => props.post.cover || props.collection.cover)
|
|
16
16
|
const title = computed(() => props.post.title || props.collection.title)
|
|
17
17
|
const itemCount = computed(() => props.collection.items?.length ?? 0)
|
|
18
|
+
const categories = computed(() => props.post.categories?.length ? props.post.categories : props.collection.categories)
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Preview up to 3 items from the collection
|
|
@@ -86,7 +87,7 @@ const hasMoreItems = computed(() => itemCount.value > 3)
|
|
|
86
87
|
|
|
87
88
|
<div w="full" class="yun-card-actions flex justify-between p-4" min-h="10" text="sm">
|
|
88
89
|
<div class="post-categories inline-flex" flex="wrap 1" items="center">
|
|
89
|
-
<YunPostCategories
|
|
90
|
+
<YunPostCategories m="l-1" :categories="categories" />
|
|
90
91
|
</div>
|
|
91
92
|
<YunPostTags v-if="post.tags || collection.tags" m="1" :tags="(post.tags || collection.tags)!" />
|
|
92
93
|
</div>
|
|
@@ -98,6 +99,7 @@ const hasMoreItems = computed(() => itemCount.value > 3)
|
|
|
98
99
|
.collection-card {
|
|
99
100
|
--collection-accent: var(--va-c-primary);
|
|
100
101
|
--collection-accent-light: var(--va-c-primary-lighter, var(--va-c-primary));
|
|
102
|
+
--collection-accent-text: color-mix(in srgb, var(--va-c-text-1) 80%, var(--collection-accent));
|
|
101
103
|
|
|
102
104
|
border-left: 3px solid var(--collection-accent);
|
|
103
105
|
transition: border-color var(--va-transition-duration), box-shadow var(--va-transition-duration), scale var(--va-transition-duration);
|
|
@@ -111,6 +113,7 @@ const hasMoreItems = computed(() => itemCount.value > 3)
|
|
|
111
113
|
.collection-card-body {
|
|
112
114
|
padding: 0.75rem 1rem;
|
|
113
115
|
gap: 0.35rem;
|
|
116
|
+
color: var(--va-c-text-2);
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
.collection-card-badge {
|
|
@@ -122,8 +125,7 @@ const hasMoreItems = computed(() => itemCount.value > 3)
|
|
|
122
125
|
font-weight: 600;
|
|
123
126
|
text-transform: uppercase;
|
|
124
127
|
letter-spacing: 0.05em;
|
|
125
|
-
color: var(--collection-accent);
|
|
126
|
-
opacity: 0.55;
|
|
128
|
+
color: var(--collection-accent-text);
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
.collection-card-title {
|
|
@@ -136,9 +138,7 @@ const hasMoreItems = computed(() => itemCount.value > 3)
|
|
|
136
138
|
font-size: 1.25rem;
|
|
137
139
|
font-weight: 800;
|
|
138
140
|
font-family: var(--va-font-serif);
|
|
139
|
-
|
|
140
|
-
background-clip: text;
|
|
141
|
-
-webkit-text-fill-color: transparent;
|
|
141
|
+
color: var(--collection-accent-text);
|
|
142
142
|
line-height: 1.4;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -146,14 +146,11 @@ const hasMoreItems = computed(() => itemCount.value > 3)
|
|
|
146
146
|
.collection-card-count {
|
|
147
147
|
font-size: 0.8rem;
|
|
148
148
|
font-weight: 600;
|
|
149
|
-
color: var(--collection-accent);
|
|
150
|
-
opacity: 0.5;
|
|
151
149
|
}
|
|
152
150
|
|
|
153
151
|
.collection-card-desc {
|
|
154
152
|
align-self: flex-start;
|
|
155
153
|
font-size: 0.8rem;
|
|
156
|
-
opacity: 0.6;
|
|
157
154
|
line-height: 1.5;
|
|
158
155
|
display: -webkit-box;
|
|
159
156
|
-webkit-line-clamp: 2;
|
|
@@ -175,13 +172,7 @@ const hasMoreItems = computed(() => itemCount.value > 3)
|
|
|
175
172
|
align-items: center;
|
|
176
173
|
gap: 0.3rem;
|
|
177
174
|
font-size: 0.75rem;
|
|
178
|
-
opacity: 0.5;
|
|
179
175
|
line-height: 1.6;
|
|
180
|
-
transition: opacity var(--va-transition-duration-fast);
|
|
181
|
-
|
|
182
|
-
.collection-card:hover & {
|
|
183
|
-
opacity: 0.7;
|
|
184
|
-
}
|
|
185
176
|
}
|
|
186
177
|
|
|
187
178
|
.collection-card-item-dot {
|
|
@@ -195,8 +186,6 @@ const hasMoreItems = computed(() => itemCount.value > 3)
|
|
|
195
186
|
|
|
196
187
|
.collection-card-item-more {
|
|
197
188
|
letter-spacing: 0.1em;
|
|
198
|
-
color: var(--collection-accent);
|
|
199
|
-
opacity: 0.4;
|
|
200
189
|
}
|
|
201
190
|
|
|
202
191
|
.collection-card-empty {
|
|
@@ -205,7 +194,6 @@ const hasMoreItems = computed(() => itemCount.value > 3)
|
|
|
205
194
|
align-items: center;
|
|
206
195
|
gap: 0.35rem;
|
|
207
196
|
font-size: 0.75rem;
|
|
208
|
-
opacity: 0.35;
|
|
209
197
|
margin-top: 0.2rem;
|
|
210
198
|
font-style: italic;
|
|
211
199
|
}
|