mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
fix(i18n): make i18n.routing
fields optional (#10165)
* fix(i18n): make `i18n.routing` fields optional * update user config * Update packages/astro/src/core/config/schema.ts Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> --------- Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
This commit is contained in:
parent
9b78c99275
commit
d50dddb71d
2 changed files with 48 additions and 43 deletions
5
.changeset/large-planets-kick.md
Normal file
5
.changeset/large-planets-kick.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"astro": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes an issue where the `i18n.routing` object had all its fields defined as mandatory. Now they all are optionals and shouldn't break when using `astro.config.mts`.
|
|
@ -1492,7 +1492,7 @@ export interface AstroUserConfig {
|
||||||
* URLs will be of the form `example.com/[locale]/content/` for every route, including the default language.
|
* URLs will be of the form `example.com/[locale]/content/` for every route, including the default language.
|
||||||
* Localized folders are used for every language, including the default.
|
* Localized folders are used for every language, including the default.
|
||||||
*/
|
*/
|
||||||
prefixDefaultLocale: boolean;
|
prefixDefaultLocale?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @docs
|
* @docs
|
||||||
|
@ -1521,7 +1521,7 @@ export interface AstroUserConfig {
|
||||||
* })
|
* })
|
||||||
*```
|
*```
|
||||||
* */
|
* */
|
||||||
redirectToDefaultLocale: boolean;
|
redirectToDefaultLocale?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name i18n.routing.strategy
|
* @name i18n.routing.strategy
|
||||||
|
@ -1532,48 +1532,48 @@ export interface AstroUserConfig {
|
||||||
*
|
*
|
||||||
* - `"pathname": The strategy is applied to the pathname of the URLs
|
* - `"pathname": The strategy is applied to the pathname of the URLs
|
||||||
*/
|
*/
|
||||||
strategy: 'pathname';
|
strategy?: 'pathname';
|
||||||
|
|
||||||
/**
|
|
||||||
* @name i18n.domains
|
|
||||||
* @type {Record<string, string> }
|
|
||||||
* @default '{}'
|
|
||||||
* @version 4.3.0
|
|
||||||
* @description
|
|
||||||
*
|
|
||||||
* Configures the URL pattern of one or more supported languages to use a custom domain (or sub-domain).
|
|
||||||
*
|
|
||||||
* When a locale is mapped to a domain, a `/[locale]/` path prefix will not be used.
|
|
||||||
* However, localized folders within `src/pages/` are still required, including for your configured `defaultLocale`.
|
|
||||||
*
|
|
||||||
* Any other locale not configured will default to a localized path-based URL according to your `prefixDefaultLocale` strategy (e.g. `https://example.com/[locale]/blog`).
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* //astro.config.mjs
|
|
||||||
* export default defineConfig({
|
|
||||||
* site: "https://example.com",
|
|
||||||
* output: "server", // required, with no prerendered pages
|
|
||||||
* adapter: node({
|
|
||||||
* mode: 'standalone',
|
|
||||||
* }),
|
|
||||||
* i18n: {
|
|
||||||
* defaultLocale: "en",
|
|
||||||
* locales: ["en", "fr", "pt-br", "es"],
|
|
||||||
* prefixDefaultLocale: false,
|
|
||||||
* domains: {
|
|
||||||
* fr: "https://fr.example.com",
|
|
||||||
* es: "https://example.es"
|
|
||||||
* }
|
|
||||||
* },
|
|
||||||
* })
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Both page routes built and URLs returned by the `astro:i18n` helper functions [`getAbsoluteLocaleUrl()`](https://docs.astro.build/en/guides/internationalization/#getabsolutelocaleurl) and [`getAbsoluteLocaleUrlList()`](https://docs.astro.build/en/guides/internationalization/#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.
|
|
||||||
*/
|
|
||||||
domains?: Record<string, string>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name i18n.domains
|
||||||
|
* @type {Record<string, string> }
|
||||||
|
* @default '{}'
|
||||||
|
* @version 4.3.0
|
||||||
|
* @description
|
||||||
|
*
|
||||||
|
* Configures the URL pattern of one or more supported languages to use a custom domain (or sub-domain).
|
||||||
|
*
|
||||||
|
* When a locale is mapped to a domain, a `/[locale]/` path prefix will not be used.
|
||||||
|
* However, localized folders within `src/pages/` are still required, including for your configured `defaultLocale`.
|
||||||
|
*
|
||||||
|
* Any other locale not configured will default to a localized path-based URL according to your `prefixDefaultLocale` strategy (e.g. `https://example.com/[locale]/blog`).
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* //astro.config.mjs
|
||||||
|
* export default defineConfig({
|
||||||
|
* site: "https://example.com",
|
||||||
|
* output: "server", // required, with no prerendered pages
|
||||||
|
* adapter: node({
|
||||||
|
* mode: 'standalone',
|
||||||
|
* }),
|
||||||
|
* i18n: {
|
||||||
|
* defaultLocale: "en",
|
||||||
|
* locales: ["en", "fr", "pt-br", "es"],
|
||||||
|
* prefixDefaultLocale: false,
|
||||||
|
* domains: {
|
||||||
|
* fr: "https://fr.example.com",
|
||||||
|
* es: "https://example.es"
|
||||||
|
* }
|
||||||
|
* },
|
||||||
|
* })
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Both page routes built and URLs returned by the `astro:i18n` helper functions [`getAbsoluteLocaleUrl()`](https://docs.astro.build/en/guides/internationalization/#getabsolutelocaleurl) and [`getAbsoluteLocaleUrlList()`](https://docs.astro.build/en/guides/internationalization/#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.
|
||||||
|
*/
|
||||||
|
domains?: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** ⚠️ WARNING: SUBJECT TO CHANGE */
|
/** ⚠️ WARNING: SUBJECT TO CHANGE */
|
||||||
|
|
Loading…
Reference in a new issue