preact-hashish-router 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Router.d.ts +9 -0
- package/dist/Router.js +5 -3
- package/package.json +1 -1
package/dist/Router.d.ts
CHANGED
|
@@ -2,6 +2,15 @@ import { PropsWithChildren } from "preact/compat";
|
|
|
2
2
|
import { RouterContext } from "./context";
|
|
3
3
|
type RouterProps = PropsWithChildren & {
|
|
4
4
|
type: RouterContext["type"];
|
|
5
|
+
/**
|
|
6
|
+
* Only for `hash` routers.
|
|
7
|
+
*
|
|
8
|
+
* Decide if the initial pathname will be rewrite as the initial hash.
|
|
9
|
+
*
|
|
10
|
+
* `Caution`: This will replace the initial url hash
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
redirect_path_to_hash?: boolean;
|
|
5
14
|
};
|
|
6
15
|
export declare const Router: (props: RouterProps) => import("preact").JSX.Element;
|
|
7
16
|
export {};
|
package/dist/Router.js
CHANGED
|
@@ -44,9 +44,11 @@ export const Router = (props) => {
|
|
|
44
44
|
const [path, query] = get_hash_route().split("?");
|
|
45
45
|
setQuery(query || "");
|
|
46
46
|
setPath(path);
|
|
47
|
-
if (
|
|
48
|
-
location.
|
|
49
|
-
|
|
47
|
+
if (props.redirect_path_to_hash === true) {
|
|
48
|
+
if (location.pathname !== "/") {
|
|
49
|
+
location.hash = location.pathname;
|
|
50
|
+
location.pathname = "";
|
|
51
|
+
}
|
|
50
52
|
}
|
|
51
53
|
hashEffectHandler.effect();
|
|
52
54
|
return () => hashEffectHandler.cleanUp();
|