π¬ A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots π
TypeScript browser-extensionchrome-extensiondocumentationfirefox-extensionguide-generatorlocal-firstmanifest-v3privacy-firstproductivityreactscreenshotstep-by-step-guidetutorialtypescriptworkflowwxt
feat: hash-based router for fullview dashboard
Luis Ortiz93f044853cc3
diff --git a/src/fullview/router.ts b/src/fullview/router.tsnew file mode 100644index 0000000..9cd369a--- /dev/null+++ b/src/fullview/router.ts@@ -0,0 +1,46 @@+import { useState, useEffect } from 'react';++export type Route =+ | { page: 'library'; category: 'all' | 'starred' | 'trash' }+ | { page: 'guide'; guideId: string };++function parseHash(hash: string): Route {+ const h = hash.replace(/^#\/?/, '');+ if (h.startsWith('guide/')) {+ const guideId = h.slice(6);+ if (guideId) return { page: 'guide', guideId };+ }+ if (h === 'library/starred') return { page: 'library', category: 'starred' };+ if (h === 'library/trash') return { page: 'library', category: 'trash' };+ return { page: 'library', category: 'all' };+}++export function navigate(route: Route) {+ if (route.page === 'guide') {+ window.location.hash = `#guide/${route.guideId}`;+ } else if (route.category === 'all') {+ window.location.hash = '#library';+ } else {+ window.location.hash = `#library/${route.category}`;+ }+}++export function useRoute(): Route {+ const [route, setRoute] = useState<Route>(() => {+ const params = new URLSearchParams(window.location.search);+ const guideId = params.get('guideId');+ if (guideId) {+ window.history.replaceState(null, '', window.location.pathname + `#guide/${guideId}`);+ return { page: 'guide', guideId };+ }+ return parseHash(window.location.hash);+ });++ useEffect(() => {+ const handler = () => setRoute(parseHash(window.location.hash));+ window.addEventListener('hashchange', handler);+ return () => window.removeEventListener('hashchange', handler);+ }, []);++ return route;+}