forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/api-skip-prebuild-try-2' of github.com:dac09/redwo…
…od into feat/api-skip-prebuild-try-2 * 'feat/api-skip-prebuild-try-2' of github.com:dac09/redwood: chore(ci): retry detectChanges on error (redwoodjs#9769) useRouteName (redwoodjs#9758) docker.md: Fix web path (redwoodjs#9768)
- Loading branch information
Showing
8 changed files
with
80 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useRouterState } from './router-context' | ||
|
||
import { routes } from '.' | ||
import type { AvailableRoutes } from '.' | ||
|
||
// This needs to be a function so that we can use codegen to provide better | ||
// types in a user's project (see web-routerRoutes.d.ts) | ||
/** Gets the name of the current route (as defined in your Routes file) */ | ||
export function useRouteName() { | ||
const routerState = useRouterState() | ||
const routeName = routerState.activeRouteName | ||
|
||
if (isAvailableRouteName(routeName)) { | ||
return routeName | ||
} | ||
|
||
return undefined | ||
} | ||
|
||
function isAvailableRouteName(name: unknown): name is keyof AvailableRoutes { | ||
return typeof name === 'string' && Object.keys(routes).includes(name) | ||
} |