valaxy-theme-yun 0.25.0 → 0.25.2

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.
@@ -17,7 +17,7 @@ const themeConfig = useThemeConfig()
17
17
 
18
18
  // height of top/bottom line
19
19
 
20
- const { totalCharHeight, chars } = useYunBanner(themeConfig.value.banner)
20
+ const { totalCharHeight, chars, bannerTitle } = useYunBanner(themeConfig.value.banner)
21
21
 
22
22
  const bannerStyles = computed<CSSProperties>(() => {
23
23
  const styles: CSSProperties = {
@@ -64,13 +64,13 @@ onMounted(async () => {
64
64
  <template v-if="yun.isNimbo">
65
65
  <YunBannerCharContainer
66
66
  v-if="animationStatus === 'banner'"
67
- :title="themeConfig.banner.title"
67
+ :title="bannerTitle"
68
68
  :chars="chars"
69
69
  />
70
70
  </template>
71
71
  <template v-if="yun.isStrato">
72
72
  <YunBannerCharContainer
73
- :title="themeConfig.banner.title"
73
+ :title="bannerTitle"
74
74
  :chars="chars"
75
75
  />
76
76
  </template>
@@ -1,8 +1,6 @@
1
1
  <script setup lang="ts">
2
- import type { Post } from 'valaxy'
3
- import { isCategoryList, tObject } from 'valaxy'
2
+ import { isCategoryList, useValaxyI18n } from 'valaxy'
4
3
  import { computed } from 'vue'
5
- import { useI18n } from 'vue-i18n'
6
4
  import { useRoute } from 'vue-router'
7
5
 
8
6
  defineProps<{
@@ -14,10 +12,8 @@ defineProps<{
14
12
  /**
15
13
  * i18n
16
14
  */
17
- const { locale } = useI18n()
18
- function getTitle(post: Post | any) {
19
- return tObject(post.title || '', locale.value)
20
- }
15
+ const { $tO } = useValaxyI18n()
16
+
21
17
  const route = useRoute()
22
18
  const categoryList = computed(() => {
23
19
  const c = (route.query.category as string) || ''
@@ -42,7 +38,7 @@ const categoryList = computed(() => {
42
38
  hover="bg-black/5"
43
39
  >
44
40
  <div i-ri-file-text-line />
45
- <span font="serif black">{{ getTitle(categoryItem) }}</span>
41
+ <span class="st-text">{{ $tO(categoryItem.title) }}</span>
46
42
  </RouterLink>
47
43
  </template>
48
44
  </template>
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Post } from 'valaxy'
3
- import { tObject } from 'valaxy'
3
+ import { useValaxyI18n } from 'valaxy'
4
4
  import { computed, ref } from 'vue'
5
5
  import { useI18n } from 'vue-i18n'
6
6
  import { usePostProperty } from '../composables'
@@ -9,7 +9,8 @@ const props = defineProps<{
9
9
  post: Post
10
10
  }>()
11
11
 
12
- const { t, locale } = useI18n()
12
+ const { t } = useI18n()
13
+ const { $tO } = useValaxyI18n()
13
14
 
14
15
  const { icon, styles, color } = usePostProperty(props.post.type)
15
16
 
@@ -20,10 +21,6 @@ const postTitleClass = computed(() => {
20
21
  }
21
22
  return props.post.postTitleClass || gradientClasses.value
22
23
  })
23
-
24
- const postTitle = computed(() => {
25
- return tObject(props.post.title || '', locale.value)
26
- })
27
24
  </script>
28
25
 
29
26
  <template>
@@ -44,7 +41,7 @@ const postTitle = computed(() => {
44
41
  loading="lazy"
45
42
  >
46
43
 
47
- <div class="flex flex-col items-center relative" :class="post.cover && 'h-54'" w="full">
44
+ <div class="flex flex-col items-center relative px-6" :class="post.cover && 'h-54'" w="full">
48
45
  <AppLink
49
46
  class="post-title-link cursor-pointer"
50
47
  :to="post.path || ''"
@@ -56,7 +53,7 @@ const postTitle = computed(() => {
56
53
  text="center" font="serif black"
57
54
  >
58
55
  <div v-if="post.type" class="inline-flex" m="r-1" :class="icon" />
59
- <span>{{ postTitle }}</span>
56
+ <span>{{ $tO(post.title) }}</span>
60
57
  </div>
61
58
  </AppLink>
62
59
 
@@ -86,7 +83,7 @@ const postTitle = computed(() => {
86
83
 
87
84
  <!-- always show -->
88
85
  <div
89
- w="full" class="yun-card-actions flex justify-between"
86
+ w="full" class="yun-card-actions flex justify-between px-6"
90
87
  min-h="10"
91
88
  text="sm"
92
89
  >
@@ -1,10 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import type { Post } from 'valaxy'
3
3
  import { useMotion } from '@vueuse/motion'
4
- import { formatDate, tObject } from 'valaxy'
5
- import { computed, ref } from 'vue'
6
-
7
- import { useI18n } from 'vue-i18n'
4
+ import { formatDate, useValaxyI18n } from 'valaxy'
5
+ import { ref } from 'vue'
8
6
 
9
7
  const props = defineProps<{
10
8
  i: number
@@ -29,10 +27,7 @@ useMotion(itemRef, {
29
27
  },
30
28
  })
31
29
 
32
- const { locale } = useI18n()
33
- const postTitle = computed(() => {
34
- return tObject(props.post.title || '', locale.value)
35
- })
30
+ const { $tO } = useValaxyI18n()
36
31
  </script>
37
32
 
38
33
  <template>
@@ -55,7 +50,7 @@ const postTitle = computed(() => {
55
50
  </div>
56
51
  <h2 class="post-title w-full" inline-flex items-center font="serif black">
57
52
  <RouterLink :to="post.path || ''" class="post-title-link">
58
- {{ postTitle }}
53
+ {{ $tO(post.title) }}
59
54
  </RouterLink>
60
55
  </h2>
61
56
  </header>
@@ -1,7 +1,9 @@
1
1
  <script lang="ts" setup>
2
+ import { useValaxyI18n } from 'valaxy'
2
3
  import { useThemeConfig } from '../composables'
3
4
 
4
5
  const themeConfig = useThemeConfig()
6
+ const { $t } = useValaxyI18n()
5
7
  </script>
6
8
 
7
9
  <template>
@@ -9,7 +11,8 @@ const themeConfig = useThemeConfig()
9
11
  <AppLink
10
12
  v-for="item, i in themeConfig.pages" :key="i"
11
13
  class="link-item yun-icon-btn" inline-flex
12
- :to="item.url" :title="item.name"
14
+ :to="item.url"
15
+ :title="$t(item.name)"
13
16
  :style="`color:${item.color}`"
14
17
  >
15
18
  <div :class="item.icon" class="icon size-6" />
@@ -1,10 +1,10 @@
1
1
  <script setup lang="ts">
2
- import { tObject, useFrontmatter, useSiteConfig, useValaxyI18n } from 'valaxy'
2
+ import { useFrontmatter, useSiteConfig, useValaxyI18n } from 'valaxy'
3
3
  import { computed, ref, watch } from 'vue'
4
4
  import { useRoute, useRouter } from 'vue-router'
5
5
  import { useYunAppStore } from '../../stores'
6
6
 
7
- const { $t, locale } = useValaxyI18n()
7
+ const { $t, $tO } = useValaxyI18n()
8
8
 
9
9
  const yunApp = useYunAppStore()
10
10
  const fm = useFrontmatter()
@@ -63,10 +63,10 @@ function goToLink() {
63
63
  class="size-4"
64
64
  :class="fm.icon || 'i-ri-article-line'"
65
65
  />
66
- <span class="truncate"> {{ tObject(fm.title || '', locale) }}</span>
66
+ <span class="truncate"> {{ $tO(fm.title || '') }}</span>
67
67
  </div>
68
68
  <span v-if="fm.subtitle" class="font-light op-80">
69
- {{ tObject(fm.subtitle || '', locale) }}
69
+ {{ $tO(fm.subtitle || '') }}
70
70
  </span>
71
71
  </div>
72
72
  <span v-if="showSiteTitle" class="font-light truncate">
@@ -1,8 +1,11 @@
1
1
  <script setup lang="ts">
2
2
  import { ref } from 'vue'
3
+ import { useI18n } from 'vue-i18n'
4
+
3
5
  import { useThemeConfig } from '../../composables'
4
6
 
5
7
  const themeConfig = useThemeConfig()
8
+ const { t } = useI18n()
6
9
 
7
10
  const showContent = ref(false)
8
11
  </script>
@@ -79,7 +82,7 @@ const showContent = ref(false)
79
82
  >
80
83
  <YunSiteLinkItem
81
84
  :page="{
82
- name: '博客文章',
85
+ name: t('menu.posts'),
83
86
  icon: 'i-ri-article-line',
84
87
  url: '/posts/',
85
88
  }"
@@ -1,11 +1,14 @@
1
1
  <script setup lang="ts">
2
2
  import type { PageProps } from '../../types'
3
+ import { useValaxyI18n } from 'valaxy'
3
4
  import { useYunAppStore } from '../../stores'
4
5
 
5
6
  defineProps<{
6
7
  page: PageProps
7
8
  }>()
8
9
 
10
+ const { $t } = useValaxyI18n()
11
+
9
12
  const yunApp = useYunAppStore()
10
13
  </script>
11
14
 
@@ -14,14 +17,15 @@ const yunApp = useYunAppStore()
14
17
  class="link-item inline-flex-center gap-2 transition rounded-lg text-xl p-2 md:(text-lg p-2) lg:(text-xl p-3) text-$va-c-text"
15
18
  bg="white/5 dark:black/5"
16
19
  inline-flex
17
- :to="page.url" :title="page.name"
20
+ :to="page.url"
21
+ :title="$t(page.name)"
18
22
  :style="`color:${page.color}`"
19
23
  hover="bg-white/80 dark:bg-black/80"
20
24
  @click="yunApp.fullscreenMenu.isOpen = false"
21
25
  >
22
26
  <div :class="page.icon" class="icon" />
23
27
  <span>
24
- {{ page.name }}
28
+ {{ $t(page.name) }}
25
29
  </span>
26
30
  </AppLink>
27
31
  </template>
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts">
2
- import { useSiteConfig } from 'valaxy'
2
+ import { useSiteConfig, useValaxyI18n } from 'valaxy'
3
3
 
4
+ const { $t } = useValaxyI18n()
4
5
  const siteConfig = useSiteConfig()
5
6
  </script>
6
7
 
@@ -9,6 +10,6 @@ const siteConfig = useSiteConfig()
9
10
  v-if="siteConfig.subtitle"
10
11
  class="site-subtitle block text-$va-c-text op-80 font-medium" text="sm"
11
12
  >
12
- {{ siteConfig.subtitle }}
13
+ {{ $t(siteConfig.subtitle) }}
13
14
  </h4>
14
15
  </template>
@@ -1,10 +1,14 @@
1
1
  <script setup lang="ts">
2
- import { useAppStore, useSiteConfig } from 'valaxy'
2
+ import { useAppStore, useSiteConfig, useValaxyI18n } from 'valaxy'
3
3
  import { onMounted, ref, watch } from 'vue'
4
+ import { useI18n } from 'vue-i18n'
4
5
  import { useRoute } from 'vue-router'
5
6
  import { useThemeConfig } from '../../../composables'
6
7
  import { useYunAppStore } from '../../../stores'
7
8
 
9
+ const { t } = useI18n()
10
+ const { $t } = useValaxyI18n()
11
+
8
12
  // const app = useAppStore()
9
13
  const yunApp = useYunAppStore()
10
14
  const siteConfig = useSiteConfig()
@@ -60,7 +64,7 @@ const app = useAppStore()
60
64
  <template v-if="yunApp.size.isLg">
61
65
  <YunNavMenuItem
62
66
  icon="i-ri-article-line" to="/posts/"
63
- title="博客文章"
67
+ :title="t('menu.posts')"
64
68
  />
65
69
 
66
70
  <YunNavMenuItem
@@ -68,7 +72,7 @@ const app = useAppStore()
68
72
  :key="i"
69
73
  :icon="item.icon"
70
74
  :to="item.link"
71
- :title="item.text"
75
+ :title="$t(item.text)"
72
76
  />
73
77
  </template>
74
78
  </div>
@@ -1,11 +1,19 @@
1
1
  import type { YunTheme } from '../types'
2
- import { random } from 'valaxy'
2
+ import { random, useValaxyI18n } from 'valaxy'
3
3
  import { computed } from 'vue'
4
4
 
5
5
  export function useYunBanner(options: YunTheme.Banner) {
6
+ const { $tO } = useValaxyI18n()
7
+
8
+ const bannerTitle = computed(() => {
9
+ if (Array.isArray(options.title)) {
10
+ return options.title
11
+ }
12
+ return $tO<string | string[]>(options.title)
13
+ })
6
14
  const chars = computed(() => {
7
15
  const arr = []
8
- for (let i = 0; i < options.title.length; i++) {
16
+ for (let i = 0; i < bannerTitle.value.length; i++) {
9
17
  const rn = random(1.5, 3.5)
10
18
  arr.push(rn)
11
19
  }
@@ -15,6 +23,7 @@ export function useYunBanner(options: YunTheme.Banner) {
15
23
  const totalCharHeight = computed(() => chars.value.reduce((a, b) => a + b, 0))
16
24
 
17
25
  return {
26
+ bannerTitle,
18
27
  chars,
19
28
  totalCharHeight,
20
29
  }
package/layouts/post.vue CHANGED
@@ -2,18 +2,16 @@
2
2
  import { defineArticle, useSchemaOrg } from '@unhead/schema-org/vue'
3
3
 
4
4
  import dayjs from 'dayjs'
5
- import { tObject, useFrontmatter, useSiteConfig, useValaxyI18n } from 'valaxy'
6
- import { useI18n } from 'vue-i18n'
5
+ import { useFrontmatter, useSiteConfig, useValaxyI18n } from 'valaxy'
7
6
 
8
7
  const siteConfig = useSiteConfig()
9
8
  const frontmatter = useFrontmatter()
10
9
 
11
- const { locale } = useI18n()
12
- const { $t } = useValaxyI18n()
10
+ const { $t, $tO } = useValaxyI18n()
13
11
  const article: Parameters<typeof defineArticle>[0] = {
14
12
  '@type': 'BlogPosting',
15
- 'headline': tObject(frontmatter.value.title || '', locale.value),
16
- 'description': tObject(frontmatter.value.description || '', locale.value),
13
+ 'headline': $tO(frontmatter.value.title),
14
+ 'description': $tO(frontmatter.value.description),
17
15
  'author': [
18
16
  {
19
17
  name: $t(siteConfig.value.author.name),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valaxy-theme-yun",
3
3
  "type": "module",
4
- "version": "0.25.0",
4
+ "version": "0.25.2",
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.25.0",
35
+ "valaxy": "0.25.2",
36
36
  "valaxy-addon-waline": "0.2.1"
37
37
  },
38
38
  "scripts": {
package/styles/main.scss CHANGED
@@ -8,9 +8,10 @@ $c-primary: #0078e7 !default;
8
8
  );
9
9
 
10
10
  // override the default style of star-markdown-css
11
+ @use "./animations/index.scss" as *;
11
12
  @use "./common/button.scss" as *;
12
13
  @use "./common/markdown.scss" as *;
14
+ // valaxy client styles
13
15
  @use 'valaxy/client/styles/components/code.scss' as *;
14
16
  @use 'valaxy/client/styles/components/code-group.scss' as *;
15
17
  @use 'valaxy/client/styles/components/custom-block.scss' as *;
16
- @use "./animations/index.scss" as *;
package/types/index.d.ts CHANGED
@@ -12,8 +12,11 @@ export namespace YunTheme {
12
12
  /**
13
13
  * @en Banner title
14
14
  * @zh 标题,默认每个字分割,你也可以通过数组的方式来自定义分割,如 ['Hello', 'World']
15
+ *
16
+ * i18n: { 'en': 'Title', 'zh-CN': '标题' }
17
+ * { en: ['Hello', 'World'], 'zh-CN': ['你好', '世界'] }
15
18
  */
16
- title: string | string[]
19
+ title: string | string[] | Record<string, string | string[]>
17
20
 
18
21
  /**
19
22
  * 首页下方的动态云