Description
Describe the bug
If you are navigating https://example.com/en/foo/bar
and have another language es
configured, the language selector would link to https://example.com/es/foo/bar
.
This is fine as long as /es/foo/bar
exists. But this does not need to be always the case. Even with complete translations, there are some pages that are localized and only make sense in certain languages.
For those cases, the language selector should link to the first parent directory that exists (i.e.: /es/foo/
or /es/
).
Reproduction
Create a project with internationalization and have one page available in one language (/en/
), but not available in another language (/es/
). Visit the English version and, from the drop-down language selector, the /es/
page would be linked for the Spanish version of the site, even if that page does not exist.
Expected behavior
The language selector should not link to pages that do not exist. For those cases, it could use the first existing parent or just link to the top-level language URL (i.e: /es/
).
System Info
System:
OS: Linux 6.11 Fedora Linux 39 (Container Image)
CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
Memory: 8.19 GB / 15.54 GB
Container: Yes
Shell: 5.2.15 - /bin/bash
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
npmPackages:
vitepress: ^1.5.0 => 1.5.0
### Additional context
_No response_
### Validations
- [X] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).
- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)
- [X] Read the [docs](https://vitepress.dev).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.