valaxy-theme-yun 0.24.5 → 0.25.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,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import type { CategoryList, Post } from 'valaxy'
3
- import { useInvisibleElement } from 'valaxy'
3
+ import { useInvisibleElement, useValaxyI18n } from 'valaxy'
4
4
  import { onMounted, ref } from 'vue'
5
5
  import { useI18n } from 'vue-i18n'
6
6
  import { useRouter } from 'vue-router'
@@ -25,6 +25,7 @@ const router = useRouter()
25
25
 
26
26
  const collapse = ref(props.collapsable)
27
27
  const { t } = useI18n()
28
+ const { $t } = useValaxyI18n()
28
29
 
29
30
  const postCollapseElRef = ref<HTMLElement>()
30
31
  const { show } = useInvisibleElement(postCollapseElRef)
@@ -79,7 +80,7 @@ if (props.level === 1) {
79
80
  @click="jumpToDisplayCategory(parentKey)"
80
81
  >
81
82
  <span>
82
- {{ category.name === 'Uncategorized' ? t('category.uncategorized') : category.name }}
83
+ {{ category.name === 'Uncategorized' ? t('category.uncategorized') : $t(category.name) }}
83
84
  </span>
84
85
  <span class="rounded-full px-1.5 bg-black/5 shadow-sm op-60" text="xs">
85
86
  {{ category.total }}
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { useSiteConfig, useValaxyConfig, useValaxyDark } from 'valaxy'
2
+ import { useSiteConfig, useValaxyConfig, useValaxyDark, useValaxyI18n } from 'valaxy'
3
3
  import pkg from 'valaxy/package.json'
4
4
  import { capitalize, computed } from 'vue'
5
5
  import { useI18n } from 'vue-i18n'
@@ -21,6 +21,7 @@ const gradientStyles = computed(() => {
21
21
  })
22
22
 
23
23
  const { t } = useI18n()
24
+ const { $t } = useValaxyI18n()
24
25
  const config = useValaxyConfig()
25
26
  const siteConfig = useSiteConfig()
26
27
  const themeConfig = useThemeConfig()
@@ -72,7 +73,7 @@ const footerIcon = computed(() => themeConfig.value.footer.icon || {
72
73
  >
73
74
  <div :class="footerIcon.name" />
74
75
  </a>
75
- <span>{{ siteConfig.author.name }}</span>
76
+ <span>{{ $t(siteConfig.author.name) }}</span>
76
77
  </div>
77
78
 
78
79
  <div v-if="themeConfig.footer.powered" class="powered" m="2">
@@ -1,4 +1,5 @@
1
1
  <script lang="ts" setup>
2
+ import { useValaxyI18n } from 'valaxy'
2
3
  import { ref } from 'vue'
3
4
  import { useYunSpringAnimation } from '../composables/animation'
4
5
 
@@ -8,6 +9,8 @@ const props = defineProps<{
8
9
  count: number
9
10
  }>()
10
11
 
12
+ const { $t } = useValaxyI18n()
13
+
11
14
  const tagRef = ref<HTMLElement>()
12
15
  useYunSpringAnimation(tagRef, {
13
16
  i: props.i || 0,
@@ -21,7 +24,7 @@ useYunSpringAnimation(tagRef, {
21
24
  inline-flex my="2" p="1"
22
25
  class="post-tag cursor-pointer items-baseline leading-4"
23
26
  >
24
- <span inline-flex>#{{ title }}</span>
27
+ <span inline-flex>#{{ $t(title) }}</span>
25
28
  <span inline-flex text="xs">[{{ count }}]</span>
26
29
  </span>
27
30
  </template>
@@ -1,9 +1,12 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Post } from 'valaxy'
3
+ import { useValaxyI18n } from 'valaxy'
3
4
 
4
5
  defineProps<{
5
6
  categories: Post['categories']
6
7
  }>()
8
+
9
+ const { $t } = useValaxyI18n()
7
10
  </script>
8
11
 
9
12
  <template>
@@ -19,7 +22,7 @@ defineProps<{
19
22
  >
20
23
  <div m="x-1" inline-flex i-ri-folder-2-line />
21
24
  <span>
22
- {{ Array.isArray(categories) ? categories.join(' / ') : categories }}
25
+ {{ Array.isArray(categories) ? categories.map($t).join(' / ') : $t(categories || '') }}
23
26
  </span>
24
27
  </RouterLink>
25
28
  </template>
@@ -1,9 +1,12 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Post } from 'valaxy'
3
+ import { useValaxyI18n } from 'valaxy'
3
4
 
4
5
  defineProps<{
5
6
  tags: Post['tags']
6
7
  }>()
8
+
9
+ const { $t } = useValaxyI18n()
7
10
  </script>
8
11
 
9
12
  <template>
@@ -19,7 +22,7 @@ defineProps<{
19
22
  border
20
23
  hover="bg-blue-500 text-white"
21
24
  >
22
- <span>{{ tag }}</span>
25
+ <span>{{ $t(tag) }}</span>
23
26
  </RouterLink>
24
27
  </div>
25
28
  </template>
@@ -16,7 +16,7 @@ function togglePopup() {
16
16
 
17
17
  const algoliaRef = ref()
18
18
  onMounted(() => {
19
- // algolia has its own hotkey
19
+ // algolia has its own hotkey handling in YunAlgoliaSearch component
20
20
  if (isFuse.value)
21
21
  useHotKey('k', togglePopup)
22
22
  })
@@ -1,8 +1,7 @@
1
1
  <script lang="ts" setup>
2
- import { useSiteConfig } from 'valaxy'
3
- import { useI18n } from 'vue-i18n'
2
+ import { useSiteConfig, useValaxyI18n } from 'valaxy'
4
3
 
5
- const { t } = useI18n()
4
+ const { $t } = useValaxyI18n()
6
5
  const siteConfig = useSiteConfig()
7
6
  </script>
8
7
 
@@ -16,14 +15,14 @@ const siteConfig = useSiteConfig()
16
15
  <YunAuthorName />
17
16
  <YunSiteTitle />
18
17
  <h4
19
- v-if="siteConfig.subtitle"
18
+ v-if="$t(siteConfig.subtitle)"
20
19
  class="site-subtitle block"
21
20
  text="xs"
22
21
  >
23
- {{ t(siteConfig.subtitle) }}
22
+ {{ $t(siteConfig.subtitle) }}
24
23
  </h4>
25
24
  <div v-if="siteConfig.description" class="site-description">
26
- {{ t(siteConfig.description) }}
25
+ {{ $t(siteConfig.description) }}
27
26
  </div>
28
27
  </div>
29
28
  </template>
@@ -1,12 +1,14 @@
1
1
  <script setup lang="ts">
2
2
  import type { SocialLink } from 'valaxy/types'
3
- import { useAppStore } from 'valaxy'
3
+ import { useAppStore, useValaxyI18n } from 'valaxy'
4
4
  import { computed } from 'vue'
5
5
 
6
6
  const props = defineProps<{
7
7
  social: SocialLink
8
8
  }>()
9
9
 
10
+ const { $t } = useValaxyI18n()
11
+
10
12
  const appStore = useAppStore()
11
13
  const color = computed(() => {
12
14
  return (appStore.isDark && props.social.color === 'black') ? 'white' : props.social.color
@@ -16,7 +18,7 @@ const color = computed(() => {
16
18
  <template>
17
19
  <a
18
20
  class="links-of-author-item yun-icon-btn"
19
- rel="noopener" :href="social.link" :title="social.name"
21
+ rel="noopener" :href="social.link" :title="$t(social.name)"
20
22
  target="_blank"
21
23
  :style="`color:${color}`"
22
24
  >
@@ -1,9 +1,10 @@
1
1
  <script lang="ts" setup>
2
- import { useSiteConfig } from 'valaxy'
2
+ import { useSiteConfig, useValaxyI18n } from 'valaxy'
3
3
  import { computed, ref } from 'vue'
4
4
  import { useI18n } from 'vue-i18n'
5
5
 
6
6
  const { t } = useI18n()
7
+ const { $t } = useValaxyI18n()
7
8
 
8
9
  const siteConfig = useSiteConfig()
9
10
  const showQr = ref(false)
@@ -35,7 +36,7 @@ const sponsorBtnTitle = computed(() => {
35
36
  :href="method.url" target="_blank"
36
37
  :style="`color:${method.color}`"
37
38
  >
38
- <img class="sponsor-method-img" border="~ rounded" p="1" loading="lazy" :src="method.url" :title="method.name">
39
+ <img class="sponsor-method-img" border="~ rounded" p="1" loading="lazy" :src="method.url" :title="$t(method.name)">
39
40
  <div text="xl" m="2" :class="method.icon" />
40
41
  </a>
41
42
  </div>
@@ -1,13 +1,12 @@
1
1
  <script setup lang="ts">
2
- import { useSiteConfig } from 'valaxy'
3
- import { useI18n } from 'vue-i18n'
2
+ import { useSiteConfig, useValaxyI18n } from 'valaxy'
4
3
 
5
4
  const siteConfig = useSiteConfig()
6
- const { t } = useI18n()
5
+ const { $t } = useValaxyI18n()
7
6
  </script>
8
7
 
9
8
  <template>
10
9
  <div v-if="siteConfig.author.intro" class="site-author-intro" m="t-0 b-4">
11
- {{ t(siteConfig.author.intro) }}
10
+ {{ $t(siteConfig.author.intro) }}
12
11
  </div>
13
12
  </template>
@@ -1,7 +1,8 @@
1
1
  <script setup lang="ts">
2
- import { useSiteConfig } from 'valaxy'
2
+ import { useSiteConfig, useValaxyI18n } from 'valaxy'
3
3
 
4
4
  const siteConfig = useSiteConfig()
5
+ const { $t } = useValaxyI18n()
5
6
  </script>
6
7
 
7
8
  <template>
@@ -9,6 +10,6 @@ const siteConfig = useSiteConfig()
9
10
  class="site-author-name font-black font-serif text-$va-c-text op-80 hover:op-100 flex-center"
10
11
  to="/about"
11
12
  >
12
- {{ siteConfig.author.name }}
13
+ {{ $t(siteConfig.author.name) }}
13
14
  </RouterLink>
14
15
  </template>
@@ -1,11 +1,10 @@
1
1
  <script setup lang="ts">
2
- import { useFrontmatter, useSiteConfig } from 'valaxy'
2
+ import { tObject, useFrontmatter, useSiteConfig, useValaxyI18n } from 'valaxy'
3
3
  import { computed, ref, watch } from 'vue'
4
- import { useI18n } from 'vue-i18n'
5
4
  import { useRoute, useRouter } from 'vue-router'
6
5
  import { useYunAppStore } from '../../stores'
7
6
 
8
- const { t } = useI18n()
7
+ const { $t, locale } = useValaxyI18n()
9
8
 
10
9
  const yunApp = useYunAppStore()
11
10
  const fm = useFrontmatter()
@@ -64,14 +63,14 @@ function goToLink() {
64
63
  class="size-4"
65
64
  :class="fm.icon || 'i-ri-article-line'"
66
65
  />
67
- <span class="truncate"> {{ fm.title }}</span>
66
+ <span class="truncate"> {{ tObject(fm.title || '', locale) }}</span>
68
67
  </div>
69
68
  <span v-if="fm.subtitle" class="font-light op-80">
70
- {{ fm.subtitle }}
69
+ {{ tObject(fm.subtitle || '', locale) }}
71
70
  </span>
72
71
  </div>
73
72
  <span v-if="showSiteTitle" class="font-light truncate">
74
- {{ t(siteConfig.title) }}
73
+ {{ $t(siteConfig.title) }}
75
74
  </span>
76
75
  </div>
77
76
  </template>
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { useMotion } from '@vueuse/motion'
3
- import { ref } from 'vue'
3
+ import { useValaxyI18n } from 'valaxy/client'
4
+ import { computed, ref } from 'vue'
4
5
 
5
6
  const props = defineProps<{
6
7
  social: {
@@ -12,7 +13,7 @@ const props = defineProps<{
12
13
  // animation
13
14
  delay: number
14
15
  }>()
15
-
16
+ const { $t } = useValaxyI18n()
16
17
  const iconRef = ref<HTMLElement>()
17
18
  useMotion(iconRef, {
18
19
  initial: {
@@ -34,18 +35,20 @@ useMotion(iconRef, {
34
35
  },
35
36
  },
36
37
  })
38
+
39
+ const socialName = computed(() => $t(props.social.name))
37
40
  </script>
38
41
 
39
42
  <template>
40
43
  <div
41
- v-tooltip="social.name"
44
+ v-tooltip="socialName"
42
45
  class="size-10 inline-flex-center"
43
46
  >
44
47
  <a
45
48
  ref="iconRef"
46
49
  class="prologue-social-icon inline-flex-center w-full h-full text-white bg-$c-brand hover:bg-white hover:text-$c-brand"
47
50
  rel="noopener"
48
- :href="social.link" :title="social.name"
51
+ :href="social.link" :title="socialName"
49
52
  target="_blank"
50
53
  :style="`--c-brand:${social.color}`"
51
54
  >
@@ -1,13 +1,12 @@
1
1
  <script setup lang="ts">
2
- import { useSiteConfig } from 'valaxy'
3
- import { useI18n } from 'vue-i18n'
2
+ import { useSiteConfig, useValaxyI18n } from 'valaxy'
4
3
 
5
4
  const siteConfig = useSiteConfig()
6
- const { t } = useI18n()
5
+ const { $t } = useValaxyI18n()
7
6
  </script>
8
7
 
9
8
  <template>
10
9
  <div v-if="siteConfig.description" class="site-description text-$va-c-text text-sm">
11
- {{ t(siteConfig.description) }}
10
+ {{ $t(siteConfig.description) }}
12
11
  </div>
13
12
  </template>
@@ -1,6 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { useSiteConfig } from 'valaxy'
3
- import { useI18n } from 'vue-i18n'
2
+ import { useSiteConfig, useValaxyI18n } from 'valaxy'
4
3
  import { useRouter } from 'vue-router'
5
4
  import { useThemeConfig } from '../../composables'
6
5
 
@@ -8,8 +7,7 @@ const router = useRouter()
8
7
  const siteConfig = useSiteConfig()
9
8
  const themeConfig = useThemeConfig()
10
9
 
11
- const { t } = useI18n()
12
-
10
+ const { $t } = useValaxyI18n()
13
11
  // bg-gradient-to-r gradient-text from-#1e3c72 to-dark dark:(from-#66a6ff to-blue-500)
14
12
  </script>
15
13
 
@@ -19,14 +17,14 @@ const { t } = useI18n()
19
17
  class="site-name text-lg leading-loose"
20
18
  :class="themeConfig.banner.siteNameClass"
21
19
  >
22
- {{ t(siteConfig.title) }}
20
+ {{ $t(siteConfig.title) }}
23
21
  </RouterLink>
24
22
  <span
25
23
  v-else
26
24
  class="site-name text-lg leading-loose"
27
25
  :class="themeConfig.banner.siteNameClass"
28
26
  >
29
- {{ t(siteConfig.title) }}
27
+ {{ $t(siteConfig.title) }}
30
28
  </span>
31
29
  </template>
32
30
 
@@ -1,6 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import { isEmptyAddon } from 'valaxy'
3
3
  import * as addonAlgolia from 'valaxy-addon-algolia'
4
+ import { onMounted, onUnmounted } from 'vue'
4
5
 
5
6
  defineProps<{
6
7
  open: boolean
@@ -16,6 +17,40 @@ defineExpose({
16
17
  load,
17
18
  dispatchEvent,
18
19
  })
20
+
21
+ function isEditingContent(event: KeyboardEvent): boolean {
22
+ const element = event.target as HTMLElement
23
+ const tagName = element.tagName
24
+
25
+ return (
26
+ element.isContentEditable
27
+ || tagName === 'INPUT'
28
+ || tagName === 'SELECT'
29
+ || tagName === 'TEXTAREA'
30
+ )
31
+ }
32
+
33
+ onMounted(() => {
34
+ const handleSearchHotKey = (event: KeyboardEvent) => {
35
+ if (
36
+ (event.key?.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey))
37
+ || (!isEditingContent(event) && event.key === '/')
38
+ ) {
39
+ event.preventDefault()
40
+ load()
41
+ // eslint-disable-next-line ts/no-use-before-define
42
+ remove()
43
+ }
44
+ }
45
+
46
+ const remove = () => {
47
+ window.removeEventListener('keydown', handleSearchHotKey)
48
+ }
49
+
50
+ window.addEventListener('keydown', handleSearchHotKey)
51
+
52
+ onUnmounted(remove)
53
+ })
19
54
  </script>
20
55
 
21
56
  <template>
package/layouts/post.vue CHANGED
@@ -2,20 +2,21 @@
2
2
  import { defineArticle, useSchemaOrg } from '@unhead/schema-org/vue'
3
3
 
4
4
  import dayjs from 'dayjs'
5
- import { tObject, useFrontmatter, useSiteConfig } from 'valaxy'
5
+ import { tObject, useFrontmatter, useSiteConfig, useValaxyI18n } from 'valaxy'
6
6
  import { useI18n } from 'vue-i18n'
7
7
 
8
8
  const siteConfig = useSiteConfig()
9
9
  const frontmatter = useFrontmatter()
10
10
 
11
11
  const { locale } = useI18n()
12
+ const { $t } = useValaxyI18n()
12
13
  const article: Parameters<typeof defineArticle>[0] = {
13
14
  '@type': 'BlogPosting',
14
15
  'headline': tObject(frontmatter.value.title || '', locale.value),
15
16
  'description': tObject(frontmatter.value.description || '', locale.value),
16
17
  'author': [
17
18
  {
18
- name: siteConfig.value.author.name,
19
+ name: $t(siteConfig.value.author.name),
19
20
  url: siteConfig.value.author.link,
20
21
  },
21
22
  ],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valaxy-theme-yun",
3
3
  "type": "module",
4
- "version": "0.24.5",
4
+ "version": "0.25.0",
5
5
  "author": {
6
6
  "email": "me@yunyoujun.cn",
7
7
  "name": "YunYouJun",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/animejs": "^3.1.13",
35
- "valaxy": "0.24.5",
35
+ "valaxy": "0.25.0",
36
36
  "valaxy-addon-waline": "0.2.1"
37
37
  },
38
38
  "scripts": {