docs: fix press category locale

This commit is contained in:
YunYouJun 2024-02-14 19:54:08 +08:00
parent f3afb0cc1a
commit 8d956c1377
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
---
title: Participate in Development
title_zh: 参与开发
title_zh-CN: 参与开发
categories:
- dev
end: false

View File

@ -22,9 +22,9 @@ const collapsable = ref(props.collapsable)
const { t, locale } = useI18n()
function getTitle(post: Post | any) {
let lang = locale.value
lang = lang === 'zh-CN' ? 'zh' : lang
return post[`title_${lang}`] ? post[`title_${lang}`] : post.title
const lang = locale.value
const localeTitle = post[`title_${lang}`] || post[`title_${lang.split('-')[0]}`]
return localeTitle || post.title
}
</script>