mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: support template query param in index
This adds support to navigate directly to a template from the index by using the `?template=<name>` query param.
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import { FC } from "react"
|
||||
import { Navigate } from "react-router-dom"
|
||||
import { Navigate, useSearchParams } from "react-router-dom"
|
||||
|
||||
export const IndexPage: FC = () => {
|
||||
const [searchParams, _] = useSearchParams()
|
||||
const template = searchParams.get("template")
|
||||
|
||||
if (template) {
|
||||
return <Navigate to={`/templates/${template}`} replace />
|
||||
}
|
||||
|
||||
return <Navigate to="/workspaces" replace />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user