Skip to content

Commit e9dab51

Browse files
committed
feat(index): support template query param
This adds a check for the `template` query param on the index page and automatically navigates to the Template.
1 parent 0ca4c35 commit e9dab51

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

site/src/pages/index.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { FC } from "react"
2-
import { Navigate } from "react-router-dom"
2+
import { Navigate, useSearchParams } from "react-router-dom"
33

44
export const IndexPage: FC = () => {
5-
// TODO@jsjoeio - here's what we need to do:
6-
/*
7-
1. check query params for template
8-
2. if none, navigate to /workspaces
9-
3. if some, navigate to /templates/<template>
10-
*/
5+
const [searchParams, _] = useSearchParams();
6+
const template = searchParams.get("template")
7+
8+
if (template) {
9+
return <Navigate to={`/templates/${template}`} replace />
10+
}
11+
1112
return <Navigate to="/workspaces" replace />
1213
}

0 commit comments

Comments
 (0)