From f34f9cbbffcddcdcf43662717600df27de4f19b4 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 9 Oct 2023 11:10:08 +0100 Subject: [PATCH] docs: better explanation for configuration --- .changeset/thin-flies-notice.md | 5 +++++ packages/astro/src/@types/astro.ts | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .changeset/thin-flies-notice.md diff --git a/.changeset/thin-flies-notice.md b/.changeset/thin-flies-notice.md new file mode 100644 index 000000000..596e945b6 --- /dev/null +++ b/.changeset/thin-flies-notice.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Enrich the explanation of the `base` configuration with examples. diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 2217e76f2..08d3cf056 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -580,7 +580,28 @@ export interface AstroUserConfig { * * When using this option, all of your static asset imports and URLs should add the base as a prefix. You can access this value via `import.meta.env.BASE_URL`. * - * The value of `import.meta.env.BASE_URL` respects your `trailingSlash` config and will include a trailing slash if you explicitly include one or if `trailingSlash: "always"` is set. If `trailingSlash: "never"` is set, `BASE_URL` will not include a trailing slash, even if `base` includes one. + * The value of `import.meta.env.BASE_URL` and configuration value `config.base` respects your `trailingSlash` config and will include a trailing slash if you explicitly include one or if `trailingSlash: "always"` is set. If `trailingSlash: "never"` is set, `BASE_URL` will not include a trailing slash, even if `base` includes one. + * + * This means with a configuration like this: + * ```js + * { + * base: '/docs/', + * trailingSlash: "never" + * } + * ``` + * + * `import.meta.env.BASE_URL` and `config.base` will be `/docs`. + * + * In a configuration like this: + * + * ```js + * { + * base: '/docs', + * trailingSlash: "always" + * } + * ``` + * + * `import.meta.env.BASE_URL` and `config.base` will be `/docs/`. */ base?: string;