Skip to content

Commit

Permalink
better usePathname
Browse files Browse the repository at this point in the history
  • Loading branch information
KishiTheMechanic committed Oct 30, 2024
1 parent cd12e83 commit 45f156c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,14 @@ export function useTranslation() {
```tsx:./hooks/i18n/usePathname.ts
import { useAtom } from 'fresh-atom'
import { stateAtom } from '@/islands/layouts/StateShareLayer.tsx'
import { useCallback } from 'preact/hooks'

export function usePathname() {
const [state] = useAtom(stateAtom)
return state.path
const isActivePath = useCallback((path: string) => {
return state.path === path
}, [state.path])
return { pathname: state.path, isActivePath }
}
```

Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elsoul/fresh-i18n",
"version": "1.1.1",
"version": "1.1.2",
"description": "A simple and flexible internationalization (i18n) plugin for Deno's Fresh framework.",
"runtimes": ["deno", "browser"],
"exports": "./mod.ts",
Expand Down

0 comments on commit 45f156c

Please sign in to comment.