From 45f156c37ac1b6e1b77ef08971ba33fa32455e3b Mon Sep 17 00:00:00 2001 From: KishiTheMechanic Date: Wed, 30 Oct 2024 11:24:15 +0100 Subject: [PATCH] better usePathname --- README.md | 6 +++++- deno.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 337d731..6a548cb 100644 --- a/README.md +++ b/README.md @@ -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 } } ``` diff --git a/deno.json b/deno.json index 77f3122..2eb6004 100644 --- a/deno.json +++ b/deno.json @@ -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",