-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor nav to not use useSearchParams which blocks SSR
- Loading branch information
1 parent
43f312a
commit d4dcd1f
Showing
4 changed files
with
18 additions
and
52 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
24 changes: 0 additions & 24 deletions
24
web/src/components/site/Navigation/Sidebar/components/NavItem.tsx
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,32 +1,20 @@ | ||
"use client"; | ||
|
||
import { useSearchParams } from "next/navigation"; | ||
import { z } from "zod"; | ||
|
||
import { useGetInfo } from "src/api/openapi/misc"; | ||
import { useSession } from "src/auth"; | ||
|
||
export const QuerySchema = z.object({ | ||
category: z.string().optional(), | ||
}); | ||
export type Query = z.infer<typeof QuerySchema>; | ||
|
||
// NOTE: Everything that involves data fetching here has a suitable fallback. | ||
// Most of the time, components will render <Unready /> but this is the data for | ||
// the navigation so it's a bit more important that we show something always. | ||
|
||
export function useNavigation() { | ||
const query = useSearchParams(); | ||
const { data: infoResult } = useGetInfo(); | ||
const session = useSession(); | ||
|
||
const { category } = QuerySchema.parse(query); | ||
|
||
const title = infoResult?.title ?? "Storyden"; | ||
|
||
return { | ||
isAdmin: session?.admin ?? false, | ||
title, | ||
category, | ||
}; | ||
} |
d4dcd1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
storyden-homepage – ./home
storyden-homepage-southclaws.vercel.app
storyden.org
www.storyden.org
storyden-homepage.vercel.app
storyden-homepage-git-main-southclaws.vercel.app
d4dcd1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
storyden – ./web
storyden.vercel.app
storyden-southclaws.vercel.app
storyden-git-main-southclaws.vercel.app
demo.storyden.org