valaxy-theme-press 0.23.5 → 0.24.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,10 +1,9 @@
1
1
  <script setup lang="ts">
2
- import { useFrontmatter, useSiteStore } from 'valaxy'
2
+ import { tObject, useFrontmatter, useSiteStore } from 'valaxy'
3
3
  import { computed } from 'vue'
4
4
 
5
5
  import { useI18n } from 'vue-i18n'
6
6
  import { useRoute } from 'vue-router'
7
- import { getLocaleTitle } from '../utils'
8
7
 
9
8
  const frontmatter = useFrontmatter()
10
9
 
@@ -19,7 +18,7 @@ const nextPost = computed(() => site.postList[findCurrentIndex() - 1])
19
18
  const prevPost = computed(() => site.postList[findCurrentIndex() + 1])
20
19
 
21
20
  const { locale } = useI18n()
22
- const localeTitle = computed(() => getLocaleTitle(locale.value, frontmatter.value))
21
+ const $title = computed(() => tObject(frontmatter.value.title || '', locale.value))
23
22
  </script>
24
23
 
25
24
  <template>
@@ -36,7 +35,7 @@ const localeTitle = computed(() => getLocaleTitle(locale.value, frontmatter.valu
36
35
  md:text-5xl md:leading-14
37
36
  "
38
37
  >
39
- {{ localeTitle }}
38
+ {{ $title }}
40
39
  </h1>
41
40
  </header>
42
41
 
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Category, Post } from 'valaxy'
3
- import { isCategoryList } from 'valaxy'
3
+ import { isCategoryList, tObject } from 'valaxy'
4
4
  import { ref } from 'vue'
5
5
  import { useI18n } from 'vue-i18n'
6
6
 
@@ -23,8 +23,7 @@ const { t, locale } = useI18n()
23
23
 
24
24
  function getTitle(post: Post | any) {
25
25
  const lang = locale.value
26
- const localeTitle = post[`title_${lang}`] || post[`title_${lang.split('-')[0]}`]
27
- return localeTitle || post.title
26
+ return tObject(post.title || '', lang)
28
27
  }
29
28
  </script>
30
29
 
@@ -1,11 +1,10 @@
1
1
  <script lang="ts" setup>
2
2
  import type { PageData, Post } from 'valaxy'
3
- import { onClickHref, onContentUpdated, scrollTo, useFrontmatter, useLayout, useSidebar, useSiteConfig } from 'valaxy'
3
+ import { onClickHref, onContentUpdated, scrollTo, tObject, useFrontmatter, useLayout, useSidebar, useSiteConfig } from 'valaxy'
4
4
  import { computed, nextTick } from 'vue'
5
5
  import { useI18n } from 'vue-i18n'
6
6
  import { useRoute, useRouter } from 'vue-router'
7
7
  import { targetPadding } from '../client'
8
- import { getLocaleTitle } from '../utils'
9
8
 
10
9
  defineProps<{
11
10
  frontmatter: Post
@@ -20,7 +19,7 @@ const isHome = useLayout('home')
20
19
  const layout = useLayout()
21
20
 
22
21
  const { locale } = useI18n()
23
- const localeTitle = computed(() => getLocaleTitle(locale.value, frontmatter.value))
22
+ const $title = computed(() => tObject(frontmatter.value.title || '', locale.value))
24
23
 
25
24
  const route = useRoute()
26
25
  const router = useRouter()
@@ -64,9 +63,9 @@ onContentUpdated(() => {
64
63
  <slot name="main-content-before" />
65
64
 
66
65
  <ValaxyMd class="mx-auto w-full max-w-4xl" :frontmatter="frontmatter">
67
- <h1 v-if="hasSidebar && !isHome && frontmatter.title" :id="frontmatter.title" tabindex="-1">
68
- {{ localeTitle }}
69
- <a class="header-anchor" :href="`#${frontmatter.title}`" aria-hidden="true" />
66
+ <h1 v-if="hasSidebar && !isHome && $title" :id="$title" tabindex="-1">
67
+ {{ $title }}
68
+ <a class="header-anchor" :href="`#${$title}`" aria-hidden="true" />
70
69
  </h1>
71
70
  <slot name="main-content-md" />
72
71
  <slot />
@@ -8,8 +8,7 @@ export function useEditLink() {
8
8
 
9
9
  return computed(() => {
10
10
  const { text, pattern } = themeConfig.value.editLink || {}
11
- const url = pattern.replace(/:path/g, page.value.relativePath)
12
-
11
+ const url = pattern.replace(/:path/g, page.value?.relativePath || '')
13
12
  return { url, text }
14
13
  })
15
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valaxy-theme-press",
3
- "version": "0.23.5",
3
+ "version": "0.24.0",
4
4
  "description": "Docs Theme for Valaxy",
5
5
  "author": {
6
6
  "email": "me@yunyoujun.cn",
@@ -26,6 +26,6 @@
26
26
  "@docsearch/js": "^3.9.0"
27
27
  },
28
28
  "devDependencies": {
29
- "valaxy": "0.23.5"
29
+ "valaxy": "0.24.0"
30
30
  }
31
31
  }
package/utils/index.ts CHANGED
@@ -1,8 +0,0 @@
1
- /**
2
- * get locale title
3
- * @param locale
4
- * @param frontmatter
5
- */
6
- export function getLocaleTitle(locale: string, frontmatter: any) {
7
- return frontmatter[`title${locale === 'en' ? '' : `_${locale}`}`] || frontmatter.title
8
- }