diff options
author | 2021-07-15 16:03:05 -0400 | |
---|---|---|
committer | 2021-07-15 16:03:40 -0400 | |
commit | 73b8a3a40b6233fea7d45a4db6c43d63ad0bfdd8 (patch) | |
tree | 6b03c2635040a1ad977808e3c1d81fff2140d26f /docs/src/pages/reference/api-reference.md | |
parent | 719a7217bac03ecc709ba573d73bdd27b96a7e3d (diff) | |
download | astro-73b8a3a40b6233fea7d45a4db6c43d63ad0bfdd8.tar.gz astro-73b8a3a40b6233fea7d45a4db6c43d63ad0bfdd8.tar.zst astro-73b8a3a40b6233fea7d45a4db6c43d63ad0bfdd8.zip |
fix import.meta docs reference
Diffstat (limited to 'docs/src/pages/reference/api-reference.md')
-rw-r--r-- | docs/src/pages/reference/api-reference.md | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/docs/src/pages/reference/api-reference.md b/docs/src/pages/reference/api-reference.md index b5f4f1bf1..1be5d3c2c 100644 --- a/docs/src/pages/reference/api-reference.md +++ b/docs/src/pages/reference/api-reference.md @@ -169,15 +169,18 @@ Astro will generate an RSS 2.0 feed at `/feed/[collection].xml` (for example, `/ ## `import.meta` -All ESM modules include a `import.meta` property. Astro adds `import.meta.env` through [Snowpack](https://www.snowpack.dev/). +> In this section we use `[dot]` to mean `.`. This is because of a bug in our build engine that is rewriting `import[dot]meta[dot]env` if we use `.` instead of `[dot]`. -**import.meta.env.SSR** can be used to know when rendering on the server. Some times you might want different logic, for example a component that should only be rendered in the client: +All ESM modules include a `import.meta` property. Astro adds `import[dot]meta[dot]env` through [Snowpack](https://www.snowpack.dev/). + +**`import[dot]meta[dot]env[dot]SSR`** can be used to know when rendering on the server. Some times you might want different logic, for example a component that should only be rendered in the client: ```jsx import { h } from 'preact'; export default function () { - return import.meta.env.SSR ? <div class="spinner"></div> : <FancyComponent />; + // Note: rewrite "[dot]" to "." for this to to work in your project. + return import[dot]meta[dot]env[dot]SSR ? <div class="spinner"></div> : <FancyComponent />; } ``` |