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

docs: fix config types (images, i18n) #13374

Merged
merged 6 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/rude-maps-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes the documentation of the i18n configuration where `manual` was presented as a key of `routing` instead of an available value.
74 changes: 33 additions & 41 deletions packages/astro/src/types/public/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
* @docs
* @name image.domains
* @type {string[]}
* @default `{domains: []}`
* @default `[]`
* @version 2.10.10
* @description
* Defines a list of permitted image source domains for remote image optimization. No other remote images will be optimized by Astro.
Expand All @@ -1145,7 +1145,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
* @docs
* @name image.remotePatterns
* @type {RemotePattern[]}
* @default `{remotePatterns: []}`
* @default `[]`
* @version 2.10.10
* @description
* Defines a list of permitted image source URL patterns for remote image optimization.
Expand Down Expand Up @@ -1400,7 +1400,6 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
* @name i18n
* @type {object}
* @version 3.5.0
* @type {object}
* @description
*
* Configures i18n routing and allows you to specify some customization options.
Expand Down Expand Up @@ -1476,12 +1475,39 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
/**
* @docs
* @name i18n.routing
* @type {Routing}
* @type {object | "manual"}
* @default `object`
* @version 3.7.0
* @description
*
* Controls the routing strategy to determine your site URLs. Set this based on your folder/URL path configuration for your default language.
*
* ```js
* export default defineConfig({
* i18n: {
* defaultLocale: "en",
* locales: ["en", "fr"],
* routing: {
* prefixDefaultLocale: false,
* redirectToDefaultLocale: true,
* fallbackType: "redirect",
* }
* }
* })
* ```
*
* Since 4.6.0, this option can also be set to `manual`. When this routing strategy is enabled, Astro will **disable** its i18n middleware and no other `routing` options (e.g. `prefixDefaultLocale`) may be configured. You will be responsible for writing your own routing logic, or executing Astro's i18n middleware manually alongside your own.
*
* ```js
* export default defineConfig({
* i18n: {
* defaultLocale: "en",
* locales: ["en", "fr"],
* routing: "manual"
* }
* })
* ```
*
*/
routing?:
| {
Expand Down Expand Up @@ -1581,48 +1607,14 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
* ```
*/
fallbackType?: 'redirect' | 'rewrite';

/**
* @name i18n.routing.strategy
* @type {"pathname"}
* @default `"pathname"`
* @version 3.7.0
* @description
*
* - `"pathname": The strategy is applied to the pathname of the URLs
*/
strategy?: 'pathname';
}
/**
*
* @docs
* @name i18n.routing.manual
* @kind h4
* @type {string}
* @version 4.6.0
* @description
* When this option is enabled, Astro will **disable** its i18n middleware so that you can implement your own custom logic. No other `routing` options (e.g. `prefixDefaultLocale`) may be configured with `routing: "manual"`.
*
* You will be responsible for writing your own routing logic, or executing Astro's i18n middleware manually alongside your own.
*
* ```js
* export default defineConfig({
* i18n: {
* defaultLocale: "en",
* locales: ["en", "fr", "pt-br", "es"],
* routing: {
* prefixDefaultLocale: true,
* }
* }
* })
* ```
*/
| 'manual';

/**
* @docs
* @name i18n.domains
* @type {Record<string, string> }
* @default '{}'
* @default `{}`
* @version 4.3.0
* @description
*
Expand Down Expand Up @@ -1653,7 +1645,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
* })
* ```
*
* Both page routes built and URLs returned by the `astro:i18n` helper functions [`getAbsoluteLocaleUrl()`](https://docs.astro.build/en/reference/api-reference/#getabsolutelocaleurl) and [`getAbsoluteLocaleUrlList()`](https://docs.astro.build/en/reference/api-reference/#getabsolutelocaleurllist) will use the options set in `i18n.domains`.
* Both page routes built and URLs returned by the `astro:i18n` helper functions [`getAbsoluteLocaleUrl()`](https://docs.astro.build/en/reference/modules/astro-i18n/#getabsolutelocaleurl) and [`getAbsoluteLocaleUrlList()`](https://docs.astro.build/en/reference/modules/astro-i18n/#getabsolutelocaleurllist) will use the options set in `i18n.domains`.
*
* See the [Internationalization Guide](https://docs.astro.build/en/guides/internationalization/#domains) for more details, including the limitations of this feature.
*/
Expand Down