Skip to content

Commit a418886

Browse files
Merge branch 'main' into improve-show-2
2 parents c6d069a + f048e0d commit a418886

File tree

11 files changed

+77
-28
lines changed

11 files changed

+77
-28
lines changed

src/routes/concepts/stores.mdx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,21 @@ setStore("users", 3, "loggedIn" , (loggedIn) => !loggedIn)
347347

348348
### Filtering values
349349

350-
In scenarios where you want to update elements in an array based on a specific condition, you can pass a function as an argument.
351-
This function will act as a filter, allowing you to select elements that satisfy the condition.
352-
It receives the old value and index as arguments, providing the flexibility to make conditional updates.
350+
To update elements in an array based on specific conditions, you can pass a function as an argument.
351+
This function acts as a filter, receiving the old value and index, and gives you the flexibility to apply logic that targets specific cases.
352+
This might include using methods like `.startsWith()`, `includes()`, or other comparison techniques to determine which elements should be updated.
353353

354354
```jsx
355+
// update users with username that starts with "t"
355356
setStore("users", (user) => user.username.startsWith("t"), "loggedIn", false)
356-
```
357357

358-
In addition to [`.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith), you can use other array methods like [`.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) to filter for the values that you need.
358+
// update users with location "Canada"
359+
setStore("users", (user) => user.location == "Canada" , "loggedIn", false)
360+
361+
// update users with id 1, 2 or 3
362+
let ids = [1,2,3]
363+
setStore("users", (user) => ids.includes(user.id) , "loggedIn", false)
364+
```
359365

360366
## Modifying objects
361367

src/routes/reference/reactive-utilities/untrack.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function Component(props) {
2020
It is not necessary to manually untrack values that are suppose to serve as a default or initial value to a signal. Even with the linter configured to enforce tracking, the linter will accept it when a `prop` is prefixed with `default` or `initial` as it is a common pattern to use them as such.
2121

2222

23-
```tsx tab title="initialValue" {4}
23+
```tsx tab title="initialValue" {5}
2424
// component.tsx
2525
import { createSignal } from "solid-js"
2626

@@ -32,7 +32,7 @@ export function Component(props) {
3232
}
3333
```
3434

35-
```tsx tab title="defaultValue" {4}
35+
```tsx tab title="defaultValue" {5}
3636
// component.tsx
3737
import { createSignal } from "solid-js"
3838

src/routes/solid-router/reference/data-apis/use-submissions.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ When the form is submitted, the `submission` object will be updated with the new
9191
This allows you to provide feedback to the user that the action is in progress.
9292
Once the action is complete, the `pending` property will be set to `false` and the `result` property will be updated with final value.
9393

94-
```tsx tab title="TypeScript" {5,12-19}
94+
```tsx tab title="TypeScript" {6,13-20}
9595
// component.tsx
9696
import { Show } from "solid-js";
9797
import { useSubmissions } from "@solidjs/router";
@@ -122,7 +122,7 @@ function Component() {
122122
}
123123
```
124124

125-
```tsx tab title="JavaScript" {5,12-19}
125+
```tsx tab title="JavaScript" {6,13-20}
126126
// component.jsx
127127
import { Show } from "solid-js";
128128
import { useSubmissions } from "@solidjs/router";

src/routes/solid-start/guides/data-fetching.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ To show a loading UI during data-fetching:
6464
1. Import [`Suspense`](/reference/components/suspense) from `solid-js`.
6565
2. Wrap your data rendering in `<Suspense>`, and use the `fallback` prop to show a component during data fetching.
6666

67-
```tsx tab title="TypeScript" {13} {15}
67+
```tsx tab title="TypeScript" {14} {16}
6868
// src/routes/index.tsx
6969
import { Suspense, For } from "solid-js";
7070
import { query, createAsync } from "@solidjs/router";
@@ -86,7 +86,7 @@ export default function Page() {
8686
}
8787
```
8888

89-
```jsx tab title="JavaScript" {13} {15}
89+
```jsx tab title="JavaScript" {14} {16}
9090
// src/routes/index.jsx
9191
import { Suspense, For } from "solid-js";
9292
import { query, createAsync } from "@solidjs/router";
@@ -115,7 +115,7 @@ To show a fallback UI if the data-fetching fails:
115115
1. Import [`ErrorBoundary`](/reference/components/error-boundary) from `solid-js`.
116116
2. Wrap the data rendering in `<ErrorBoundary>`, and use the `fallback` prop to show a component if an error occurs.
117117

118-
```tsx tab title="TypeScript" {13} {17}
118+
```tsx tab title="TypeScript" {14} {18}
119119
// src/routes/index.tsx
120120
import { ErrorBoundary, Suspense, For } from "solid-js";
121121
import { query, createAsync } from "@solidjs/router";
@@ -139,7 +139,7 @@ export default function Page() {
139139
}
140140
```
141141

142-
```jsx tab title="JavaScript" {13} {17}
142+
```jsx tab title="JavaScript" {14} {18}
143143
// src/routes/index.jsx
144144
import { ErrorBoundary, Suspense, For } from "solid-js";
145145
import { query, createAsync } from "@solidjs/router";
@@ -171,7 +171,7 @@ Data fetching can be optimized during user navigation by preloading the data:
171171
2. Run your query inside the `preload` function.
172172
3. Use the query as usual in your component.
173173

174-
```tsx tab title="TypeScript" {9-11}
174+
```tsx tab title="TypeScript" {10-12}
175175
// src/routes/index.tsx
176176
import { ErrorBoundary } from "solid-js";
177177
import { query, createAsync, type RouteDefinition } from "@solidjs/router";
@@ -197,7 +197,7 @@ export default function Page() {
197197
}
198198
```
199199

200-
```jsx tab title="JavaScript" {9-11}
200+
```jsx tab title="JavaScript" {10-12}
201201
// src/routes/index.jsx
202202
import { ErrorBoundary } from "solid-js";
203203
import { query, createAsync } from "@solidjs/router";
@@ -227,7 +227,7 @@ export default function Page() {
227227

228228
When creating a query that accepts parameters, define your query function to take any number of arguments:
229229

230-
```tsx tab title="TypeScript" {4} {10} {15}
230+
```tsx tab title="TypeScript" {5} {11} {16}
231231
// src/routes/posts/[id]/index.tsx
232232
import { ErrorBoundary } from "solid-js";
233233
import { query, createAsync, type RouteDefinition } from "@solidjs/router";
@@ -254,7 +254,7 @@ export default function Page() {
254254
}
255255
```
256256

257-
```jsx tab title="JavaScript" {4} {10} {15}
257+
```jsx tab title="JavaScript" {5} {11} {16}
258258
// src/routes/posts/[id]/index.jsx
259259
import { ErrorBoundary } from "solid-js";
260260
import { query, createAsync } from "@solidjs/router";
@@ -285,7 +285,7 @@ export default function Page() {
285285

286286
To safely interact with your database or ORM in a query, ensure it's server-only by adding [`"use server"`](/solid-start/reference/server/use-server) as the first line of your query:
287287

288-
```tsx tab title="TypeScript" {6-7}
288+
```tsx tab title="TypeScript" {7-8}
289289
// src/routes/index.tsx
290290
import { For, ErrorBoundary } from "solid-js";
291291
import { query, createAsync, type RouteDefinition } from "@solidjs/router";
@@ -312,7 +312,7 @@ export default function Page() {
312312
}
313313
```
314314

315-
```jsx tab title="JavaScript" {6-7}
315+
```jsx tab title="JavaScript" {7-8}
316316
// src/routes/index.jsx
317317
import { For, ErrorBoundary } from "solid-js";
318318
import { query, createAsync } from "@solidjs/router";
@@ -343,7 +343,7 @@ export default function Page() {
343343

344344
To fetch data only on the client, use the [`createResource`](/reference/basic-reactivity/create-resource) primitive:
345345

346-
```tsx tab title="TypeScript" {4-7}
346+
```tsx tab title="TypeScript" {5-8} {13}
347347
// src/routes/index.tsx
348348
import { createResource, ErrorBoundary, Suspense, For } from "solid-js";
349349

@@ -364,7 +364,7 @@ export default function Page() {
364364
}
365365
```
366366

367-
```jsx tab title="JavaScript" {4-7}
367+
```jsx tab title="JavaScript" {5-8} {13}
368368
// src/routes/index.jsx
369369
import { createResource, ErrorBoundary, Suspense, For } from "solid-js";
370370

src/routes/solid-start/guides/data-mutation.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default function Page() {
6262

6363
To pass additional arguments to your action, use the `with` method:
6464

65-
```tsx tab title="TypeScript" {15}
65+
```tsx tab title="TypeScript" {4} {15}
6666
// src/routes/index.tsx
6767
import { action } from "@solidjs/router";
6868

@@ -85,7 +85,7 @@ export default function Page() {
8585
}
8686
```
8787

88-
```jsx tab title="JavaScript" {15}
88+
```jsx tab title="JavaScript" {4} {15}
8989
// src/routes/index.jsx
9090
import { action } from "@solidjs/router";
9191

src/routes/solid-start/guides/security.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default createMiddleware({
5656
});
5757
```
5858

59-
```tsx tab title="entry-server.tsx" {6}
59+
```tsx tab title="entry-server.tsx" {7}
6060
// src/entry-server.tsx
6161
// @refresh reload
6262
import { createHandler, StartServer } from "@solidjs/start/server";

src/solidbase-theme/Layout.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import { I18nProvider } from "~/i18n/i18n-context";
77
import { Title } from "@solidjs/meta";
88
import { useThemeListener } from "@kobalte/solidbase/client";
99
import { usePace } from "@kobalte/solidbase/default-theme/pace.js";
10+
import { useProjectTitle } from "~/ui/use-project-title";
1011

1112
export default function (props: RouteSectionProps) {
1213
useThemeListener();
1314
usePace();
1415

16+
const projectTitle = useProjectTitle();
17+
1518
return (
1619
<I18nProvider>
17-
<Title>Solid Docs</Title>
20+
<Title>{projectTitle()}</Title>
1821
<ErrorBoundary fallback={() => <NotFound />}>
1922
<Layout>{props.children}</Layout>
2023
</ErrorBoundary>

src/styles/expressive-code.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ html .expressive-code-overrides .expressive-code .copy button div {
5050
--tmLineBrdCol: hsl(222.77deg 38.21% 51.76% / 55.57%);
5151
}
5252

53-
html[data-theme="dark"].dark
53+
html[data-theme="dark"]
5454
.expressive-code-overrides
5555
.expressive-code
5656
.ec-line.mark {

src/ui/docs-layout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { coreEntries } from "solid:collection";
55
import { Pagination } from "~/ui/pagination";
66
import { EditPageLink } from "./edit-page-link";
77
import { PageIssueLink } from "./page-issue-link";
8+
import { useProjectTitle } from "./use-project-title";
89

910
interface DocsLayoutProps {
1011
entries: typeof coreEntries;
@@ -13,6 +14,7 @@ interface DocsLayoutProps {
1314

1415
export const DocsLayout = (props: DocsLayoutProps) => {
1516
const location = useLocation();
17+
const projectTitle = useProjectTitle();
1618

1719
const collection = () =>
1820
location.pathname.includes("/reference/")
@@ -40,7 +42,7 @@ export const DocsLayout = (props: DocsLayoutProps) => {
4042
<Show when={props.entries} keyed>
4143
<>
4244
<Show when={titles()?.title} fallback={<Title>SolidDocs</Title>}>
43-
{(title) => <Title>{`${title()} - SolidDocs`}</Title>}
45+
{(title) => <Title>{`${title()} - ${projectTitle()}`}</Title>}
4446
</Show>
4547
<div id="rr" class="flex relative justify-center">
4648
<article class="w-fit overflow-hidden pb-16 lg:px-5 expressive-code-overrides lg:max-w-none">

src/ui/not-found.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import { Title } from "@solidjs/meta";
22
import { Layout } from "./layout";
33
import { HttpStatusCode } from "@solidjs/start";
44
import { A } from "~/ui/i18n-anchor";
5+
import { useProjectTitle } from "./use-project-title";
56

67
export function NotFound() {
8+
const projectTitle = useProjectTitle();
9+
710
return (
811
<>
9-
<Title>404 - SolidDocs</Title>
12+
<Title>Not Found - {projectTitle()}</Title>
1013
<Layout isError>
1114
<HttpStatusCode code={404} />
1215
<div class="flex flex-col items-center">

src/ui/use-project-title.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { type Accessor, createEffect, createSignal } from "solid-js";
2+
import { useMatch } from "@solidjs/router";
3+
4+
const SOLID_START_TITLE = "SolidStart Docs";
5+
const SOLID_ROUTER_TITLE = "Solid Router Docs";
6+
const SOLID_META_TITLE = "Solid Meta Docs";
7+
const SOLID_TITLE = "Solid Docs";
8+
9+
type ProjectTitle =
10+
| typeof SOLID_START_TITLE
11+
| typeof SOLID_ROUTER_TITLE
12+
| typeof SOLID_META_TITLE
13+
| typeof SOLID_TITLE;
14+
15+
export function useProjectTitle(): Accessor<ProjectTitle> {
16+
const [title, setTitle] = createSignal<ProjectTitle>(SOLID_TITLE);
17+
18+
const isStart = useMatch(() => "/solid-start/*");
19+
const isRouter = useMatch(() => "/solid-router/*");
20+
const isMeta = useMatch(() => "/solid-meta/*");
21+
22+
createEffect(() => {
23+
if (isStart()) {
24+
setTitle(SOLID_START_TITLE);
25+
} else if (isRouter()) {
26+
setTitle(SOLID_ROUTER_TITLE);
27+
} else if (isMeta()) {
28+
setTitle(SOLID_META_TITLE);
29+
} else {
30+
setTitle(SOLID_TITLE);
31+
}
32+
});
33+
34+
return title;
35+
}

0 commit comments

Comments
 (0)