Skip to content
Open
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
360e44d
feat: 在Header组件中添加语言下拉菜单,包含中文文档链接
eveningwater Aug 14, 2025
507d40b
feat: delete the icon
eveningwater Aug 14, 2025
6ab774a
feat: add some margin to the right of the selector
eveningwater Aug 14, 2025
ba2e6ef
feat: 更新English链接指向官方文档网站
eveningwater Aug 14, 2025
85eb80f
feat: update Chinese documentation link to official domain
eveningwater Aug 14, 2025
186cb80
fix: correct Chinese documentation URL format and update mobile navig…
eveningwater Aug 14, 2025
71f53fe
refactor: simplify Header component by removing multilingual support …
eveningwater Aug 14, 2025
25b0f48
feat: restore language selector with Chinese docs and English docs link
eveningwater Aug 14, 2025
128eb2a
Update website/components/layouts/Header/Header.tsx
eveningwater Aug 14, 2025
81cff59
Update website/components/layouts/Header/Header.tsx
eveningwater Aug 14, 2025
af046e4
Update website/components/layouts/Header/Header.tsx
eveningwater Aug 14, 2025
8ed8fc2
更新 Header 组件
eveningwater Aug 15, 2025
c282d81
修复Header组件中SVG属性的React/JSX兼容性问题,将连字符属性改为驼峰命名法
eveningwater Aug 15, 2025
d137a79
格式化Header组件中的SVG代码,改善可读性
eveningwater Aug 15, 2025
4418093
更新Header组件中中文文档链接的显示文本,添加by community标识
eveningwater Aug 15, 2025
47ed141
Merge branch 'main' into feature-branch
eveningwater Aug 21, 2025
25c6669
added some update suggestions
overthemike Aug 23, 2025
2be5ccf
Merge pull request #1 from overthemike/feature-branch
eveningwater Sep 1, 2025
8bf998d
Merge branch 'pmndrs:main' into feature-branch
eveningwater Sep 1, 2025
51cf417
fix: 修复 Prettier 格式检查问题
Sep 4, 2025
b756890
Merge branch 'main' into feature-branch
dai-shi Sep 5, 2025
1d4a9b3
Merge branch 'main' into feature-branch
eveningwater Sep 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions website/components/layouts/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,79 @@ import clsx from 'clsx'
import SEO from '~/components/SEO'
import ToggleTheme from '~/components/ToggleTheme'

// 语言选择器组件
function LanguageSelector() {
const [isOpen, setIsOpen] = useState(false)

useEffect(() => {
function handleClickOutside(event: MouseEvent) {
const target = event.target as Element
if (isOpen && !target.closest('.language-selector')) {
setIsOpen(false)
}
}

if (isOpen) {
document.addEventListener('mousedown', handleClickOutside)
}

return () => {
document.removeEventListener('mousedown', handleClickOutside)
}
}, [isOpen])

return (
<div className="relative language-selector mr-6">
<button
type="button"
className="flex items-center text-gray-700 dark:text-gray-200 hover:text-sky-500 dark:hover:text-sky-400 transition-colors"
onClick={() => setIsOpen(!isOpen)}
>
<span className="mr-1">🌐</span>
<span>Language</span>
<svg
className={clsx(
'ml-1 h-4 w-4 transition-transform',
isOpen ? 'rotate-180' : ''
)}
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M19 9l-7 7-7-7"
/>
</svg>
</button>

{isOpen && (
<div className="absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-md shadow-lg py-1 z-50 border border-gray-200 dark:border-gray-700">
<a
href="https://valtio-xnj9.vercel.app/zh"
Copy link
Collaborator

@overthemike overthemike Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change the href to be "https://zh/valtio.dev" and I'll create a zh subdomain on valtio.dev to point to this domain.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eveningwater I've already created the CNAME record to point here (just need to wait for propegation), but you'll want to change the root of your app to server chinese instead of english.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

** overthemike**

Can you help me check if my latest modification meets the requirements?thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eveningwater Almost. Line 158 still needs updating to http://zh.valtio.dev I think.

On your end, you can replace all of the regular .mdx files with the .zh.mdx files and then make sure the default language there will be selected to be chinese.

Let's check back in a little while to make sure the subdomain is redirecting properly to your app while you're changing your default language on your end.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eveningwater Almost. Line 158 still needs updating to http://zh.valtio.dev I think.

On your end, you can replace all of the regular .mdx files with the .zh.mdx files and then make sure the default language there will be selected to be chinese.

Let's check back in a little while to make sure the subdomain is redirecting properly to your app while you're changing your default language on your end.

Does my repo not need to display English documents? Can I just keep the Chinese documents?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eveningwater That is correct. No need to store the English docs as we store them here. Your github repos as well as your website call be all chinese docs and you can just link back for english.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eveningwater That is correct. No need to store the English docs as we store them here. Your github repos as well as your website call be all chinese docs and you can just link back for english.

Got it, thanks, I'll adjust it.

target="_blank"
rel="noopener noreferrer"
className="block px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-sky-500 dark:hover:text-sky-400 transition-colors"
onClick={() => setIsOpen(false)}
>
中文文档
</a>
<Link href="/">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change this to <Link href='https://valtio.dev'> This way it will link back to the main site and stay up to date.

<a
className="block px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-sky-500 dark:hover:text-sky-400 transition-colors"
onClick={() => setIsOpen(false)}
>
English
</a>
</Link>
</div>
)}
</div>
)
}

export function NavPopover({
display = 'md:hidden',
className = '',
Expand Down Expand Up @@ -80,6 +153,16 @@ export function NavPopover({
GitHub
</a>
</li>
<li>
<a
href="https://valtio-xnj9.vercel.app/zh"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link will need to change to something like http://zh.valtio.dev or http://valtiio.dev/zh and then we'll need to configure the dns. Let's not change this yet until we get that sorted first though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess an alternative would be to make sure that the english link links back to the valtio.dev domain. RIght now, clicking on the new language will just redirect to the new domain and won't redirect back on change again. I think maybe the better solution here would be to make these absolute links to a new site instead of state change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link will need to change to something like http://zh.valtio.dev or http://valtiio.dev/zh and then we'll need to configure the dns. Let's not change this yet until we get that sorted first though.

@overthemike
My opinion is no. We don't "host" non-English site, and it's not our responsibility. So, I prefer an external URL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RIght now, clicking on the new language will just redirect to the new domain

I think it should open a new window.

target="_blank"
rel="noopener noreferrer"
className="hover:text-sky-500 dark:hover:text-sky-400"
>
中文文档
</a>
</li>
</ul>
<div className="mt-6 pt-6 border-t border-gray-200 dark:border-gray-200/10">
<ToggleTheme />
Expand Down Expand Up @@ -175,6 +258,7 @@ export default function Header({
</ul>
</nav>
<div className="flex items-center border-l border-gray-200 ml-6 pl-6 dark:border-gray-800">
<LanguageSelector />
<ToggleTheme />
<a
href="https://github.com/pmndrs/valtio"
Expand Down