Skip to content

Commit 3d5be70

Browse files
committed
.
1 parent a47c7b0 commit 3d5be70

File tree

4 files changed

+47
-13
lines changed

4 files changed

+47
-13
lines changed

components/app-sidebar.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,18 @@ import { FadeIn } from "@/components/animation/fade-in"
3232

3333

3434
function PageSidebar() {
35-
const { content } = useSidebar()
36-
if (content != null) {
35+
const { content_projecct, content_page } = useSidebar()
36+
if (content_projecct != null) {
3737
return (
3838
<SidebarMenu className="mb-12 px-8 text-xs overflow-y-scroll no-scrollbar">
39-
<span className="font-bold p-2 select-none text-foreground/50">
40-
This Page
41-
</span>
42-
{content.map((item) => (
39+
{
40+
content_page != null && (
41+
<span className="font-bold p-2 select-none text-foreground/50">
42+
This Page
43+
</span>
44+
)
45+
}
46+
{content_projecct.map((item) => (
4347
<Link key={item.text} href={"#" + item.id} className="p-2 rounded-sm hover:bg-o-blue/3 select-none">
4448
{item.text}
4549
</Link>
@@ -56,7 +60,7 @@ function PageSidebar() {
5660

5761
export function AppSidebar() {
5862

59-
const { content } = useSidebar()
63+
const { content_page } = useSidebar()
6064

6165
return (
6266
<FadeIn>
@@ -80,7 +84,7 @@ export function AppSidebar() {
8084

8185

8286
{
83-
content == null && (
87+
content_page != null && (
8488

8589
<SidebarMenu className="mb-12 px-8 text-xs overflow-y-scroll no-scrollbar">
8690

components/ui/sidebar.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"use client"
22

33
import { usePathname } from 'next/navigation'
4-
import { pageNavigator } from '@/data/pagenavigator'
4+
import { NavigatorProject } from '@/data/navigator-project'
5+
import { NavigatorPage } from '@/data/navigator-page'
56

67
import * as React from "react"
78
import { Slot } from "@radix-ui/react-slot"
@@ -43,7 +44,8 @@ type SidebarContextProps = {
4344
setOpenMobile: (open: boolean) => void
4445
isMobile: boolean
4546
toggleSidebar: () => void
46-
content: { text: string; id: string }[] | null
47+
content_projecct: { text: string; id: string }[] | null
48+
content_page: { text: string; id: string }[] | null
4749
}
4850

4951
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
@@ -118,7 +120,9 @@ function SidebarProvider({
118120
const state = open ? "expanded" : "collapsed"
119121

120122
const pathname = usePathname()
121-
const content = pathname.toLowerCase() in pageNavigator ? pageNavigator[pathname.toLowerCase()] : null
123+
const content_projecct = pathname.toLowerCase() in NavigatorProject ? NavigatorProject[pathname.toLowerCase()] : null
124+
const content_page = pathname.toLowerCase() in NavigatorPage ? NavigatorPage[pathname.toLowerCase()] : null
125+
122126

123127
const contextValue = React.useMemo<SidebarContextProps>(
124128
() => ({
@@ -129,7 +133,8 @@ function SidebarProvider({
129133
openMobile,
130134
setOpenMobile,
131135
toggleSidebar,
132-
content,
136+
content_projecct,
137+
content_page,
133138
}),
134139
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
135140
)

data/navigator-page.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export const NavigatorPage: {
2+
[page: string]: {
3+
text: string;
4+
id: string;
5+
}[]
6+
} = {
7+
"/team": [
8+
{
9+
text: "Scholar",
10+
id: "scholar",
11+
},
12+
{
13+
text: "Ph.D.",
14+
id: "phd",
15+
},
16+
{
17+
text: "Intern",
18+
id: "intern",
19+
},
20+
{
21+
text: "Alumni",
22+
id: "alumni",
23+
},
24+
],
25+
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const pageNavigator: {
1+
export const NavigatorProject: {
22
[page: string]: {
33
text: string;
44
id: string;

0 commit comments

Comments
 (0)