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] Document base #5693

Merged
merged 7 commits into from
Jan 4, 2023
Merged
Changes from 2 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
11 changes: 9 additions & 2 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,22 @@ export interface AstroUserConfig {
* @name base
* @type {string}
* @description
* The base path to deploy to. Astro will build your pages and assets using this path as the root. Currently, this has no effect during development.
* The base path you're deploying to. Astro will match this pathname during development so that your development experience matches your build environment as closely as possible. You can access this value in your app via `import.meta.env.BASE_URL`.
sarah11918 marked this conversation as resolved.
Show resolved Hide resolved
*
* You can access this value in your app via `import.meta.env.BASE_URL`.
* In the example below, `astro dev` will start your server at `/docs`.
*
* ```js
* {
* base: '/docs'
* }
* ```
*
* When using this option, all of your static asset imports and URLs should add the base as a prefix.
sarah11918 marked this conversation as resolved.
Show resolved Hide resolved
*
* ```astro
* <a href="/docs/about/>About</a>
* <img src="/docs/image.png">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe show how we'd write URLs that adapt to changing base URLs?

Suggested change
* <a href="/docs/about/>About</a>
* <img src="/docs/image.png">
* <a href="{import.meta.env.BASE_URL}/about/">About</a>
* <img src="{import.meta.env.BASE_URL}/image.png">

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we show this instead of using the base from the example? Or in addition to?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd thought the literal base was clear enough, but it might not be. You could do one of each?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I think /docs/ is clear enough, but using `${import.meta.env.BASE_URL}/image.png` for the second example couldn't hurt.

sarah11918 marked this conversation as resolved.
Show resolved Hide resolved
* ```
*/
base?: string;

Expand Down