File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,55 @@ Functions can return an object with the normalized matched path and optional par
151151 ]
152152 ```
153153
154+ ## Redirects
155+ Redirects can be built by immediately calling ` push ` or ` replace ` on a router:
156+
157+ === "JSX"
158+ ```jsx
159+ import { ROUTER } from "rvx/router";
160+
161+ {
162+ // Redirect ".../foo" to ".../foo/bar":
163+ match: "/foo",
164+ content: () => ROUTER.current!.replace("/bar"),
165+ }
166+
167+ {
168+ // Redirect ".../foo" to ".../bar":
169+ match: "/foo",
170+ content: () => ROUTER.current!.parent!.replace("/bar"),
171+ }
172+
173+ {
174+ // Redirect ".../foo" to "/bar":
175+ match: "/foo",
176+ content: () => ROUTER.current!.root.replace("/bar"),
177+ }
178+ ```
179+
180+ === "No Build"
181+ ```jsx
182+ import { ROUTER } from "./rvx.router.js";
183+
184+ {
185+ // Redirect ".../foo" to ".../foo/bar":
186+ match: "/foo",
187+ content: () => ROUTER.current.replace("/bar"),
188+ }
189+
190+ {
191+ // Redirect ".../foo" to ".../bar":
192+ match: "/foo",
193+ content: () => ROUTER.current.parent.replace("/bar"),
194+ }
195+
196+ {
197+ // Redirect ".../foo" to "/bar":
198+ match: "/foo",
199+ content: () => ROUTER.current.root.replace("/bar"),
200+ }
201+ ```
202+
154203## Path Normalization
155204Paths are normalized, so that non-empty paths always start with a slash and the root path is represented as an empty string.
156205
You can’t perform that action at this time.
0 commit comments