22 lines
407 B
TypeScript
22 lines
407 B
TypeScript
import { createContext, useContext, type ReactNode } from "react"
|
|
|
|
const PathnameContext = createContext("/")
|
|
|
|
export function PathnameProvider({
|
|
children,
|
|
pathname,
|
|
}: {
|
|
children: ReactNode
|
|
pathname: string
|
|
}) {
|
|
return (
|
|
<PathnameContext.Provider value={pathname}>
|
|
{children}
|
|
</PathnameContext.Provider>
|
|
)
|
|
}
|
|
|
|
export function usePathname() {
|
|
return useContext(PathnameContext)
|
|
}
|