valaxy-theme-yun 0.18.5 → 0.18.7
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/components/YunComment.vue +2 -1
- package/components/YunFuseSearch.vue +13 -19
- package/components/YunMdTimeWarning.vue +17 -9
- package/components/YunPostCollapse.vue +2 -2
- package/components/YunSearchTrigger.vue +17 -6
- package/components/YunSelect.vue +14 -6
- package/components/third/YunArtalk.vue +12 -0
- package/layouts/post.vue +3 -3
- package/package.json +5 -5
- package/setup/main.ts +0 -6
@@ -3,7 +3,7 @@ import { useRuntimeConfig } from 'valaxy'
|
|
3
3
|
import { computed, ref } from 'vue'
|
4
4
|
|
5
5
|
const runtimeConfig = useRuntimeConfig()
|
6
|
-
const supportCommentAddons = ['valaxy-addon-waline', 'valaxy-addon-twikoo']
|
6
|
+
const supportCommentAddons = ['valaxy-addon-waline', 'valaxy-addon-twikoo', 'valaxy-addon-artalk']
|
7
7
|
|
8
8
|
const commentSystems = computed(() => {
|
9
9
|
return supportCommentAddons.filter(addonName => runtimeConfig.value.addons[addonName]).map(addonName => addonName.split('-')[2])
|
@@ -20,6 +20,7 @@ const activeComment = ref(commentSystems.value[0])
|
|
20
20
|
</div>
|
21
21
|
<YunWaline v-if="activeComment === 'waline'" />
|
22
22
|
<YunTwikoo v-if="activeComment === 'twikoo'" />
|
23
|
+
<YunArtalk v-if="activeComment === 'artalk'" />
|
23
24
|
<slot />
|
24
25
|
</ClientOnly>
|
25
26
|
</YunCard>
|
@@ -3,11 +3,10 @@ import type { UseFuseOptions } from '@vueuse/integrations/useFuse'
|
|
3
3
|
import { useFuse } from '@vueuse/integrations/useFuse'
|
4
4
|
import { computed, ref, watch } from 'vue'
|
5
5
|
import { useI18n } from 'vue-i18n'
|
6
|
-
import {
|
7
|
-
import { useRouter } from 'vue-router'
|
6
|
+
import { useSiteConfig } from 'valaxy'
|
8
7
|
import type { FuseListItem } from 'valaxy/types'
|
9
8
|
|
10
|
-
import { onClickOutside } from '@vueuse/core'
|
9
|
+
import { isClient, onClickOutside, useScrollLock } from '@vueuse/core'
|
11
10
|
|
12
11
|
const props = defineProps<{
|
13
12
|
open: boolean
|
@@ -16,7 +15,7 @@ const emit = defineEmits(['close'])
|
|
16
15
|
|
17
16
|
const searchContainer = ref<HTMLElement>()
|
18
17
|
|
19
|
-
const
|
18
|
+
const isLocked = useScrollLock(isClient ? document.body : null)
|
20
19
|
|
21
20
|
const { t } = useI18n()
|
22
21
|
|
@@ -32,20 +31,21 @@ const keys = computed(() => {
|
|
32
31
|
|
33
32
|
const input = ref('')
|
34
33
|
// todo export options
|
35
|
-
const
|
34
|
+
const useFuseOptions = computed<UseFuseOptions<FuseListItem>>(() => ({
|
36
35
|
fuseOptions: {
|
36
|
+
includeMatches: true,
|
37
|
+
findAllMatches: true,
|
38
|
+
|
37
39
|
...siteConfig.value.fuse.options,
|
38
40
|
keys: keys.value,
|
39
41
|
|
40
42
|
// threshold: 0.99,
|
41
43
|
// ignoreLocation: true,
|
42
44
|
},
|
43
|
-
includeMatches: true,
|
44
|
-
findAllMatches: true,
|
45
45
|
// resultLimit: resultLimit.value,
|
46
46
|
// matchAllWhenSearchEmpty: matchAllWhenSearchEmpty.value,
|
47
47
|
}))
|
48
|
-
const { results } = useFuse(input, fuseListData,
|
48
|
+
const { results } = useFuse(input, fuseListData, useFuseOptions)
|
49
49
|
|
50
50
|
const searchInputRef = ref<HTMLInputElement>()
|
51
51
|
|
@@ -66,12 +66,6 @@ watch(() => props.open, async () => {
|
|
66
66
|
})
|
67
67
|
})
|
68
68
|
|
69
|
-
const router = useRouter()
|
70
|
-
function jumpToLink(link: string) {
|
71
|
-
router.push(link)
|
72
|
-
emit('close')
|
73
|
-
}
|
74
|
-
|
75
69
|
onClickOutside(searchInputRef, () => {
|
76
70
|
// emit('close')
|
77
71
|
})
|
@@ -80,8 +74,8 @@ onClickOutside(searchInputRef, () => {
|
|
80
74
|
<template>
|
81
75
|
<Transition
|
82
76
|
name="fade"
|
83
|
-
@enter="
|
84
|
-
@after-leave="
|
77
|
+
@enter="isLocked = true"
|
78
|
+
@after-leave="isLocked = false"
|
85
79
|
>
|
86
80
|
<div
|
87
81
|
v-if="open" ref="searchContainer"
|
@@ -97,12 +91,12 @@ onClickOutside(searchInputRef, () => {
|
|
97
91
|
</div>
|
98
92
|
<div v-if="results.length > 0" overflow="auto" flex="~" w="full">
|
99
93
|
<div class="yun-fuse-result-container" flex="~ col" w="full">
|
100
|
-
<
|
94
|
+
<AppLink
|
101
95
|
v-for="result in results" :key="result.item.title"
|
102
96
|
:to="result.item.link"
|
103
97
|
class="yun-fuse-result-item text-$va-c-text hover:(text-$va-c-bg bg-$va-c-text-dark bg-opacity-100)"
|
104
98
|
flex="~ col" pb-2
|
105
|
-
@click="
|
99
|
+
@click="emit('close')"
|
106
100
|
>
|
107
101
|
<h3 font="serif black">
|
108
102
|
{{ result.item.title }}
|
@@ -113,7 +107,7 @@ onClickOutside(searchInputRef, () => {
|
|
113
107
|
<span text-xs opacity-50 mt="1">
|
114
108
|
Score Index: {{ result.refIndex }}
|
115
109
|
</span>
|
116
|
-
</
|
110
|
+
</AppLink>
|
117
111
|
</div>
|
118
112
|
</div>
|
119
113
|
</div>
|
@@ -1,24 +1,32 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
2
|
import { computed } from 'vue'
|
3
3
|
import { useFrontmatter } from 'valaxy'
|
4
|
-
|
5
|
-
import dayjs from 'dayjs'
|
6
|
-
import relativeTime from 'dayjs/plugin/relativeTime'
|
7
|
-
|
8
4
|
import { useI18n } from 'vue-i18n'
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
dayjs.extend(relativeTime)
|
6
|
+
import { differenceInMilliseconds, formatDistanceToNow } from 'date-fns'
|
13
7
|
|
8
|
+
const fm = useFrontmatter()
|
14
9
|
const { t } = useI18n()
|
15
10
|
|
11
|
+
const updated = computed(() => fm.value.updated || fm.value.date || new Date())
|
12
|
+
const ago = computed(() => {
|
13
|
+
const fromNow = formatDistanceToNow(updated.value, { addSuffix: true })
|
14
|
+
if (/^\d/.test(fromNow))
|
15
|
+
return ` ${fromNow}`
|
16
|
+
else
|
17
|
+
return fromNow
|
18
|
+
})
|
19
|
+
|
16
20
|
/**
|
17
21
|
* when the post is updated more than 180 days ago, show a warning
|
18
22
|
* default 180 days, you can set `time_warning` in frontmatter to change it
|
19
23
|
*/
|
20
24
|
const time_warning = computed(() => {
|
21
|
-
const diff =
|
25
|
+
const diff = differenceInMilliseconds(new Date(), updated.value)
|
26
|
+
/**
|
27
|
+
* if `time_warning` is a number, compare the time difference
|
28
|
+
* if `time_warning` is a boolean, show warning by flag
|
29
|
+
*/
|
22
30
|
if (typeof fm.value.time_warning === 'number')
|
23
31
|
return diff > fm.value.time_warning
|
24
32
|
else
|
@@ -28,6 +36,6 @@ const time_warning = computed(() => {
|
|
28
36
|
|
29
37
|
<template>
|
30
38
|
<blockquote v-if="time_warning" class="yun-time-warning" op="80">
|
31
|
-
{{ t('post.time_warning', { ago
|
39
|
+
{{ t('post.time_warning', { ago }) }}
|
32
40
|
</blockquote>
|
33
41
|
</template>
|
@@ -20,7 +20,7 @@ watch(() => props.posts, () => {
|
|
20
20
|
if (post.hide && post.hide !== 'index')
|
21
21
|
return
|
22
22
|
if (post.date) {
|
23
|
-
const year = Number.parseInt(formatDate(post.date, '
|
23
|
+
const year = Number.parseInt(formatDate(post.date, 'yyyy'))
|
24
24
|
if (postListByYear.value[year]) {
|
25
25
|
postListByYear.value[year].push(post)
|
26
26
|
}
|
@@ -68,7 +68,7 @@ const sortedYears = computed(() => {
|
|
68
68
|
<header class="post-header" flex items-center relative>
|
69
69
|
<div class="post-meta">
|
70
70
|
<time v-if="post.date" class="post-time" font="mono" opacity="80">{{
|
71
|
-
formatDate(post.date, 'MM-
|
71
|
+
formatDate(post.date, 'MM-dd') }}
|
72
72
|
</time>
|
73
73
|
</div>
|
74
74
|
<h2 class="post-title" inline-flex items-center font="serif black">
|
@@ -1,7 +1,6 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
2
|
import { useSiteConfig } from 'valaxy'
|
3
|
-
import { computed, defineAsyncComponent,
|
4
|
-
import { useMagicKeys } from '@vueuse/core'
|
3
|
+
import { computed, defineAsyncComponent, onMounted, onUnmounted, ref } from 'vue'
|
5
4
|
|
6
5
|
const siteConfig = useSiteConfig()
|
7
6
|
|
@@ -14,11 +13,23 @@ function togglePopup() {
|
|
14
13
|
open.value = !open.value
|
15
14
|
}
|
16
15
|
|
17
|
-
|
16
|
+
onMounted(() => {
|
17
|
+
const handleSearchHotKey = (event: KeyboardEvent) => {
|
18
|
+
if (
|
19
|
+
(event.key.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey))
|
20
|
+
) {
|
21
|
+
event.preventDefault()
|
22
|
+
togglePopup()
|
23
|
+
}
|
24
|
+
}
|
18
25
|
|
19
|
-
|
20
|
-
|
21
|
-
|
26
|
+
const remove = () => {
|
27
|
+
window.removeEventListener('keydown', handleSearchHotKey)
|
28
|
+
}
|
29
|
+
|
30
|
+
window.addEventListener('keydown', handleSearchHotKey)
|
31
|
+
|
32
|
+
onUnmounted(remove)
|
22
33
|
})
|
23
34
|
|
24
35
|
function openSearch() {
|
package/components/YunSelect.vue
CHANGED
@@ -12,16 +12,23 @@ const optionVisible = ref(false)
|
|
12
12
|
useEventListener('click', () => {
|
13
13
|
optionVisible.value = false
|
14
14
|
})
|
15
|
+
|
16
|
+
function toggleOptionVisible(e: MouseEvent) {
|
17
|
+
e.preventDefault()
|
18
|
+
e.stopImmediatePropagation()
|
19
|
+
e.stopPropagation()
|
20
|
+
optionVisible.value = !optionVisible.value
|
21
|
+
}
|
15
22
|
</script>
|
16
23
|
|
17
24
|
<template>
|
18
|
-
<div class="relative h-8 w-30 text-[var(--va-c-text-2)] z-
|
25
|
+
<div class="relative h-8 w-30 text-[var(--va-c-text-2)] z-20" @mousedown.stop>
|
19
26
|
<button
|
20
|
-
class="flex h-full w-full px-2 items-center justify-between border rounded
|
27
|
+
class="flex h-full w-full px-2 items-center justify-between border rounded transition"
|
21
28
|
:class="optionVisible ? 'border-[var(--va-c-primary)] shadow-lg' : ''"
|
22
|
-
@click
|
29
|
+
@click="toggleOptionVisible"
|
23
30
|
>
|
24
|
-
<span>{{ activeValue }}</span>
|
31
|
+
<span case-capital op-90>{{ activeValue }}</span>
|
25
32
|
<div inline-flex i-ri-arrow-down-s-line />
|
26
33
|
</button>
|
27
34
|
<Transition>
|
@@ -32,7 +39,8 @@ useEventListener('click', () => {
|
|
32
39
|
<li
|
33
40
|
v-for="option in options"
|
34
41
|
:key="option"
|
35
|
-
class="cursor-pointer list-none px-2 hover:bg-[var(--va-c-primary-
|
42
|
+
class="cursor-pointer list-none px-2 hover:bg-[var(--va-c-primary-light)] hover:text-white case-capital"
|
43
|
+
:class="{ 'bg-[var(--va-c-primary)] text-white': activeValue === option }"
|
36
44
|
@click="activeValue = option"
|
37
45
|
>
|
38
46
|
{{ option }}
|
@@ -49,7 +57,7 @@ useEventListener('click', () => {
|
|
49
57
|
|
50
58
|
.v-enter-active,
|
51
59
|
.v-leave-active {
|
52
|
-
transition: opacity .
|
60
|
+
transition: opacity .2s ease;
|
53
61
|
}
|
54
62
|
|
55
63
|
.v-enter-from,
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<script lang="ts" setup>
|
2
|
+
import * as addonArtalk from 'valaxy-addon-artalk'
|
3
|
+
import 'valaxy-addon-artalk/client/styles/index.scss'
|
4
|
+
import { isEmptyAddon } from 'valaxy'
|
5
|
+
|
6
|
+
if (!isEmptyAddon(addonArtalk))
|
7
|
+
addonArtalk.useArtalkWithOptions()
|
8
|
+
</script>
|
9
|
+
|
10
|
+
<template>
|
11
|
+
<ArtalkClient />
|
12
|
+
</template>
|
package/layouts/post.vue
CHANGED
@@ -4,7 +4,7 @@ import { useFrontmatter, useFullUrl, useSiteConfig } from 'valaxy'
|
|
4
4
|
|
5
5
|
import type { Article } from '@unhead/schema-org'
|
6
6
|
import { defineArticle, useSchemaOrg } from '@unhead/schema-org'
|
7
|
-
import
|
7
|
+
import { toDate } from 'date-fns'
|
8
8
|
|
9
9
|
const siteConfig = useSiteConfig()
|
10
10
|
const frontmatter = useFrontmatter()
|
@@ -27,8 +27,8 @@ const article: Article = {
|
|
27
27
|
url: siteConfig.value.author.link,
|
28
28
|
},
|
29
29
|
],
|
30
|
-
'datePublished':
|
31
|
-
'dateModified':
|
30
|
+
'datePublished': toDate(frontmatter.value.date || ''),
|
31
|
+
'dateModified': toDate(frontmatter.value.updated || ''),
|
32
32
|
}
|
33
33
|
|
34
34
|
const image = frontmatter.value.image || frontmatter.value.cover
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "valaxy-theme-yun",
|
3
|
-
"version": "0.18.
|
3
|
+
"version": "0.18.7",
|
4
4
|
"author": {
|
5
5
|
"email": "me@yunyoujun.cn",
|
6
6
|
"name": "YunYouJun",
|
@@ -19,13 +19,13 @@
|
|
19
19
|
"module": "index.ts",
|
20
20
|
"dependencies": {
|
21
21
|
"@explosions/fireworks": "^0.0.2",
|
22
|
-
"@iconify-json/ant-design": "^1.1.
|
23
|
-
"@iconify-json/simple-icons": "^1.1.
|
22
|
+
"@iconify-json/ant-design": "^1.1.16",
|
23
|
+
"@iconify-json/simple-icons": "^1.1.101",
|
24
24
|
"animejs": "^3.2.2"
|
25
25
|
},
|
26
26
|
"devDependencies": {
|
27
27
|
"@types/animejs": "^3.1.12",
|
28
|
-
"valaxy": "0.18.
|
29
|
-
"valaxy-addon-waline": "0.1.
|
28
|
+
"valaxy": "0.18.7",
|
29
|
+
"valaxy-addon-waline": "0.1.4"
|
30
30
|
}
|
31
31
|
}
|
package/setup/main.ts
CHANGED