Skip to content

Commit 8f6e76a

Browse files
authored
Update README.md
1 parent d4467fc commit 8f6e76a

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ export default defineConfig({
4343
For convenience, you may also wish to register aliases for importing the generated files into your application:
4444

4545
```ts
46+
import path from 'path';
47+
4648
export default defineConfig({
4749
// ...
4850
resolve: {
4951
alias: {
50-
"@actions/": "./resources/js/actions",
51-
"@routes/": "./resources/js/routes",
52+
"@": path.resolve(__dirname, "./resources/js"),
5253
},
5354
},
5455
});
@@ -82,15 +83,15 @@ You can safely `.gitignore` the `wayfinder`, `actions`, and `routes` directories
8283
Wayfinder functions return an object that contains the resolved URL and default HTTP method:
8384

8485
```ts
85-
import { show } from "@actions/App/Http/Controllers/PostController";
86+
import { show } from "@/actions/App/Http/Controllers/PostController";
8687

8788
show(1); // { url: "/posts/1", method: "get" }
8889
```
8990

9091
If you just need the URL, or would like to choose a method from the HTTP methods defined on the server, you can invoke additional methods on the Wayfinder generated function:
9192

9293
```ts
93-
import { show } from "@actions/App/Http/Controllers/PostController";
94+
import { show } from "@/actions/App/Http/Controllers/PostController";
9495

9596
show.url(1); // "/posts/1"
9697
show.head(1); // { url: "/posts/1", method: "head" }
@@ -99,7 +100,7 @@ show.head(1); // { url: "/posts/1", method: "head" }
99100
Wayfinder functions accept a variety of shapes for their arguments:
100101

101102
```ts
102-
import { show, update } from "@actions/App/Http/Controllers/PostController";
103+
import { show, update } from "@/actions/App/Http/Controllers/PostController";
103104

104105
// Single parameter action...
105106
show(1);
@@ -117,7 +118,7 @@ update({ post: { id: 1 }, author: { id: 2 } });
117118
If you've specified a key for the parameter binding, Wayfinder will detect this and allow you to pass the value in as a property on an object:
118119

119120
```ts
120-
import { show } from "@actions/App/Http/Controllers/PostController";
121+
import { show } from "@/actions/App/Http/Controllers/PostController";
121122

122123
// Route is /posts/{post:slug}...
123124
show("my-new-post");
@@ -129,7 +130,7 @@ show({ slug: "my-new-post" });
129130
If your controller is an invokable controller, you may simple invoke the imported Wayfinder function directly:
130131

131132
```ts
132-
import StorePostController from "@actions/App/Http/Controllers/StorePostController";
133+
import StorePostController from "@/actions/App/Http/Controllers/StorePostController";
133134

134135
StorePostController();
135136
```
@@ -139,7 +140,7 @@ StorePostController();
139140
You may also import the Wayfinder generated controller definition and invoke its individual methods on the imported object:
140141

141142
```ts
142-
import PostController from "@actions/App/Http/Controllers/PostController";
143+
import PostController from "@/actions/App/Http/Controllers/PostController";
143144

144145
PostController.show(1);
145146
```
@@ -152,7 +153,7 @@ PostController.show(1);
152153
Wayfinder can also generate methods for your application's named routes as well:
153154

154155
```ts
155-
import { show } from "@routes/post";
156+
import { show } from "@/routes/post";
156157

157158
// Named route is `post.show`...
158159
show(1); // { url: "/posts/1", method: "get" }
@@ -169,7 +170,7 @@ php artisan wayfinder:generate --with-form
169170
Then, you can use the `.form` variant to generate `<form>` object attributes automatically:
170171

171172
```tsx
172-
import { store, update } from "@actions/App/Http/Controllers/PostController";
173+
import { store, update } from "@/actions/App/Http/Controllers/PostController";
173174

174175
const Page = () => (
175176
<form {...store.form()}>
@@ -189,7 +190,7 @@ const Page = () => (
189190
If your form action supports multiple methods and would like to specify a method, you can invoke additional methods on the `form`:
190191

191192
```tsx
192-
import { store, update } from "@actions/App/Http/Controllers/PostController";
193+
import { store, update } from "@/actions/App/Http/Controllers/PostController";
193194

194195
const Page = () => (
195196
<form {...update.form.put(1)}>
@@ -204,7 +205,7 @@ const Page = () => (
204205
All Wayfinder methods accept an optional, final `options` argument to which you may pass a `query` object. This object can be used to append query parameters onto the resulting URL:
205206

206207
```ts
207-
import { show } from "@actions/App/Http/Controllers/PostController";
208+
import { show } from "@/actions/App/Http/Controllers/PostController";
208209

209210
const options = {
210211
query: {
@@ -222,7 +223,7 @@ show.form.head(1, options); // { action: "/posts/1?page=1&sort_by=name&_method=H
222223
You can also merge with the URL's existing parameters by passing a `mergeQuery` object instead:
223224

224225
```ts
225-
import { show } from "@actions/App/Http/Controllers/PostController";
226+
import { show } from "@/actions/App/Http/Controllers/PostController";
226227

227228
// window.location.search = "?page=1&sort_by=category&q=shirt"
228229

@@ -239,7 +240,7 @@ show.url(1, options); // "/posts/1?page=2&sort_by=name&q=shirt"
239240
If you would like to remove a parameter from the resulting URL, define the value as `null` or `undefined`:
240241

241242
```ts
242-
import { show } from "@actions/App/Http/Controllers/PostController";
243+
import { show } from "@/actions/App/Http/Controllers/PostController";
243244

244245
// window.location.search = "?page=1&sort_by=category&q=shirt"
245246

@@ -261,7 +262,7 @@ When using [Inertia](https://inertiajs.com), you can pass the result of a Wayfin
261262

262263
```ts
263264
import { useForm } from "@inertiajs/react";
264-
import { store } from "@actions/App/Http/Controllers/PostController";
265+
import { store } from "@/actions/App/Http/Controllers/PostController";
265266

266267
const form = useForm({
267268
name: "My Big Post",
@@ -276,7 +277,7 @@ You may also use Wayfinder in conjunction with Inertia's `Link` component:
276277

277278
```tsx
278279
import { Link } from "@inertiajs/react";
279-
import { show } from "@actions/App/Http/Controllers/PostController";
280+
import { show } from "@/actions/App/Http/Controllers/PostController";
280281

281282
const Nav = () => <Link href={show(1)}>Show me the first post</Link>;
282283
```

0 commit comments

Comments
 (0)