@join-com/routes
v1.3.2
Published
Routes generator lib for JOIN
Downloads
10
Maintainers
Keywords
Readme
JOIN Routes
Routes generator lib for JOIN
Install
yarn add @join-com/routes
Usage
import { makeRoutes } from '@join-com/routes'
type RouteNames = 'root' | 'dashboard'
const routes = [
{
name: 'root',
pattern: '/'
},
{
name: 'root',
locale: 'de-de',
pattern: '/de-de'
},
{
name: 'showJob',
pattern: '/job/:jobId'
},
{
name: 'showJob',
locale: 'de-de',
pattern: '/de-de/job/:jobId'
}
]
const appRoutes = makeRoutes<RouteNames>({
defaultLocale: 'en-us',
routes
})
const rootUrl = appRoutes('root')()
const deRootUrl = appRoutes('root')({ locale: 'de-de' })
const jobUrl = appRoutes.showJob({ jobId: 1234 })
const deJobUrl = appRoutes.showJob({ locale: 'de-de', jobId: 1234 })