@ossy/router-react 0.0.1-beta.3 → 0.0.1
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/package.json +6 -4
- package/src/router-react.tsx +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/router-react",
|
|
3
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"repository": "github:ossy-se/packages",
|
|
4
5
|
"description": "React router built for server side rendering and multi-language support with localized paths",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"react",
|
|
@@ -13,13 +14,14 @@
|
|
|
13
14
|
"prerendering",
|
|
14
15
|
"href",
|
|
15
16
|
"anchor",
|
|
16
|
-
"server"
|
|
17
|
+
"server",
|
|
18
|
+
"pages"
|
|
17
19
|
],
|
|
18
|
-
"version": "0.0.1-beta.3",
|
|
19
20
|
"source": "src/index.js",
|
|
20
21
|
"type": "module",
|
|
21
22
|
"main": "build/cjs/index.js",
|
|
22
23
|
"module": "build/esm/index.js",
|
|
24
|
+
"license": "MIT License",
|
|
23
25
|
"author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
|
|
24
26
|
"scripts": {
|
|
25
27
|
"build": "rollup -c rollup.config.js",
|
|
@@ -58,7 +60,7 @@
|
|
|
58
60
|
"tslib": "^2.8.1"
|
|
59
61
|
},
|
|
60
62
|
"peerDependencies": {
|
|
61
|
-
"@ossy/router": "0.0.1
|
|
63
|
+
"@ossy/router": "^0.0.1",
|
|
62
64
|
"react": "^19.0.0"
|
|
63
65
|
}
|
|
64
66
|
}
|
package/src/router-react.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import React, { createContext, useContext, useCallback } from 'react'
|
|
3
|
-
import { MultiLanguagePage, Router as
|
|
3
|
+
import { MultiLanguagePage, Router as BaseRouter, RouterOptions, SingleLanguagePage, Page as _Page } from '@ossy/router'
|
|
4
4
|
|
|
5
5
|
export const RouterContext = createContext({
|
|
6
6
|
pages: [] as RouterPage[],
|
|
@@ -48,7 +48,7 @@ export const Router = <T extends RouterPage>({
|
|
|
48
48
|
const isMultiLanguage = supportedLanguages.length > 1 && !!defaultLanguage
|
|
49
49
|
const potentialLanguage = pathname.split('/')[1] || ''
|
|
50
50
|
const language = supportedLanguages.includes(potentialLanguage) ? potentialLanguage : defaultLanguage
|
|
51
|
-
const router =
|
|
51
|
+
const router = BaseRouter.of<T>({ pages, defaultLanguage, supportedLanguages })
|
|
52
52
|
const params = router.getParamsFromUrl(href)
|
|
53
53
|
const searchParams = new URLSearchParams(search)
|
|
54
54
|
|