mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 19:51:07 +02:00
refactor: update language configuration
This commit is contained in:
parent
ff59dc1a7c
commit
22dc899a95
25 changed files with 53 additions and 188 deletions
|
@ -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}/`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue