diff --git a/packages/docs/src/routes/docs/(qwikcity)/action/index.mdx b/packages/docs/src/routes/docs/(qwikcity)/action/index.mdx index 75ab808f635..4cd6d2d806e 100644 --- a/packages/docs/src/routes/docs/(qwikcity)/action/index.mdx +++ b/packages/docs/src/routes/docs/(qwikcity)/action/index.mdx @@ -31,7 +31,7 @@ created_at: '2023-03-20T23:45:13Z' # `routeAction$()` -`routeAction$()` is used to define functions called actions that execute exclusively on the server, and only when explicitly called. Actions can have side effects such as writing to a database or sending an email, that cannot happen during client-side rendering. This makes them ideal for handling form submissions, performing operations with side effects, and then returning data back to the client/browser where it can be used to update the UI. +`routeAction$()` is used to define functions called actions that execute exclusively on the server, and only when explicitly called. Actions can have side effects such as writing to a database or sending an email, that cannot happen during client-side rendering. This makes them ideal for handling form submissions, performing operations with side effects, and then returning data back to the client/browser where it can be used to update the UI. Actions can be declared using `routeAction$()` or `globalAction$()` exported from `@builder.io/qwik-city`. @@ -256,7 +256,7 @@ Please refer to the [Zod documentation](https://zod.dev/) for more information o ### Advanced event based validation -The constructor of ```zod$``` can also take a function, as the first argument is zod itself, so you can use this directly to build the schema. +The constructor of ```zod$``` can also take a function, as the first argument is zod itself, so you can use this directly to build the schema. The second parameter is the RequestEvent to construct an event-based zod schema. Especially in combination with ```refine``` and ```superRefine``` in zod, the only limit is your imagination. @@ -264,7 +264,7 @@ Especially in combination with ```refine``` and ```superRefine``` in zod, the on ```tsx {5-5} /ev/#a title="Advanced event based validation" export const useAddUser = routeAction$( async (user) => { - // The "user" is still strongly typed, but firstname + // The "user" is still strongly typed, but firstname // is now optional: { firstName?: string | undefined, lastName: string } const userID = await db.users.add({ firstName: user.firstName, @@ -341,7 +341,7 @@ export const useAddUser = routeAction$( Failures are stored in the `action.value` property, just like the success value. However, the `action.value.failed` property is set to `true` when the action fails. Futhermore, failure messages can be found in the `fieldErrors` object according to properties defined in your Zod schema. -The `fieldErrors` become a dot notation object. See [Complex forms](/docs/advanced/complex-forms) for more information. +The `fieldErrors` become a dot notation object. See [Complex forms](/docs/advanced/complex-forms) for more information. ```tsx import { component$ } from '@builder.io/qwik'; @@ -397,7 +397,7 @@ It's recommended to start with `routeAction$()`. Use `globalAction$()` only when `routeAction$()` can only be declared inside the `src/routes` folder, in a `layout.tsx` or `index.tsx` file, and they MUST be exported, just like a `routeLoader$()`. Since `routeAction$()`s are only accessible within the route it's declared, they are recommended when the action needs to access some user data, or it's a protected route. Think about it like a "private" action. -> If you want to manage common reusable routeAction$() it is essential that this function is re-exported from within 'layout.tsx' or 'index.tsx file of the existing route otherwise it will not run or throw exception. For more information [check the cookbook](/docs/cookbook/re-exporting-loaders/index.mdx). +> If you want to manage common reusable routeAction$() it is essential that this function is re-exported from within 'layout.tsx' or 'index.tsx file of the existing route otherwise it will not run or throw exception. For more information [check this section](/docs/(qwikcity)/re-exporting-loaders/index.mdx). ```tsx title="src/routes/form/index.tsx" import { routeAction$ } from '@builder.io/qwik-city'; diff --git a/packages/docs/src/routes/docs/cookbook/re-exporting-loaders/index.mdx b/packages/docs/src/routes/docs/(qwikcity)/re-exporting-loaders/index.mdx similarity index 100% rename from packages/docs/src/routes/docs/cookbook/re-exporting-loaders/index.mdx rename to packages/docs/src/routes/docs/(qwikcity)/re-exporting-loaders/index.mdx diff --git a/packages/docs/src/routes/docs/(qwikcity)/route-loader/index.mdx b/packages/docs/src/routes/docs/(qwikcity)/route-loader/index.mdx index 3e41c10f83a..e53b5db14c4 100644 --- a/packages/docs/src/routes/docs/(qwikcity)/route-loader/index.mdx +++ b/packages/docs/src/routes/docs/(qwikcity)/route-loader/index.mdx @@ -24,7 +24,7 @@ Route Loaders load data in the server so it becomes available to use inside Qwik Route Loaders can only be declared inside the `src/routes` folder, in a `layout.tsx` or `index.tsx` file, and they MUST be exported. -> If you want to manage common reusable routeLoaders$ it is essential that this function is re-exported from within 'layout.tsx' or 'index.tsx file of the existing route otherwise it will not run or throw exception. For more information [check the cookbook](/docs/cookbook/re-exporting-loaders/index.mdx). +> If you want to manage common reusable routeLoaders$ it is essential that this function is re-exported from within 'layout.tsx' or 'index.tsx file of the existing route otherwise it will not run or throw exception. For more information [check this section](/docs/(qwikcity)/re-exporting-loaders/index.mdx). ```tsx /routeLoader$/ /useProductData/#a title="src/routes/product/[productId]/index.tsx" import { component$ } from '@builder.io/qwik'; @@ -238,5 +238,3 @@ export default component$(() => { Route Loaders are executed on the server, after every navigation. This means that they are executed every time a user navigates to a page in an SPA or MPA, and they are executed even if the user is navigating to the same page. Loaders execute after the Qwik Middleware handlers (`onRequest`, `onGet`, `onPost`, etc), and before the Qwik Components are rendered. This allows the loaders to start fetching data as soon as possible, reducing latency. - - diff --git a/packages/docs/src/routes/docs/menu.md b/packages/docs/src/routes/docs/menu.md index 5775860aa50..6bcb34502cb 100644 --- a/packages/docs/src/routes/docs/menu.md +++ b/packages/docs/src/routes/docs/menu.md @@ -30,6 +30,7 @@ - [Endpoints]() - [Middleware]() - [server$]() +- [Re-exporting loaders](/docs/(qwikcity)/re-exporting-loaders/index.mdx) - [Caching]() - [HTML attributes]() - [API reference]() @@ -46,7 +47,6 @@ - [NavLink](/docs/cookbook/nav-link/index.mdx) - [Node Docker deploy](/docs/cookbook/node-docker-deploy/index.mdx) - [Portals](/docs/cookbook/portals/index.mdx) -- [Re-exporting loaders](/docs/cookbook/re-exporting-loaders/index.mdx) - [Streaming loaders](/docs/cookbook/streaming-deferred-loaders/index.mdx) - [Sync events w state](/docs/cookbook/sync-events/index.mdx) - [Theme Managment](/docs/cookbook/theme-management/index.mdx)