fix: map language code in updateDetailPage
All checks were successful
Deploy / Deploy (push) Successful in 1m14s
All checks were successful
Deploy / Deploy (push) Successful in 1m14s
This commit is contained in:
parent
48b65d804a
commit
f50e3447c6
1 changed files with 14 additions and 1 deletions
|
@ -44,7 +44,7 @@ const UpdateDetailPage: React.FC = () => {
|
|||
|
||||
try {
|
||||
// 尝试加载 Markdown 文件
|
||||
const mdPath = `/data/${i18n.language}/updates/${year}/${foundUpdate.id}.md`;
|
||||
const mdPath = `/data/${getMarkdownLanguage(i18n.language)}/updates/${year}/${foundUpdate.id}.md`;
|
||||
const response = await fetch(mdPath);
|
||||
|
||||
// 检查响应状态和内容类型
|
||||
|
@ -75,6 +75,19 @@ const UpdateDetailPage: React.FC = () => {
|
|||
fetchUpdateData();
|
||||
}, [id, i18n.language, allUpdates]);
|
||||
|
||||
// Map i18n language codes to markdown file path language codes
|
||||
const getMarkdownLanguage = (language: string): string => {
|
||||
const languageMap: Record<string, string> = {
|
||||
'en-US': 'en',
|
||||
'zh-CN': 'zh-Hans',
|
||||
'zh-TW': 'zh-Hant',
|
||||
'en': 'en',
|
||||
'zh-Hans': 'zh-Hans',
|
||||
'zh-Hant': 'zh-Hant'
|
||||
};
|
||||
return languageMap[language] || 'en'; // Default to 'en' if mapping not found
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue