Skip to content

Commit

Permalink
Merge branch 'main' into fix-0802-1
Browse files Browse the repository at this point in the history
  • Loading branch information
liruifengv authored Aug 2, 2024
2 parents a8ea31e + 1e26130 commit 695197f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
12 changes: 6 additions & 6 deletions src/content/docs/en/guides/content-collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,12 @@ Alternatively, you can set this value in your editor settings. For example, to s
```json
{
"json.schemas": [
{
"fileMatch": [
"/src/content/authors/**"
],
"url": "./.astro/collections/authors.schema.json"
}
{
"fileMatch": [
"/src/content/authors/**"
],
"url": "./.astro/collections/authors.schema.json"
}
]
}
```
Expand Down
24 changes: 8 additions & 16 deletions src/content/docs/en/guides/imports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ The following file types are supported out-of-the-box by Astro:
- Astro Components (`.astro`)
- Markdown (`.md`, `.markdown`, etc.)
- JavaScript (`.js`, `.mjs`)
- TypeScript (`.ts`, `.tsx`)
- TypeScript (`.ts`)
- NPM Packages
- JSON (`.json`)
- JSX (`.jsx`, `.tsx`)
- CSS (`.css`)
- CSS Modules (`.module.css`)
- Images & Assets (`.svg`, `.jpg`, `.png`, etc.)
Expand All @@ -41,6 +40,13 @@ import { getUser } from './user.js';

JavaScript can be imported using normal ESM `import` & `export` syntax.

:::note[Importing JSX files]

An appropriate [UI framework](/en/guides/framework-components/) ([React](/en/guides/integrations-guide/react/), [Preact](/en/guides/integrations-guide/preact/), or [Solid](/en/guides/integrations-guide/solid-js/)) is required to render JSX/TSX files.
Use `.jsx`/`.tsx` extensions where appropriate, as Astro does not support JSX in `.js`/`.ts` files.

:::

### TypeScript

```js
Expand All @@ -65,20 +71,6 @@ import MyComponent from "./MyComponent"; // MyComponent.tsx
<ReadMore>Read more about [TypeScript support in Astro](/en/guides/typescript/).</ReadMore>


### JSX / TSX

```js
import { MyComponent } from './MyComponent.jsx';
```

Astro includes built-in support for JSX (`*.jsx` and `*.tsx`) files in your project. JSX syntax is automatically transpiled to JavaScript.

While Astro understands JSX syntax out-of-the-box, you will need to include a framework integration to properly render frameworks like React, Preact and Solid. Check out our [Using Integrations](/en/guides/integrations-guide/) guide to learn more.

:::note
**Astro does not support JSX in `.js`/`.ts` files.** JSX will only be handled inside of files that end with the `.jsx` and `.tsx` file extensions.
:::

### NPM Packages

If you've installed an NPM package, you can import it in Astro.
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/fr/basics/astro-components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const myFavoritePokemon = [/* ... */];
const { title } = Astro.props;
---
<!-- les commentaires HTML sont supportés ! -->
{/* La syntaxe des commentaires JavaScipt est aussi valide ! */}
{/* La syntaxe des commentaires JavaScript est aussi valide ! */}
<Banner />
<h1>Hello, world!</h1>
Expand Down

0 comments on commit 695197f

Please sign in to comment.