Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/demonicious/svelte-static-hash-router
A Simple & Easy to use Static page router for Svelte.
https://github.com/demonicious/svelte-static-hash-router
Last synced: 6 days ago
JSON representation
A Simple & Easy to use Static page router for Svelte.
- Host: GitHub
- URL: https://github.com/demonicious/svelte-static-hash-router
- Owner: Demonicious
- License: mit
- Created: 2020-04-13T21:17:28.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-04-13T21:18:47.000Z (over 4 years ago)
- Last Synced: 2023-10-15T16:06:56.064Z (about 1 year ago)
- Language: HTML
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
### Svelte Static Hash Router
A Simple & Easy to use Static page router for Svelte.
#### 1. Installation
It's available on NPM under the name 'svelte-static-hash-router'.
You can Install the package with the command below:`npm i -D svelte-static-hash-router`
#### 2. Usage Example
```jsimport Router from "svelte-static-hash-router/Router.svelte";
import Link from "svelte-static-hash-router/Link.svelte";import Index from "./Components/Index.svelte";
import About from "./Components/About.svelte";
import ErrorComponent from "./Components/ErrorComponent.svelte";
```
The "Router" component needs to have a "routes" prop that is an array of Routes.Each "Route" has a Path & and a Component. Optionally, You may pass "props" to the component which can be accessed with an "export let property_name" statement inside the Component.
The "Link" component needs to have a "to" prop that determines where the Link will go to.
You may specify any attributes for the Anchor tag by passing in a "attributes" prop as shown above.#### 3. Notes
Currently this router can only be used for Static Routes. But I plan on making a Router for dynamic routes very soon.