Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locale issues: need different title href URL and home page hero link #195

Closed
ShenQingchuan opened this issue Jan 3, 2021 · 2 comments · Fixed by #233
Closed

locale issues: need different title href URL and home page hero link #195

ShenQingchuan opened this issue Jan 3, 2021 · 2 comments · Fixed by #233
Assignees
Labels
bug Something isn't working

Comments

@ShenQingchuan
Copy link
Contributor

ShenQingchuan commented Jan 3, 2021

Problem 1

Describe the bug
I need '/' as the title href for English version, and '/zh/' for Chinese version.
But I didn't found any useful suggestions in the documentation.

To Reproduce
switch to the '/zh/xxx' page, but the title href is still targeting to '/':
image

Expected behavior
'/zh/xxx' pages' titie href is suppposed to be '/zh/' ( which defines as the key of themeConfigs.locales)

System Info

  • vitepress version: v0.10.5
  • vite version: v2.0.0-beta2
  • Node version: v12.16.2
  • OS version: 64bit Mac OS X 10.15.6 19G2021

Problem 2

When I toggle the language, the actionText in docs/index.md and docs/zh/index.md doesn't work well as expected:

Reproduce in my fork for vitejs-docs Chinese translation repo

屏幕录制2021-01-04 13

@ShenQingchuan
Copy link
Contributor Author

ShenQingchuan commented Jan 15, 2021

seems like the reactivity was lost when deconstructed props....

@ShenQingchuan ShenQingchuan changed the title locales support different title href URL locales support different title href URL and home page hero link Jan 21, 2021
@ShenQingchuan ShenQingchuan changed the title locales support different title href URL and home page hero link locales issues different title href URL and home page hero link Jan 21, 2021
@ShenQingchuan ShenQingchuan changed the title locales issues different title href URL and home page hero link locale issues: need different title href URL and home page hero link Jan 21, 2021
@ShenQingchuan
Copy link
Contributor Author

对问题 2 的解决方案 👆

@yyx990803 审阅

导致错误的原因:

  1. defineProps() 结构出来的变量 丢失了响应性
  2. useNavLink 方法中 props 计算属性的闭包函数缓存了该 item
  3. 再从
    const { props: linkProps, isExternal } = useNavLink(item)
    解构出去时,props 内的所有属性都将永远不变

解决方案:

将传入 useNavLink() 的参数更改为 Ref,保证其响应性

image

实现效果:

result.mov

@kiaking kiaking added bug Something isn't working and removed bug: pending triage Maybe a bug, waiting for confirmation labels Feb 10, 2021
kiaking pushed a commit that referenced this issue Feb 11, 2021
@kiaking kiaking self-assigned this Feb 11, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants