@sugarat/theme 0.1.49 → 0.1.50
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/node.d.ts +1 -1
- package/node.js +23 -19
- package/package.json +23 -23
- package/src/components/BlogAlert.vue +17 -17
- package/src/components/BlogApp.vue +81 -49
- package/src/components/BlogArticleAnalyze.vue +56 -57
- package/src/components/BlogComment.vue +53 -50
- package/src/components/BlogDocCover.vue +4 -4
- package/src/components/BlogFriendLink.vue +40 -31
- package/src/components/BlogHomeBanner.vue +22 -16
- package/src/components/BlogHomeOverview.vue +20 -20
- package/src/components/BlogHomeTags.vue +49 -40
- package/src/components/BlogHotArticle.vue +43 -36
- package/src/components/BlogImagePreview.vue +7 -5
- package/src/components/BlogItem.vue +42 -43
- package/src/components/BlogList.vue +46 -42
- package/src/components/BlogPopover.vue +41 -39
- package/src/components/BlogRecommendArticle.vue +58 -48
- package/src/components/BlogSearch.vue +143 -145
- package/src/components/UserWorks.vue +214 -210
- package/src/composables/config/blog.ts +7 -5
- package/src/composables/config/index.ts +33 -31
- package/src/constants/svg.ts +2 -2
- package/src/index.ts +1 -2
- package/src/node.ts +2 -2
- package/src/styles/scss/global.scss +0 -5
- package/src/utils/client/index.ts +9 -8
- package/src/utils/node/genFeed.ts +8 -7
- package/src/utils/node/index.ts +8 -6
- package/src/utils/node/mdPlugins.ts +29 -22
- package/src/utils/node/theme.ts +16 -13
- package/src/utils/node/vitePlugins.ts +7 -6
- package/types/vue-shim.d.ts +1 -1
|
@@ -1,142 +1,16 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="blog-search" v-if="openSearch" data-pagefind-ignore="all">
|
|
3
|
-
<div class="nav-search-btn-wait" @click="searchModal = true">
|
|
4
|
-
<svg width="14" height="14" viewBox="0 0 20 20">
|
|
5
|
-
<path
|
|
6
|
-
d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z"
|
|
7
|
-
stroke="currentColor"
|
|
8
|
-
fill="none"
|
|
9
|
-
fill-rule="evenodd"
|
|
10
|
-
stroke-linecap="round"
|
|
11
|
-
stroke-linejoin="round"
|
|
12
|
-
></path>
|
|
13
|
-
</svg>
|
|
14
|
-
<span v-if="!isMinimized" class="search-tip">{{
|
|
15
|
-
searchConfig?.btnPlaceholder || '搜索'
|
|
16
|
-
}}</span>
|
|
17
|
-
<span v-if="!isMinimized" class="metaKey"> {{ metaKey }} K </span>
|
|
18
|
-
</div>
|
|
19
|
-
<Command.Dialog :visible="searchModal" theme="algolia">
|
|
20
|
-
<template #header>
|
|
21
|
-
<Command.Input
|
|
22
|
-
v-model:value="searchWords"
|
|
23
|
-
:placeholder="searchConfig?.placeholder || '请输入要搜素的内容'"
|
|
24
|
-
/>
|
|
25
|
-
</template>
|
|
26
|
-
<template #body>
|
|
27
|
-
<div class="search-dialog">
|
|
28
|
-
<Command.List>
|
|
29
|
-
<Command.Empty v-if="!searchResult.length">{{
|
|
30
|
-
searchConfig?.emptyText || 'No results found.'
|
|
31
|
-
}}</Command.Empty>
|
|
32
|
-
<Command.Group v-else :heading="headingText">
|
|
33
|
-
<Command.Item
|
|
34
|
-
v-for="item in searchResult"
|
|
35
|
-
:data-value="item.route"
|
|
36
|
-
:key="item.route"
|
|
37
|
-
@select="handleSelect"
|
|
38
|
-
>
|
|
39
|
-
<div class="link">
|
|
40
|
-
<div class="title">
|
|
41
|
-
<span>{{ item.meta.title }}</span>
|
|
42
|
-
<span class="date">
|
|
43
|
-
{{ formatDate(item.meta.date, 'yyyy-MM-dd') }}</span
|
|
44
|
-
>
|
|
45
|
-
</div>
|
|
46
|
-
<div class="des" v-html="item.meta.description"></div>
|
|
47
|
-
</div>
|
|
48
|
-
</Command.Item>
|
|
49
|
-
</Command.Group>
|
|
50
|
-
</Command.List>
|
|
51
|
-
</div>
|
|
52
|
-
</template>
|
|
53
|
-
<template #footer v-if="searchResult.length">
|
|
54
|
-
<div class="command-palette-logo">
|
|
55
|
-
<a
|
|
56
|
-
v-if="openSearch === 'pagefind'"
|
|
57
|
-
href="https://github.com/cloudcannon/pagefind"
|
|
58
|
-
target="_blank"
|
|
59
|
-
rel="noopener noreferrer"
|
|
60
|
-
>
|
|
61
|
-
<span class="command-palette-Label">Search by</span>
|
|
62
|
-
<logo-pagefind style="width: 77px" />
|
|
63
|
-
</a>
|
|
64
|
-
</div>
|
|
65
|
-
<ul class="command-palette-commands">
|
|
66
|
-
<li>
|
|
67
|
-
<kbd class="command-palette-commands-key"
|
|
68
|
-
><svg width="15" height="15" aria-label="Enter key" role="img">
|
|
69
|
-
<g
|
|
70
|
-
fill="none"
|
|
71
|
-
stroke="currentColor"
|
|
72
|
-
stroke-linecap="round"
|
|
73
|
-
stroke-linejoin="round"
|
|
74
|
-
stroke-width="1.2"
|
|
75
|
-
>
|
|
76
|
-
<path
|
|
77
|
-
d="M12 3.53088v3c0 1-1 2-2 2H4M7 11.53088l-3-3 3-3"
|
|
78
|
-
></path>
|
|
79
|
-
</g></svg></kbd
|
|
80
|
-
><span class="command-palette-Label">to select</span>
|
|
81
|
-
</li>
|
|
82
|
-
<li>
|
|
83
|
-
<kbd class="command-palette-commands-key"
|
|
84
|
-
><svg width="15" height="15" aria-label="Arrow down" role="img">
|
|
85
|
-
<g
|
|
86
|
-
fill="none"
|
|
87
|
-
stroke="currentColor"
|
|
88
|
-
stroke-linecap="round"
|
|
89
|
-
stroke-linejoin="round"
|
|
90
|
-
stroke-width="1.2"
|
|
91
|
-
>
|
|
92
|
-
<path d="M7.5 3.5v8M10.5 8.5l-3 3-3-3"></path>
|
|
93
|
-
</g></svg></kbd
|
|
94
|
-
><kbd class="command-palette-commands-key"
|
|
95
|
-
><svg width="15" height="15" aria-label="Arrow up" role="img">
|
|
96
|
-
<g
|
|
97
|
-
fill="none"
|
|
98
|
-
stroke="currentColor"
|
|
99
|
-
stroke-linecap="round"
|
|
100
|
-
stroke-linejoin="round"
|
|
101
|
-
stroke-width="1.2"
|
|
102
|
-
>
|
|
103
|
-
<path d="M7.5 11.5v-8M10.5 6.5l-3-3-3 3"></path>
|
|
104
|
-
</g></svg></kbd
|
|
105
|
-
><span class="command-palette-Label">to navigate</span>
|
|
106
|
-
</li>
|
|
107
|
-
<li>
|
|
108
|
-
<kbd class="command-palette-commands-key"
|
|
109
|
-
><svg width="15" height="15" aria-label="Escape key" role="img">
|
|
110
|
-
<g
|
|
111
|
-
fill="none"
|
|
112
|
-
stroke="currentColor"
|
|
113
|
-
stroke-linecap="round"
|
|
114
|
-
stroke-linejoin="round"
|
|
115
|
-
stroke-width="1.2"
|
|
116
|
-
>
|
|
117
|
-
<path
|
|
118
|
-
d="M13.6167 8.936c-.1065.3583-.6883.962-1.4875.962-.7993 0-1.653-.9165-1.653-2.1258v-.5678c0-1.2548.7896-2.1016 1.653-2.1016.8634 0 1.3601.4778 1.4875 1.0724M9 6c-.1352-.4735-.7506-.9219-1.46-.8972-.7092.0246-1.344.57-1.344 1.2166s.4198.8812 1.3445.9805C8.465 7.3992 8.968 7.9337 9 8.5c.032.5663-.454 1.398-1.4595 1.398C6.6593 9.898 6 9 5.963 8.4851m-1.4748.5368c-.2635.5941-.8099.876-1.5443.876s-1.7073-.6248-1.7073-2.204v-.4603c0-1.0416.721-2.131 1.7073-2.131.9864 0 1.6425 1.031 1.5443 2.2492h-2.956"
|
|
119
|
-
></path>
|
|
120
|
-
</g></svg></kbd
|
|
121
|
-
><span class="command-palette-Label">to close</span>
|
|
122
|
-
</li>
|
|
123
|
-
</ul>
|
|
124
|
-
</template>
|
|
125
|
-
</Command.Dialog>
|
|
126
|
-
</div>
|
|
127
|
-
</template>
|
|
128
|
-
|
|
129
1
|
<script lang="ts" setup>
|
|
130
2
|
// @ts-nocheck
|
|
131
|
-
import { computed, nextTick,
|
|
3
|
+
import { computed, nextTick, onBeforeMount, onMounted, ref, watch } from 'vue'
|
|
132
4
|
import { Command } from 'vue-command-palette'
|
|
133
5
|
import { useRoute, useRouter, withBase } from 'vitepress'
|
|
134
6
|
import { useMagicKeys, useWindowSize } from '@vueuse/core'
|
|
135
7
|
import { chineseSearchOptimize, formatDate } from '../utils/client'
|
|
136
8
|
import { useArticles, useBlogConfig } from '../composables/config/blog'
|
|
137
|
-
import { Theme } from '../composables/config'
|
|
9
|
+
import type { Theme } from '../composables/config'
|
|
138
10
|
import LogoPagefind from './LogoPagefind.vue'
|
|
139
11
|
|
|
12
|
+
const searchResult = ref<Theme.PageData[]>([])
|
|
13
|
+
|
|
140
14
|
const windowSize = useWindowSize()
|
|
141
15
|
|
|
142
16
|
const isMinimized = computed(() => windowSize.width.value < 760)
|
|
@@ -146,9 +20,9 @@ const { search: searchConfig } = useBlogConfig()
|
|
|
146
20
|
const headingText = computed(() => {
|
|
147
21
|
return searchConfig?.heading
|
|
148
22
|
? searchConfig.heading.replace(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
23
|
+
/\{\{searchResult\}\}/,
|
|
24
|
+
searchResult.value.length
|
|
25
|
+
)
|
|
152
26
|
: `共: ${searchResult.value.length} 个搜索结果`
|
|
153
27
|
})
|
|
154
28
|
const openSearch = computed(() =>
|
|
@@ -157,7 +31,7 @@ const openSearch = computed(() =>
|
|
|
157
31
|
: searchConfig ?? true
|
|
158
32
|
)
|
|
159
33
|
|
|
160
|
-
|
|
34
|
+
function addInlineScript() {
|
|
161
35
|
const scriptText = `import('${withBase('/_pagefind/pagefind.js')}')
|
|
162
36
|
.then((module) => {
|
|
163
37
|
window.__pagefind__ = module
|
|
@@ -196,7 +70,8 @@ const docsMap = computed(() => {
|
|
|
196
70
|
const keys = useMagicKeys({
|
|
197
71
|
passive: false,
|
|
198
72
|
onEventFired(e) {
|
|
199
|
-
if (e.ctrlKey && e.key === 'k' && e.type === 'keydown')
|
|
73
|
+
if (e.ctrlKey && e.key === 'k' && e.type === 'keydown')
|
|
74
|
+
e.preventDefault()
|
|
200
75
|
}
|
|
201
76
|
})
|
|
202
77
|
const CmdK = keys['Meta+K']
|
|
@@ -220,14 +95,13 @@ watch(Escape, (v) => {
|
|
|
220
95
|
}
|
|
221
96
|
})
|
|
222
97
|
|
|
223
|
-
|
|
224
|
-
const inlineSearch = () => {
|
|
98
|
+
function inlineSearch() {
|
|
225
99
|
if (!searchWords.value) {
|
|
226
100
|
searchResult.value = []
|
|
227
101
|
return
|
|
228
102
|
}
|
|
229
103
|
searchResult.value = docs.value
|
|
230
|
-
.filter(
|
|
104
|
+
.filter(v =>
|
|
231
105
|
`${v.meta.description}${v.meta.title}`.includes(searchWords.value)
|
|
232
106
|
)
|
|
233
107
|
.map((v) => {
|
|
@@ -253,11 +127,12 @@ watch(
|
|
|
253
127
|
async () => {
|
|
254
128
|
if (openSearch.value === 'pagefind') {
|
|
255
129
|
// dev-server兜底
|
|
256
|
-
// @ts-
|
|
130
|
+
// @ts-expect-error
|
|
257
131
|
if (!window?.__pagefind__?.search) {
|
|
258
132
|
inlineSearch()
|
|
259
|
-
}
|
|
260
|
-
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
// @ts-expect-error
|
|
261
136
|
await window?.__pagefind__
|
|
262
137
|
?.search?.(chineseSearchOptimize(searchWords.value))
|
|
263
138
|
.then(async (search: any) => {
|
|
@@ -287,7 +162,8 @@ watch(
|
|
|
287
162
|
})
|
|
288
163
|
})
|
|
289
164
|
}
|
|
290
|
-
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
291
167
|
inlineSearch()
|
|
292
168
|
}
|
|
293
169
|
nextTick(() => {
|
|
@@ -299,7 +175,7 @@ watch(
|
|
|
299
175
|
}
|
|
300
176
|
)
|
|
301
177
|
|
|
302
|
-
|
|
178
|
+
function handleClickMask(e: any) {
|
|
303
179
|
if (e.target === e.currentTarget) {
|
|
304
180
|
searchModal.value = false
|
|
305
181
|
}
|
|
@@ -313,7 +189,8 @@ watch(
|
|
|
313
189
|
.querySelector('div[command-dialog-mask]')
|
|
314
190
|
?.addEventListener('click', handleClickMask)
|
|
315
191
|
})
|
|
316
|
-
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
317
194
|
document
|
|
318
195
|
.querySelector('div[command-dialog-mask]')
|
|
319
196
|
?.removeEventListener('click', handleClickMask)
|
|
@@ -334,7 +211,7 @@ watch(
|
|
|
334
211
|
|
|
335
212
|
const router = useRouter()
|
|
336
213
|
const route = useRoute()
|
|
337
|
-
|
|
214
|
+
function handleSelect(target: any) {
|
|
338
215
|
searchModal.value = false
|
|
339
216
|
if (!route.path.startsWith(target.value)) {
|
|
340
217
|
// searchWords.value = ''
|
|
@@ -343,6 +220,127 @@ const handleSelect = (target: any) => {
|
|
|
343
220
|
}
|
|
344
221
|
</script>
|
|
345
222
|
|
|
223
|
+
<template>
|
|
224
|
+
<div v-if="openSearch" class="blog-search" data-pagefind-ignore="all">
|
|
225
|
+
<div class="nav-search-btn-wait" @click="searchModal = true">
|
|
226
|
+
<svg width="14" height="14" viewBox="0 0 20 20">
|
|
227
|
+
<path
|
|
228
|
+
d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z"
|
|
229
|
+
stroke="currentColor"
|
|
230
|
+
fill="none"
|
|
231
|
+
fill-rule="evenodd"
|
|
232
|
+
stroke-linecap="round"
|
|
233
|
+
stroke-linejoin="round"
|
|
234
|
+
/>
|
|
235
|
+
</svg>
|
|
236
|
+
<span v-if="!isMinimized" class="search-tip">{{
|
|
237
|
+
searchConfig?.btnPlaceholder || '搜索'
|
|
238
|
+
}}</span>
|
|
239
|
+
<span v-if="!isMinimized" class="metaKey"> {{ metaKey }} K </span>
|
|
240
|
+
</div>
|
|
241
|
+
<Command.Dialog :visible="searchModal" theme="algolia">
|
|
242
|
+
<template #header>
|
|
243
|
+
<Command.Input
|
|
244
|
+
v-model:value="searchWords"
|
|
245
|
+
:placeholder="searchConfig?.placeholder || '请输入要搜素的内容'"
|
|
246
|
+
/>
|
|
247
|
+
</template>
|
|
248
|
+
<template #body>
|
|
249
|
+
<div class="search-dialog">
|
|
250
|
+
<Command.List>
|
|
251
|
+
<Command.Empty v-if="!searchResult.length">
|
|
252
|
+
{{
|
|
253
|
+
searchConfig?.emptyText || 'No results found.'
|
|
254
|
+
}}
|
|
255
|
+
</Command.Empty>
|
|
256
|
+
<Command.Group v-else :heading="headingText">
|
|
257
|
+
<Command.Item
|
|
258
|
+
v-for="item in searchResult"
|
|
259
|
+
:key="item.route"
|
|
260
|
+
:data-value="item.route"
|
|
261
|
+
@select="handleSelect"
|
|
262
|
+
>
|
|
263
|
+
<div class="link">
|
|
264
|
+
<div class="title">
|
|
265
|
+
<span>{{ item.meta.title }}</span>
|
|
266
|
+
<span class="date">
|
|
267
|
+
{{ formatDate(item.meta.date, 'yyyy-MM-dd') }}</span>
|
|
268
|
+
</div>
|
|
269
|
+
<div class="des" v-html="item.meta.description" />
|
|
270
|
+
</div>
|
|
271
|
+
</Command.Item>
|
|
272
|
+
</Command.Group>
|
|
273
|
+
</Command.List>
|
|
274
|
+
</div>
|
|
275
|
+
</template>
|
|
276
|
+
<template v-if="searchResult.length" #footer>
|
|
277
|
+
<div class="command-palette-logo">
|
|
278
|
+
<a
|
|
279
|
+
v-if="openSearch === 'pagefind'"
|
|
280
|
+
href="https://github.com/cloudcannon/pagefind"
|
|
281
|
+
target="_blank"
|
|
282
|
+
rel="noopener noreferrer"
|
|
283
|
+
>
|
|
284
|
+
<span class="command-palette-Label">Search by</span>
|
|
285
|
+
<LogoPagefind style="width: 77px" />
|
|
286
|
+
</a>
|
|
287
|
+
</div>
|
|
288
|
+
<ul class="command-palette-commands">
|
|
289
|
+
<li>
|
|
290
|
+
<kbd class="command-palette-commands-key"><svg width="15" height="15" aria-label="Enter key" role="img">
|
|
291
|
+
<g
|
|
292
|
+
fill="none"
|
|
293
|
+
stroke="currentColor"
|
|
294
|
+
stroke-linecap="round"
|
|
295
|
+
stroke-linejoin="round"
|
|
296
|
+
stroke-width="1.2"
|
|
297
|
+
>
|
|
298
|
+
<path
|
|
299
|
+
d="M12 3.53088v3c0 1-1 2-2 2H4M7 11.53088l-3-3 3-3"
|
|
300
|
+
/>
|
|
301
|
+
</g></svg></kbd><span class="command-palette-Label">to select</span>
|
|
302
|
+
</li>
|
|
303
|
+
<li>
|
|
304
|
+
<kbd class="command-palette-commands-key"><svg width="15" height="15" aria-label="Arrow down" role="img">
|
|
305
|
+
<g
|
|
306
|
+
fill="none"
|
|
307
|
+
stroke="currentColor"
|
|
308
|
+
stroke-linecap="round"
|
|
309
|
+
stroke-linejoin="round"
|
|
310
|
+
stroke-width="1.2"
|
|
311
|
+
>
|
|
312
|
+
<path d="M7.5 3.5v8M10.5 8.5l-3 3-3-3" />
|
|
313
|
+
</g></svg></kbd><kbd class="command-palette-commands-key"><svg width="15" height="15" aria-label="Arrow up" role="img">
|
|
314
|
+
<g
|
|
315
|
+
fill="none"
|
|
316
|
+
stroke="currentColor"
|
|
317
|
+
stroke-linecap="round"
|
|
318
|
+
stroke-linejoin="round"
|
|
319
|
+
stroke-width="1.2"
|
|
320
|
+
>
|
|
321
|
+
<path d="M7.5 11.5v-8M10.5 6.5l-3-3-3 3" />
|
|
322
|
+
</g></svg></kbd><span class="command-palette-Label">to navigate</span>
|
|
323
|
+
</li>
|
|
324
|
+
<li>
|
|
325
|
+
<kbd class="command-palette-commands-key"><svg width="15" height="15" aria-label="Escape key" role="img">
|
|
326
|
+
<g
|
|
327
|
+
fill="none"
|
|
328
|
+
stroke="currentColor"
|
|
329
|
+
stroke-linecap="round"
|
|
330
|
+
stroke-linejoin="round"
|
|
331
|
+
stroke-width="1.2"
|
|
332
|
+
>
|
|
333
|
+
<path
|
|
334
|
+
d="M13.6167 8.936c-.1065.3583-.6883.962-1.4875.962-.7993 0-1.653-.9165-1.653-2.1258v-.5678c0-1.2548.7896-2.1016 1.653-2.1016.8634 0 1.3601.4778 1.4875 1.0724M9 6c-.1352-.4735-.7506-.9219-1.46-.8972-.7092.0246-1.344.57-1.344 1.2166s.4198.8812 1.3445.9805C8.465 7.3992 8.968 7.9337 9 8.5c.032.5663-.454 1.398-1.4595 1.398C6.6593 9.898 6 9 5.963 8.4851m-1.4748.5368c-.2635.5941-.8099.876-1.5443.876s-1.7073-.6248-1.7073-2.204v-.4603c0-1.0416.721-2.131 1.7073-2.131.9864 0 1.6425 1.031 1.5443 2.2492h-2.956"
|
|
335
|
+
/>
|
|
336
|
+
</g></svg></kbd><span class="command-palette-Label">to close</span>
|
|
337
|
+
</li>
|
|
338
|
+
</ul>
|
|
339
|
+
</template>
|
|
340
|
+
</Command.Dialog>
|
|
341
|
+
</div>
|
|
342
|
+
</template>
|
|
343
|
+
|
|
346
344
|
<style lang="scss" scoped>
|
|
347
345
|
.blog-search {
|
|
348
346
|
flex: v-bind(flexValue);
|