refactor: update language configuration

This commit is contained in:
radishzzz 2025-03-15 01:02:45 +00:00
parent ff59dc1a7c
commit 22dc899a95
25 changed files with 53 additions and 188 deletions

View file

@ -1,6 +1,6 @@
---
import PostTime from '@/components/PostTime.astro'
import { defaultLocale } from '@/i18n/config'
import { defaultLocale } from '@/config'
interface Post {
data: {
@ -16,7 +16,6 @@ interface Post {
}
}
// Get post list and page language parameter from props
const { posts, lang } = Astro.props
export interface Props {
@ -24,9 +23,8 @@ export interface Props {
lang?: string
}
// Get multilingual post URL path
function getPostPath(post: Post) {
// If abbrlink is set, it will be used instead of slug
// Prioritize abbrlink over slug
const postPath = post.data.abbrlink || post.slug
// Add language prefix to URL if current page is in a language subdirectory and not the default language
return lang && lang !== defaultLocale ? `/${lang}/posts/${postPath}/` : `/posts/${postPath}/`