docs: add example for conditional redirects in routing

This commit is contained in:
SkyZeroZx
2026-04-21 20:44:15 -05:00
committed by Jessica Janiuk
parent 544d084c34
commit ea3097c774
@@ -38,6 +38,24 @@ Use `redirectTo` to point one path to another.
{ path: 'blog', component: Blog },
```
### Conditional Redirects
Pass a function to `redirectTo` to apply logic when redirecting.
```ts
{
path: 'restaurant/:location/menu',
redirectTo: ({ params }) => {
const base = `/restaurant/${params['location']}/menu`;
const hour = new Date().getHours();
if (hour < 11) return `${base}/breakfast`;
if (hour < 17) return `${base}/lunch`;
return `${base}/dinner`;
},
},
```
## Page Titles
Associate titles with routes for accessibility. Titles can be static or dynamic (via `ResolveFn` or a custom `TitleStrategy`).