From 92cc86ca649a51f08d944e0ae3143ce6d248762a Mon Sep 17 00:00:00 2001 From: amirhhashemi <87268103+amirhhashemi@users.noreply.github.com> Date: Thu, 2 Jan 2025 19:03:49 +0330 Subject: [PATCH] Fix errors --- .github/ISSUE_TEMPLATE/OTHER.yml | 6 +- src/routes/concepts/context.mdx | 81 +++---- src/routes/configuration/typescript.mdx | 34 ++- .../guides/deployment-options/aws-via-sst.mdx | 72 ++++-- .../guides/deployment-options/cloudflare.mdx | 35 ++- .../guides/deployment-options/firebase.mdx | 17 +- .../guides/deployment-options/netlify.mdx | 17 +- .../guides/deployment-options/railway.mdx | 17 +- .../guides/deployment-options/vercel.mdx | 18 +- .../guides/deployment-options/zerops.mdx | 24 +- src/routes/guides/routing-and-navigation.mdx | 17 +- src/routes/guides/state-management.mdx | 12 +- src/routes/guides/styling-components/less.mdx | 17 +- .../guides/styling-components/macaron.mdx | 19 +- src/routes/guides/styling-components/sass.mdx | 17 +- .../guides/styling-components/tailwind.mdx | 36 ++- src/routes/guides/styling-components/uno.mdx | 17 +- src/routes/guides/testing.mdx | 215 +++++++++++------- src/routes/pt-br/quick-start.mdx | 20 +- src/routes/pt-br/solid-router/quick-start.mdx | 20 +- src/routes/quick-start.mdx | 128 +++++++++-- .../installation-and-setup.mdx | 10 +- .../installation-and-setup.mdx | 17 +- .../reference/data-apis/use-submission.mdx | 85 +++---- .../reference/data-apis/use-submissions.mdx | 85 ++++--- .../data-loading.mdx | 41 ++-- .../building-your-application/routing.mdx | 39 ++-- src/routes/solid-start/getting-started.mdx | 58 ++++- 28 files changed, 835 insertions(+), 339 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/OTHER.yml b/.github/ISSUE_TEMPLATE/OTHER.yml index 50ef31571..27d160454 100644 --- a/.github/ISSUE_TEMPLATE/OTHER.yml +++ b/.github/ISSUE_TEMPLATE/OTHER.yml @@ -1,9 +1,7 @@ name: "Other Report 🌐" title: "[Other]:" description: Report something else we should know about the docs site! -labels: [ -"pending review" -] +labels: ["pending review"] body: - type: textarea id: issue @@ -12,4 +10,4 @@ body: description: Please describe the problem with the documentation in detail. placeholder: "..." validations: - required: true + required: true diff --git a/src/routes/concepts/context.mdx b/src/routes/concepts/context.mdx index e536dc2c6..33190ab58 100644 --- a/src/routes/concepts/context.mdx +++ b/src/routes/concepts/context.mdx @@ -23,25 +23,23 @@ This function has a `Provider` property that wraps the component tree you want t
+ ```jsx import { createContext } from "solid-js"; const MyContext = createContext(); +``` -````
+ ```jsx import { MyContext } from "./create"; -export function Provider (props) { - return ( - - {props.children} - - ) -}; -```` +export function Provider(props) { + return {props.children}; +} +```
@@ -162,6 +160,7 @@ You can pass a signal directly to the `value` prop of the `Provider` component,
+ ```jsx import { CounterProvider } from "./Context"; import { Child } from "./Child"; @@ -172,11 +171,13 @@ export function App() {

Welcome to Counter App

- ) + ); } ``` +
+ ```jsx import { createSignal, useContext } from "solid-js"; @@ -186,43 +187,45 @@ export function CounterProvider(props) { count, { increment() { - setCount(prev => prev + 1); + setCount((prev) => prev + 1); }, decrement() { - setCount(prev => prev - 1); - } - } + setCount((prev) => prev - 1); + }, + }, ]; - return ( - - {props.children} - - ); - + return ( + + {props.children} + + ); } -export function useCounter() { return useContext(CounterContext); } +export function useCounter() { + return useContext(CounterContext); +} ``` +
+ ```tsx title="/context/counter-component.tsx" import { useCounter } from "./Context"; export function Child(props) { const [count, { increment, decrement }] = useCounter(); - return ( - <> -
{count()}
- - - - ); - -}; + return ( + <> +
{count()}
+ + + + ); +} +``` -````
@@ -239,21 +242,21 @@ To solve this issue, a default value can be specified when creating a context ob import { useContext } from "solid-js"; function useMyContext() { - const value = useContext(MyContext); + const value = useContext(MyContext); - if (!value) { - throw new Error("Missing context Provider"); - } + if (!value) { + throw new Error("Missing context Provider"); + } - return value; + return value; } function Child() { - const value = useMyContext(); + const value = useMyContext(); - return
{value}
; + return
{value}
; } -```` +``` ## Common issues with `createContext` and `useContext` diff --git a/src/routes/configuration/typescript.mdx b/src/routes/configuration/typescript.mdx index fac50ad56..5e19e5d80 100644 --- a/src/routes/configuration/typescript.mdx +++ b/src/routes/configuration/typescript.mdx @@ -54,19 +54,32 @@ Transitioning from JavaScript to TypeScript in a Solid project offers the benefi
+ ```bash frame="none" npm i --save-dev typescript ``` +
+
-
```bash frame="none" yarn add --dev typescript ```
+```bash frame="none" +yarn add --dev typescript +``` -
```bash frame="none" pnpm add --save-dev typescript ```
+
+
+```bash frame="none" +pnpm add --save-dev typescript +``` + +
+ ```bash frame="none" bun add --save-dev typescript ``` +
@@ -74,19 +87,32 @@ bun add --save-dev typescript
+ ```bash frame="none" npx tsc --init ``` +
+
-
```bash frame="none" yarn dlx tsc --init ```
+```bash frame="none" +yarn dlx tsc --init +``` -
```bash frame="none" pnpm tsc --init ```
+
+
+```bash frame="none" +pnpm tsc --init +``` + +
+ ```bash frame="none" bunx tsc --init ``` +
diff --git a/src/routes/guides/deployment-options/aws-via-sst.mdx b/src/routes/guides/deployment-options/aws-via-sst.mdx index 96d3b58b1..b6bf5385b 100644 --- a/src/routes/guides/deployment-options/aws-via-sst.mdx +++ b/src/routes/guides/deployment-options/aws-via-sst.mdx @@ -13,10 +13,34 @@ mainNavExclude: true 2. In your project, init SST. -
```bash frame="none" npx sst@latest init ```
-
```bash frame="none" yarn dlx sst@latest init ```
-
```bash frame="none" pnpm dlx sst@latest init ```
-
```bash frame="none" bunx sst@latest init ```
+
+ +```bash frame="none" +npx sst@latest init +``` + +
+
+ +```bash frame="none" +yarn dlx sst@latest init +``` + +
+
+ +```bash frame="none" +pnpm dlx sst@latest init +``` + +
+
+ +```bash frame="none" +bunx sst@latest init +``` + +
3. This will detect your SolidStart app and ask you to update your `app.config.ts`. @@ -30,18 +54,34 @@ server: { 4. When you are ready, you can deploy your app using: -
- ```bash frame="none" npx sst@latest deploy --stage production ``` -
-
- ```bash frame="none" yarn dlx sst@latest deploy --stage production ``` -
-
- ```bash frame="none" pnpm dlx sst@latest deploy --stage production ``` -
-
- ```bash frame="none" bunx sst@latest deploy --stage production ``` -
+
+ +```bash frame="none" +npx sst@latest deploy --stage production +``` + +
+
+ +```bash frame="none" +yarn dlx sst@latest deploy --stage production +``` + +
+
+ +```bash frame="none" +pnpm dlx sst@latest deploy --stage production +``` + +
+
+ +```bash frame="none" +bunx sst@latest deploy --stage production +``` + +
You can [read the full tutorial on the SST docs](https://sst.dev/docs/start/aws/solid). diff --git a/src/routes/guides/deployment-options/cloudflare.mdx b/src/routes/guides/deployment-options/cloudflare.mdx index a08c0d232..f560b7fe2 100644 --- a/src/routes/guides/deployment-options/cloudflare.mdx +++ b/src/routes/guides/deployment-options/cloudflare.mdx @@ -60,19 +60,32 @@ Here are the steps to deploy your Solid project using Wrangler.
+ ```bash frame="none" npm i -g wrangler ``` +
+
-
```bash frame="none" yarn global add wrangler ```
+```bash frame="none" +yarn global add wrangler +``` + +
+
-
```bash frame="none" pnpm add -g wrangler ```
+```bash frame="none" +pnpm add -g wrangler +``` +
+ ```bash frame="none" bun add -g wrangler ``` +
@@ -86,25 +99,35 @@ wrangler login
+ ```bash frame="none" npm run build wrangler pages publish dist ``` -
+
- ```bash frame="none" yarn build wrangler pages publish dist ``` + +```bash frame="none" +yarn build wrangler pages publish dist +``` +
- ```bash frame="none" pnpm build wrangler pages publish dist ``` -
+```bash frame="none" +pnpm build wrangler pages publish dist +``` + +
+ ```bash frame="none" bun build wrangler pages publish dist ``` +
diff --git a/src/routes/guides/deployment-options/firebase.mdx b/src/routes/guides/deployment-options/firebase.mdx index b2ef90b11..37bd407d0 100644 --- a/src/routes/guides/deployment-options/firebase.mdx +++ b/src/routes/guides/deployment-options/firebase.mdx @@ -18,19 +18,32 @@ If you haven't, you can follow [Firebase's official guide](https://firebase.goog
+ ```bash frame="none" npm i -g firebase-tools ``` +
+
-
``` bash frame="none" yarn global add firebase-tools ```
+```bash frame="none" +yarn global add firebase-tools +``` -
```bash frame="none" pnpm add -g firebase-tools ```
+
+
+```bash frame="none" +pnpm add -g firebase-tools +``` + +
+ ```bash frame="none" bun add -g firebase-tools ``` +
diff --git a/src/routes/guides/deployment-options/netlify.mdx b/src/routes/guides/deployment-options/netlify.mdx index 808e720f0..77070b727 100644 --- a/src/routes/guides/deployment-options/netlify.mdx +++ b/src/routes/guides/deployment-options/netlify.mdx @@ -42,19 +42,32 @@ For detailed guidance on build procedures, deployment options, and the range of
+ ```bash frame="none" npm i -g netlify-cli ``` +
+
-
```bash frame="none" yarn global add netlify-cli ```
+```bash frame="none" +yarn global add netlify-cli +``` -
```bash frame="none" pnpm add -g netlify-cli ```
+
+
+```bash frame="none" +pnpm add -g netlify-cli +``` + +
+ ```bash frame="none" bun add -g netlify-cli ``` +
diff --git a/src/routes/guides/deployment-options/railway.mdx b/src/routes/guides/deployment-options/railway.mdx index ddb0d1544..37e4af0a5 100644 --- a/src/routes/guides/deployment-options/railway.mdx +++ b/src/routes/guides/deployment-options/railway.mdx @@ -73,19 +73,32 @@ Once a domain has been generated, your Solid project should be live.
+ ```bash frame="none" npm i -g @railway/cli ``` +
+
-
```bash frame="none" yarn global add @railway/cli ```
+```bash frame="none" +yarn global add @railway/cli +``` -
```bash frame="none" pnpm add -g @railway/cli ```
+
+
+```bash frame="none" +pnpm add -g @railway/cli +``` + +
+ ```bash frame="none" bun add -g @railway/cli ``` +
diff --git a/src/routes/guides/deployment-options/vercel.mdx b/src/routes/guides/deployment-options/vercel.mdx index 0b5bb6875..bebab13ee 100644 --- a/src/routes/guides/deployment-options/vercel.mdx +++ b/src/routes/guides/deployment-options/vercel.mdx @@ -53,19 +53,33 @@ For detailed information regarding build and deployment instructions, as well as
+ ```bash frame="none" npm i -g vercel ``` + +
+
+ +```bash frame="none" +yarn global add vercel +``` +
+
-
```bash frame="none" yarn global add vercel ```
+```bash frame="none" +pnpm add -g vercel +``` -
```bash frame="none" pnpm add -g vercel ```
+
+ ```bash frame="none" bun add -g vercel ``` +
diff --git a/src/routes/guides/deployment-options/zerops.mdx b/src/routes/guides/deployment-options/zerops.mdx index 6e8ce8055..8cb3f5e1d 100644 --- a/src/routes/guides/deployment-options/zerops.mdx +++ b/src/routes/guides/deployment-options/zerops.mdx @@ -148,9 +148,27 @@ irm https://zerops.io/zcli/install.ps1 | iex Npm -
```bash frame="none" npm i -g @zerops/zcli ```
-
```bash frame="none" pnpm add -g @zerops/zcli ```
-
```bash frame="none" yarn global add @zerops/zcli ```
+
+ +```bash frame="none" +npm i -g @zerops/zcli +``` + +
+
+ +```bash frame="none" +pnpm add -g @zerops/zcli +``` + +
+
+ +```bash frame="none" +yarn global add @zerops/zcli +``` + +
2. Open Settings > [Access Token Management](https://app.zerops.io/settings/token-management) in the Zerops app and generate a new access token. diff --git a/src/routes/guides/routing-and-navigation.mdx b/src/routes/guides/routing-and-navigation.mdx index 67c9a6dad..1d1a903e5 100644 --- a/src/routes/guides/routing-and-navigation.mdx +++ b/src/routes/guides/routing-and-navigation.mdx @@ -15,19 +15,32 @@ This package is not included by default.
+ ```bash frame="none" npm install @solidjs/router ``` +
+
-
```bash frame="none" yarn add @solidjs/router ```
+```bash frame="none" +yarn add @solidjs/router +``` -
```bash frame="none" pnpm add @solidjs/router ```
+
+
+```bash frame="none" +pnpm add @solidjs/router +``` + +
+ ```bash frame="none" bun add @solidjs/router ``` +
diff --git a/src/routes/guides/state-management.mdx b/src/routes/guides/state-management.mdx index be6ff8f41..5bdf48fb7 100644 --- a/src/routes/guides/state-management.mdx +++ b/src/routes/guides/state-management.mdx @@ -143,11 +143,19 @@ View this example of [`doubleCount` in a `createEffect` in the Solid Playground
- ```html title="Counter.tsx" Current count: 0 Doubled count: 0 ``` + +```html title="Counter.tsx" +Current count: 0 Doubled count: 0 +``` +
- ```html title="Counter.tsx" Current count: 1 Doubled count: 2 ``` + +```html title="Counter.tsx" +Current count: 1 Doubled count: 2 +``` +
diff --git a/src/routes/guides/styling-components/less.mdx b/src/routes/guides/styling-components/less.mdx index b877a2845..8b64b3fc9 100644 --- a/src/routes/guides/styling-components/less.mdx +++ b/src/routes/guides/styling-components/less.mdx @@ -13,19 +13,32 @@ To utilize LESS in a Solid app, it will need to be installed as a development de
+ ```bash frame="none" npm i --save-dev less ``` +
+
-
```bash frame="none" yarn add --dev less ```
+```bash frame="none" +yarn add --dev less +``` -
```bash frame="none" pnpm add --dev less ```
+
+
+```bash frame="none" +pnpm add --dev less +``` + +
+ ```bash frame="none" bun add --dev less ``` +
diff --git a/src/routes/guides/styling-components/macaron.mdx b/src/routes/guides/styling-components/macaron.mdx index 00085622d..01850198a 100644 --- a/src/routes/guides/styling-components/macaron.mdx +++ b/src/routes/guides/styling-components/macaron.mdx @@ -12,23 +12,32 @@ mainNavExclude: true
+ ```bash frame="none" npm install @macaron-css/core @macaron-css/solid ``` -
-
- ```bash frame="none" yarn add @macaron-css/core @macaron-css/solid ```
+
+ +```bash frame="none" +yarn add @macaron-css/core @macaron-css/solid +``` -
- ```bash frame="none" pnpm add @macaron-css/core @macaron-css/solid ```
+
+ +```bash frame="none" +pnpm add @macaron-css/core @macaron-css/solid +``` +
+ ```bash frame="none" bun add @macaron-css/core @macaron-css/solid ``` +
diff --git a/src/routes/guides/styling-components/sass.mdx b/src/routes/guides/styling-components/sass.mdx index 4ee234fea..ed222335c 100644 --- a/src/routes/guides/styling-components/sass.mdx +++ b/src/routes/guides/styling-components/sass.mdx @@ -13,19 +13,32 @@ Depending on your package manager, SASS can be installed as a development depend
+ ```bash frame="none" npm i --save-dev sass ``` +
+
-
```bash frame="none" yarn add --dev sass ```
+```bash frame="none" +yarn add --dev sass +``` -
```bash frame="none" pnpm add --save-dev sass ```
+
+
+```bash frame="none" +pnpm add --save-dev sass +``` + +
+ ```bash frame="none" bun add --dev sass ``` +
diff --git a/src/routes/guides/styling-components/tailwind.mdx b/src/routes/guides/styling-components/tailwind.mdx index e8505860d..cc36398cd 100644 --- a/src/routes/guides/styling-components/tailwind.mdx +++ b/src/routes/guides/styling-components/tailwind.mdx @@ -12,23 +12,32 @@ mainNavExclude: true
+ ```bash frame="none" npm i --save-dev tailwindcss postcss autoprefixer ``` -
+
- ```bash frame="none" yarn add --dev tailwindcss postcss autoprefixer ``` + +```bash frame="none" +yarn add --dev tailwindcss postcss autoprefixer +``` +
-
- ```bash frame="none" pnpm add --save-dev tailwindcss postcss autoprefixer ``` -
+```bash frame="none" +pnpm add --save-dev tailwindcss postcss autoprefixer +``` + +
+ ```bash frame="none" bun add --save-dev tailwindcss postcss autoprefixer ``` +
@@ -36,19 +45,32 @@ bun add --save-dev tailwindcss postcss autoprefixer
+ ```bash frame="none" npx tailwindcss init -p ``` +
+
+ +```bash frame="none" +yarn dlx tailwindcss init -p +``` -
```bash frame="none" yarn dlx tailwindcss init -p ```
+
+
-
```bash frame="none" pnpm dlx tailwindcss init -p ```
+```bash frame="none" +pnpm dlx tailwindcss init -p +``` +
+ ```bash frame="none" bunx tailwindcss init -p ``` +
diff --git a/src/routes/guides/styling-components/uno.mdx b/src/routes/guides/styling-components/uno.mdx index bc4f5d710..fb22726f2 100644 --- a/src/routes/guides/styling-components/uno.mdx +++ b/src/routes/guides/styling-components/uno.mdx @@ -12,19 +12,32 @@ To get started with UnoCSS in your Solid app:
+ ```bash frame="none" npm i --save-dev unocss ``` +
+
-
```bash frame="none" yarn add --dev unocss ```
+```bash frame="none" +yarn add --dev unocss +``` -
```bash frame="none" pnpm add --save-dev unocss ```
+
+
+```bash frame="none" +pnpm add --save-dev unocss +``` + +
+ ```bash frame="none" bun add --save-dev unocss ``` +
diff --git a/src/routes/guides/testing.mdx b/src/routes/guides/testing.mdx index 9e0ea8953..7c6f82b7e 100644 --- a/src/routes/guides/testing.mdx +++ b/src/routes/guides/testing.mdx @@ -22,18 +22,27 @@ The recommended testing testing framework for Solid applications is [vitest](htt To get started with vitest, install the following development dependencies: -
- ```bash frame="none" npm i -D vitest jsdom @solidjs/testing-library - @testing-library/user-event @testing-library/jest-dom ``` -
-
- ```bash frame="none" yarn add -D vitest jsdom @solidjs/testing-library - @testing-library/user-event @testing-library/jest-dom ``` -
-
- ```bash frame="none" pnpm i -D vitest jsdom @solidjs/testing-library - @testing-library/user-event @testing-library/jest-dom ``` -
+
+ +```bash frame="none" +npm i -D vitest jsdom @solidjs/testing-library @testing-library/user-event @testing-library/jest-dom +``` + +
+
+ +```bash frame="none" +yarn add -D vitest jsdom @solidjs/testing-library @testing-library/user-event @testing-library/jest-dom +``` + +
+
+ +```bash frame="none" +pnpm i -D vitest jsdom @solidjs/testing-library @testing-library/user-event @testing-library/jest-dom +``` + +
### Testing configuration @@ -92,35 +101,33 @@ The purpose of this file is to describe the intended behavior from a user's pers
+ ```jsx frame="none" -import { test, expect } from "vitest" -import { render } from "@solidjs/testing-library" -import userEvent from "@testing-library/user-event" -import { Counter } from "./Counter" +import { test, expect } from "vitest"; +import { render } from "@solidjs/testing-library"; +import userEvent from "@testing-library/user-event"; +import { Counter } from "./Counter"; -const user = userEvent.setup() +const user = userEvent.setup(); test("increments value", async () => { -const { getByRole } = render(() => ) -const counter = getByRole('button') -expect(counter).toHaveTextContent("1") -await user.click(counter) -expect(counter).toHaveTextContent("2") -}) - -```` + const { getByRole } = render(() => ); + const counter = getByRole("button"); + expect(counter).toHaveTextContent("1"); + await user.click(counter); + expect(counter).toHaveTextContent("2"); +}); +``` +
+ ```jsx frame="none" export const Counter = () => { - const [count, setCount] = createSignal(1); - return ( - - ); -} -```` + const [count, setCount] = createSignal(1); + return ; +}; +```
@@ -132,9 +139,27 @@ The [`expect` function provided by `vitest`](https://vitest.dev/api/expect.html) To run this test, use the following command: -
```bash frame="none" npm test ```
-
```bash frame="none" yarn test ```
-
```bash frame="none" pnpm test ```
+
+ +```bash frame="none" +npm test +``` + +
+
+ +```bash frame="none" +yarn test +``` + +
+
+ +```bash frame="none" +pnpm test +``` + +
If running the command is successful, you will get the following result showing whether the tests have passed or failed: @@ -232,33 +257,39 @@ Solid allows components to break through the DOM tree structure using [`
+ ```jsx frame="none" -import { test, expect } from "vitest" -import { render, screen } from "@solidjs/testing-library" -import { Toast } from "./Toast" +import { test, expect } from "vitest"; +import { render, screen } from "@solidjs/testing-library"; +import { Toast } from "./Toast"; test("increments value", async () => { -render(() =>

This is a toast

) -const toast = screen.getByRole("log") -expect(toast).toHaveTextContent("This is a toast") -}) + render(() => ( + +

This is a toast

+
+ )); + const toast = screen.getByRole("log"); + expect(toast).toHaveTextContent("This is a toast"); +}); +``` -````
+ ```jsx frame="none" import { Portal } from "solid-js/web"; export const Toast = (props) => { - return ( - -
- {props.children} -
-
- ); -} -```` + return ( + +
+ {props.children} +
+
+ ); +}; +```
@@ -390,36 +421,38 @@ This, along with the ability to modify the `arg` signal, are helpful when testin If, for example, you have a directive that handles the [Fullscreen API](https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API), you can test it like this: -
-```ts frame="none" -import { test, expect, vi } from "vitest" -import { renderDirective } from "@solidjs/testing-library" -import { createFullScreen } from "./fullscreen" +
+ +```tsx frame="none" +import { test, expect, vi } from "vitest"; +import { renderDirective } from "@solidjs/testing-library"; +import { createFullScreen } from "./fullscreen"; test("toggles fullscreen", () => { -const targetElement = document.createElement("div") -const fs = vi.spyOn(targetElement, "fullscreen") -const [setArg, container] = renderDirective(createFullScreen, false) -setArg(true) -expect(fs).toHaveBeenCalled() -}) - -```` -
-
-```ts frame="none" -import { Accessor } from "solid-js" + const targetElement = document.createElement("div"); + const fs = vi.spyOn(targetElement, "fullscreen"); + const [setArg, container] = renderDirective(createFullScreen, false); + setArg(true); + expect(fs).toHaveBeenCalled(); +}); +``` + +
+
+ +```tsx frame="none" +import { Accessor } from "solid-js"; export const fullscreen = (ref: HTMLElement, active: Accessor) => - createEffect(() => { - const isActive = document.fullscreenElement === ref - if (active() && !isActive) { - ref.requestFullScreen().catch(() => {}) - } else if (!active() && isActive) { - document.exitFullScreen() - } - }) -```` + createEffect(() => { + const isActive = document.fullscreenElement === ref; + if (active() && !isActive) { + ref.requestFullScreen().catch(() => {}); + } else if (!active() && isActive) { + document.exitFullScreen(); + } + }); +```
@@ -561,9 +594,27 @@ While coverage numbers can be misleading, they are used by many projects as a ro Vitest supports coverage collection. To use it, it needs an extra package: -
```bash frame="none" npm i -D @vitest/coverage-v8 ```
-
```bash frame="none" yarn add -D @vitest/coverage-v8 ```
-
```bash frame="none" pnpm i -D @vitest/coverage-v8 ```
+
+ +```bash frame="none" +npm i -D @vitest/coverage-v8 +``` + +
+
+ +```bash frame="none" +yarn add -D @vitest/coverage-v8 +``` + +
+
+ +```bash frame="none" +pnpm i -D @vitest/coverage-v8 +``` + +
Also, you need to [set up vitest's coverage feature](https://vitest.dev/guide/coverage.html). diff --git a/src/routes/pt-br/quick-start.mdx b/src/routes/pt-br/quick-start.mdx index bed73174f..17c8c215c 100644 --- a/src/routes/pt-br/quick-start.mdx +++ b/src/routes/pt-br/quick-start.mdx @@ -38,17 +38,25 @@ cd my-app
+ ```bash frame="none" npm install ``` +
+
-
```bash frame="none" yarn install ```
+```bash frame="none" +yarn install +``` +
+ ```bash frame="none" pnpm install ``` +
@@ -79,17 +87,25 @@ cd my-app
+ ```bash frame="none" npm install ``` +
+
-
```bash frame="none" yarn install ```
+```bash frame="none" +yarn install +``` +
+ ```bash frame="none" pnpm install ``` +
diff --git a/src/routes/pt-br/solid-router/quick-start.mdx b/src/routes/pt-br/solid-router/quick-start.mdx index bed73174f..17c8c215c 100644 --- a/src/routes/pt-br/solid-router/quick-start.mdx +++ b/src/routes/pt-br/solid-router/quick-start.mdx @@ -38,17 +38,25 @@ cd my-app
+ ```bash frame="none" npm install ``` +
+
-
```bash frame="none" yarn install ```
+```bash frame="none" +yarn install +``` +
+ ```bash frame="none" pnpm install ``` +
@@ -79,17 +87,25 @@ cd my-app
+ ```bash frame="none" npm install ``` +
+
-
```bash frame="none" yarn install ```
+```bash frame="none" +yarn install +``` +
+ ```bash frame="none" pnpm install ``` +
diff --git a/src/routes/quick-start.mdx b/src/routes/quick-start.mdx index fe5ac3fe5..985c40b28 100644 --- a/src/routes/quick-start.mdx +++ b/src/routes/quick-start.mdx @@ -26,27 +26,39 @@ To get an application running, follow the steps below based on the language you
+ ```bash frame="none" npx degit solidjs/templates/js my-app ``` -
-
- ```bash frame="none" yarn dlx degit solidjs/templates/js my-app ```
+
+ +```bash frame="none" +yarn dlx degit solidjs/templates/js my-app +``` -
- ```bash frame="none" pnpm dlx degit solidjs/templates/js my-app ```
+
+ +```bash frame="none" +pnpm dlx degit solidjs/templates/js my-app +``` -
- ```bash frame="none" bunx degit solidjs/templates/js my-app ```
+
+ +```bash frame="none" +bunx degit solidjs/templates/js my-app +``` +
+ ```bash frame="none" deno -A npm:degit solidjs/templates/js my-app ``` +
@@ -60,21 +72,39 @@ cd my-app
+ ```bash frame="none" npm install ``` +
+
-
```bash frame="none" yarn install ```
+```bash frame="none" +yarn install +``` -
```bash frame="none" pnpm install ```
+
+
-
```bash frame="none" bun install ```
+```bash frame="none" +pnpm install +``` +
+
+ +```bash frame="none" +bun install +``` + +
+ ```bash frame="none" deno install ``` +
@@ -82,24 +112,39 @@ deno install
+ ```bash frame="none" npm run dev ``` +
+
+ +```bash frame="none" +yarn dev +``` -
```bash frame="none" yarn dev ```
+
+
-
```bash frame="none" pnpm dev ```
+```bash frame="none" +pnpm dev +``` +
+ ```bash frame="none" bun dev ``` +
+ ```bash frame="none" deno task dev ``` +
@@ -112,28 +157,39 @@ Now, you can open your browser and navigate to `localhost:3000` to see your appl
+ ```bash frame="none" npx degit solidjs/templates/ts my-app ``` -
-
- ```bash frame="none" yarn dlx degit solidjs/templates/ts my-app ```
+
+ +```bash frame="none" +yarn dlx degit solidjs/templates/ts my-app +``` -
- ```bash frame="none" pnpm dlx degit solidjs/templates/ts my-app ```
+
+```bash frame="none" +pnpm dlx degit solidjs/templates/ts my-app +``` + +
+ ```bash frame="none" bunx degit solidjs/templates/ts my-app ``` +
+ ```bash frame="none" deno -A npm:degit solidjs/templates/ts my-app ``` +
@@ -147,24 +203,39 @@ cd my-app
+ ```bash frame="none" npm install ``` +
+
+ +```bash frame="none" +yarn install +``` -
```bash frame="none" yarn install ```
+
+
-
```bash frame="none" pnpm install ```
+```bash frame="none" +pnpm install +``` +
+ ```bash frame="none" bun install ``` +
+ ```bash frame="none" deno install ``` +
@@ -172,24 +243,39 @@ deno install
+ ```bash frame="none" npm run dev ``` +
+
-
```bash frame="none" yarn dev ```
+```bash frame="none" +yarn dev +``` + +
+
-
```bash frame="none" pnpm dev ```
+```bash frame="none" +pnpm dev +``` +
+ ```bash frame="none" bun dev ``` +
+ ```bash frame="none" deno task dev ``` +
diff --git a/src/routes/solid-meta/getting-started/installation-and-setup.mdx b/src/routes/solid-meta/getting-started/installation-and-setup.mdx index 25bde1e2d..5daf37c9d 100644 --- a/src/routes/solid-meta/getting-started/installation-and-setup.mdx +++ b/src/routes/solid-meta/getting-started/installation-and-setup.mdx @@ -14,17 +14,25 @@ To get started, install using your preferred package manager.
+ ```bash frame="none" npm i @solidjs/meta ``` +
+
-
```bash frame="none" yarn add @solidjs/meta ```
+```bash frame="none" +yarn add @solidjs/meta +``` +
+ ```bash frame="none" pnpm add @solidjs/meta ``` +
diff --git a/src/routes/solid-router/getting-started/installation-and-setup.mdx b/src/routes/solid-router/getting-started/installation-and-setup.mdx index aa5855796..f3e0cd132 100644 --- a/src/routes/solid-router/getting-started/installation-and-setup.mdx +++ b/src/routes/solid-router/getting-started/installation-and-setup.mdx @@ -15,19 +15,32 @@ To get started with Solid Router, install it using your preferred package manage
+ ```bash frame="none" npm i @solidjs/router ``` +
+
-
```bash frame="none" yarn add @solidjs/router ```
+```bash frame="none" +yarn add @solidjs/router +``` -
```bash frame="none" pnpm add @solidjs/router ```
+
+
+```bash frame="none" +pnpm add @solidjs/router +``` + +
+ ```bash frame="none" bun add @solidjs/router ``` +
diff --git a/src/routes/solid-router/reference/data-apis/use-submission.mdx b/src/routes/solid-router/reference/data-apis/use-submission.mdx index b01998327..e1f6e93c1 100644 --- a/src/routes/solid-router/reference/data-apis/use-submission.mdx +++ b/src/routes/solid-router/reference/data-apis/use-submission.mdx @@ -69,64 +69,65 @@ Once the action is complete, the `pending` property will be set to `false` and t
+ ```tsx title="component.tsx" {5,9-11} import { Show } from "solid-js"; import { useSubmission } from "@solidjs/router"; function Component() { -const submission = useSubmission(postNameAction); - - return ( - <> - - {(name) =>
Optimistic: {name() as string}
} -
- - - {(name) =>
Result: {name()}
} -
- -
- - -
- - ) + const submission = useSubmission(postNameAction); + return ( + <> + + {(name) =>
Optimistic: {name() as string}
} +
+ + + {(name) =>
Result: {name()}
} +
+ +
+ + +
+ + ); } +``` -````
+ ```tsx title="component.jsx" {5,9-11} import { Show } from "solid-js"; import { useSubmission } from "@solidjs/router"; function Component() { - const submission = useSubmission(postNameAction); - - return ( - <> - - {(name) =>
Optimistic: {name()}
} -
- - - {(name) =>
Result: {name()}
} -
- -
- - -
- - ) + const submission = useSubmission(postNameAction); + + return ( + <> + + {(name) =>
Optimistic: {name()}
} +
+ + + {(name) =>
Result: {name()}
} +
+ +
+ + +
+ + ); } -```` +```
diff --git a/src/routes/solid-router/reference/data-apis/use-submissions.mdx b/src/routes/solid-router/reference/data-apis/use-submissions.mdx index 53df4af40..8e4db5288 100644 --- a/src/routes/solid-router/reference/data-apis/use-submissions.mdx +++ b/src/routes/solid-router/reference/data-apis/use-submissions.mdx @@ -104,68 +104,67 @@ Once the action is complete, the `pending` property will be set to `false` and t
+ ```tsx title="component.tsx" {5,12-19} import { Show } from "solid-js"; import { useSubmissions } from "@solidjs/router"; function Component() { -const submissions = useSubmissions(postNameAction); - - return ( -
-
    - - {([attemptIndex, data]) => ( - - {(input) => { - const name = (input().value as [string, string])[1] + const submissions = useSubmissions(postNameAction); - return ( -
  • Optimistic: {name}
  • - )}} -
    - )} -
    -
- - -
- ) + return ( +
+
    + + {([attemptIndex, data]) => ( + + {(input) => { + const name = (input().value as [string, string])[1]; + return
  • Optimistic: {name}
  • ; + }} +
    + )} +
    +
+ + +
+ ); } +``` -````
+ ```tsx title="component.jsx" {5,12-19} import { Show } from "solid-js"; import { useSubmissions } from "@solidjs/router"; function Component() { - const submissions = useSubmissions(postNameAction); + const submissions = useSubmissions(postNameAction); - return ( -
-
    - - {([attemptIndex, data]) => ( - - {(input) => { - const name = input().value[1] + return ( + +
      + + {([attemptIndex, data]) => ( + + {(input) => { + const name = input().value[1]; - return ( -
    • Optimistic: {name}
    • - )}} -
      - )} -
      -
    - - - - ) + return
  • Optimistic: {name}
  • ; + }} +
    + )} +
    +
+ + + + ); } -```` +```
diff --git a/src/routes/solid-start/building-your-application/data-loading.mdx b/src/routes/solid-start/building-your-application/data-loading.mdx index d652d9b9a..08abdfec6 100644 --- a/src/routes/solid-start/building-your-application/data-loading.mdx +++ b/src/routes/solid-start/building-your-application/data-loading.mdx @@ -14,6 +14,7 @@ It takes an async function and returns a [signal](/reference/basic-reactivity/cr
+ ```tsx {6-9} title="/src/routes/users.tsx" import { For, createResource } from "solid-js"; @@ -25,25 +26,25 @@ export default function Page() { return (await response.json()) as User[]; }); - return {(user) =>
  • {user.name}
  • }
    ; - + return {(user) =>
  • {user.name}
  • }
    ; } +``` -````
    + ```tsx {4-7} title="/src/routes/users.jsx" import { For, createResource } from "solid-js"; export default function Page() { const [users] = createResource(async () => { const response = await fetch("https://example.com/users"); - return (await response.json()); + return await response.json(); }); return {(user) =>
  • {user.name}
  • }
    ; } -```` +```
    @@ -56,6 +57,7 @@ Using some of the features of `solid-router`, we can create a cache for our data
    + ```tsx title="/routes/users.tsx" {6, 9, 12} import { For } from "solid-js"; import { createAsync, query } from "@solidjs/router"; @@ -63,8 +65,8 @@ import { createAsync, query } from "@solidjs/router"; type User = { name: string; email: string }; const getUsers = query(async () => { -const response = await fetch("https://example.com/users"); -return (await response.json()) as User[]; + const response = await fetch("https://example.com/users"); + return (await response.json()) as User[]; }, "users"); export const route = { @@ -74,21 +76,21 @@ export const route = { export default function Page() { const users = createAsync(() => getUsers()); - return {(user) =>
  • {user.name}
  • }
    ; - + return {(user) =>
  • {user.name}
  • }
    ; } +``` -````
    + ```tsx title="/routes/users.jsx" {4, 7, 10} import { For } from "solid-js"; import { createAsync, query } from "@solidjs/router"; const getUsers = query(async () => { const response = await fetch("https://example.com/users"); - return (await response.json()); + return await response.json(); }, "users"); export const route = { @@ -100,7 +102,7 @@ export default function Page() { return {(user) =>
  • {user.name}
  • }
    ; } -```` +```
    @@ -127,6 +129,7 @@ For example, it could be database access or internal APIs, or when you sit withi
    + ```tsx title="/routes/users.tsx" {7} import { For } from "solid-js"; import { createAsync, query } from "@solidjs/router"; @@ -134,8 +137,8 @@ import { createAsync, query } from "@solidjs/router"; type User = { name: string; email: string }; const getUsers = query(async () => { -"use server"; -return store.users.list(); + "use server"; + return store.users.list(); }, "users"); export const route = { @@ -145,15 +148,14 @@ export const route = { export default function Page() { const users = createAsync(() => getUsers()); - return {(user) =>
  • {user.name}
  • }
    ; - + return {(user) =>
  • {user.name}
  • }
    ; } +``` -````
    -
    + ```tsx title="/routes/users.jsx" {5} import { For } from "solid-js"; import { createAsync, query } from "@solidjs/router"; @@ -172,7 +174,8 @@ export default function Page() { return {(user) =>
  • {user.name}
  • }
    ; } -```` +```
    +``` diff --git a/src/routes/solid-start/building-your-application/routing.mdx b/src/routes/solid-start/building-your-application/routing.mdx index 9836bf2ff..fd819e695 100644 --- a/src/routes/solid-start/building-your-application/routing.mdx +++ b/src/routes/solid-start/building-your-application/routing.mdx @@ -88,7 +88,8 @@ In this case the `blog.tsx` file will act as a layout for the articles in the `b by using `props.children` in the layout. -
    +
    + ```tsx filename="routes/blog.tsx" title="blog.tsx" import { RouteSectionProps } from "@solidjs/router"; @@ -96,14 +97,17 @@ export default function BlogLayout(props: RouteSectionProps) { return
    {props.children}
    ; } ``` -
    -
    - ```jsx filename="routes/blog.jsx" title="blog.tsx" + +
    +
    + +```jsx filename="routes/blog.jsx" title="blog.tsx" export default function BlogLayout(props) { return
    {props.children}
    ; } ``` -
    + +
    **Note**: Creating a `blog/index.tsx` or `blog/(blogIndex).tsx` is not the same as it would only be used for the index route. @@ -249,7 +253,8 @@ SolidStart offers a way to add additional route configuration outside of the fil Since SolidStart supports the use of other routers, you can use the `route` export provided by `` to define the route configuration for the router of your choice. -
    +
    + ```jsx {3-7} import type { RouteSectionProps, RouteDefinition } from "@solidjs/router"; @@ -268,10 +273,11 @@ export default function UsersLayout(props: RouteSectionProps) { ); } ``` -
    -
    -```jsx {3-7} +
    +
    + +```jsx {3-7} export const route = { preload() { // define preload function @@ -279,15 +285,16 @@ export const route = { }; export default function UsersLayout(props) { - return ( -
    -

    Users

    - {props.children} -
    - ); + return ( +
    +

    Users

    + {props.children} +
    + ); } ``` -
    + +
    [api-routes]: /core-concepts/api-routes diff --git a/src/routes/solid-start/getting-started.mdx b/src/routes/solid-start/getting-started.mdx index 73f1def42..2691d8cd9 100644 --- a/src/routes/solid-start/getting-started.mdx +++ b/src/routes/solid-start/getting-started.mdx @@ -10,21 +10,39 @@ Once you have created a directory for your new application, you can initialize S
    + ```bash frame="none" npm init solid@latest ``` +
    +
    + +```bash frame="none" +yarn create solid +``` -
    ```bash frame="none" yarn create solid ```
    +
    +
    -
    ```bash frame="none" pnpm create solid ```
    +```bash frame="none" +pnpm create solid +``` -
    ```bash frame="none" bun create solid ```
    +
    +
    +```bash frame="none" +bun create solid +``` + +
    + ```bash frame="none" deno run -A npm:create-solid ``` +
    @@ -52,19 +70,32 @@ Once you have chosen your template and configuration options, you can navigate t
    + ```bash frame="none" npm install ``` +
    +
    + +```bash frame="none" +yarn install +``` -
    ```bash frame="none" yarn install ```
    +
    +
    -
    ```bash frame="none" pnpm i ```
    +```bash frame="none" +pnpm i +``` +
    + ```bash frame="none" bun install ``` +
    @@ -76,19 +107,32 @@ To run your application locally, you can use the following command:
    + ```bash frame="none" npm run dev ``` +
    +
    -
    ```bash frame="none" yarn dev ```
    +```bash frame="none" +yarn dev +``` -
    ```bash frame="none" pnpm dev ```
    +
    +
    +```bash frame="none" +pnpm dev +``` + +
    + ```bash frame="none" bun dev ``` +