feat(theme): add queryString option to localeDropdown (#8915)

Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
This commit is contained in:
Will Ceolin 2023-04-21 07:35:02 -03:00 committed by GitHub
parent 4a4a8be062
commit 10f161d578
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 1 deletions

View file

@ -616,6 +616,7 @@ Accepted fields:
| `position` | <code>'left' \| 'right'</code> | `'left'` | The side of the navbar this item should appear on. |
| `dropdownItemsBefore` | <code>[LinkLikeItem](#navbar-dropdown)[]</code> | `[]` | Add additional dropdown items at the beginning of the dropdown. |
| `dropdownItemsAfter` | <code>[LinkLikeItem](#navbar-dropdown)[]</code> | `[]` | Add additional dropdown items at the end of the dropdown. |
| `queryString` | `string` | `undefined` | The query string to be appended to the URL. |
```mdx-code-block
</APITable>

View file

@ -68,6 +68,14 @@ module.exports = {
};
```
:::tip
You can pass a query parameter that will be appended to the URL when a user changes the locale using the dropdown (e.g. `queryString: '?persistLocale=true'`).
This is useful for implementing an automatic locale detection on your server. For example, you can use this parameter to store the user's preferred locale in a cookie.
:::
### Start your site {#start-your-site}
Start your localized site in dev mode, using the locale of your choice: