generouted
Advanced tools
Comparing version 1.10.0 to 1.11.0
{ | ||
"name": "generouted", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "Generated client-side file-based routes for Vite", | ||
@@ -5,0 +5,0 @@ "author": "Omar Elhawary <oedotme@gmail.com> (https://omarelhawary.me)", |
@@ -43,3 +43,3 @@ <br> | ||
- React with [TanStack's React Location](https://react-location.tanstack.com) | ||
- Solid with [Solid Router](https://github.com/solidjs/solid-router) | ||
- Solid with [Solid Router w/ type-safe navigation ๐](https://github.com/solidjs/solid-router) | ||
@@ -111,5 +111,5 @@ ## Getting started | ||
### Solid Router | ||
### Solid Router w/ type-safe navigation ๐ | ||
If you're using Solid, check out their [getting started guide](https://www.solidjs.com/guides/getting-started#try-solid) to start a new project. | ||
In case you don't have a Vite project with Solid and TypeScript, check out this [getting started guide](https://www.solidjs.com/guides/getting-started#try-solid) to start a new project. | ||
@@ -119,5 +119,20 @@ #### Installation | ||
```shell | ||
pnpm add generouted @solidjs/router | ||
pnpm add @generouted/solid-router generouted @solidjs/router | ||
``` | ||
- `generouted` provides the file-based routes | ||
- `@generouted/solid-router` optional but recommended plugin to generates types and type-safe router component/hooks | ||
#### Setup | ||
```ts | ||
// vite.config.ts | ||
import { defineConfig } from 'vite' | ||
import solid from 'vite-plugin-solid' | ||
import generouted from '@generouted/solid-router' | ||
export default defineConfig({ plugins: [solid(), generouted()] }) | ||
``` | ||
#### Usage | ||
@@ -134,2 +149,4 @@ | ||
๐ Check more about type-safe navigation and global modals [in the plugin docs](./plugins/solid-router). | ||
### Adding pages | ||
@@ -304,3 +321,3 @@ | ||
- [Nested layouts](./examples/react-router/nested-layouts) | ||
- [Plugin w/ type-safe navigation](./examples/react-router/plugin) ๐ | ||
- [w/ type-safe navigation plugin](./examples/react-router/plugin) ๐ | ||
@@ -320,3 +337,3 @@ ### TanStack React Router ๐ | ||
- [Basic](./examples/solid-router/basic) | ||
- [w/ type-safe navigation plugin](./examples/solid-router) | ||
@@ -323,0 +340,0 @@ <br> |
@@ -6,3 +6,3 @@ export const patterns = { | ||
slash: [/^index$|\./g, '/'], | ||
optional: [/^-(:?[\w-]+)/g, '$1?'], | ||
optional: [/^-(:?[\w-]+)/, '$1?'], | ||
} as const | ||
@@ -33,3 +33,2 @@ | ||
.replace(...patterns.param) | ||
.replace(...patterns.optional) | ||
.split('/') | ||
@@ -39,3 +38,3 @@ .filter(Boolean) | ||
segments.reduce((parent, segment, index) => { | ||
const path = segment.replace(...patterns.slash) | ||
const path = segment.replace(...patterns.slash).replace(...patterns.optional) | ||
const root = index === 0 | ||
@@ -42,0 +41,0 @@ const leaf = index === segments.length - 1 && segments.length > 1 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
23736
339
224