🚀 refactor: unify page routing files

This commit is contained in:
radishzzz 2025-03-14 23:13:54 +00:00
parent d352b6fb65
commit 54902da6dd
19 changed files with 522 additions and 348 deletions

View file

@ -1,5 +1,6 @@
---
import PostTime from '@/components/PostTime.astro'
import { defaultLocale } from '@/i18n/config'
interface Post {
data: {
@ -27,8 +28,8 @@ export interface Props {
function getPostPath(post: Post) {
// If abbrlink is set, it will be used instead of slug
const postPath = post.data.abbrlink || post.slug
// Add language prefix to URL if current page is in a language subdirectory
return lang ? `/${lang}/posts/${postPath}/` : `/posts/${postPath}/`
// 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}/`
}
---
<ul>