GithubHelp home page GithubHelp logo

svelte-app-router's Introduction

Svelte App Router

A simple router for your Single Page Application.

JavaScript Style Guide

Features

  • Hash based routing
  • Data can be set for components when declaring routes
  • Querystring parameters are passed to component when mounted (optional)
  • No special <link> components needed, just use standard <a>.

Installation

npm install --save svelte-app-router

Usage:

Routes should be specified as on object where each key is a route, and each value is an array containing a component as the first element and optionally an object with data for that component as the second element.

<!-- Links. These can be here or anywhere else in your app. -->
<a href="#/home">Home</a>
<a href="#/contact">Contact</a>
<a href="#/notfound">Does not exist</a>

<!-- The Router component. Content between Router start and end tag will be 
     shown in case of navigation to a non-existing route.-->
<Router routes={routes}>
  <div class="error">
    Houston, we have a problem! This page was not found.
  </div>
</Router>

<script>
  import Router from 'svelte-app-router'
  import Home from './pages/Home.html'
  import Contact from './pages/Contact.html'

  export let routes: {
    '/': [Home, {message: 'from "/" path'}],
    '/home' [Home, {message: 'from "/home" path'}]
    '/contact': [Contact]
  }

</script>

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Credits

License

MIT

svelte-app-router's People

Contributors

coussej avatar factry-desmedl avatar pielambr avatar vereecw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

svelte-app-router's Issues

Fails with rollup and uglify

Hi by simply installing the npm and including

import Router from 'svelte-app-router';

In my component, it then fails to build with the following error:

[!] (uglify plugin) Error: Error transforming bundle with 'uglify' plugin: Unexpected token: punc (,)
Error: Error transforming bundle with 'uglify' plugin: Unexpected token: punc (,)
  at error (/Users/jp/Documents/Arduino/libraries/KGB/node_modules/rollup/dist/rollup.js:185:14)
  at Promise.resolve.then.then.catch.err 
(/Users/jp/Documents/Arduino/libraries/KGB/node_modules/rollup/dist/rollup.js:9482:5)

Here's the NPM info:

"babel-core": "^6.26.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.6.1",
"lodash": "^4.17.4",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^8.2.1",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-svelte": "^3.1.0",
"rollup-plugin-uglify": "^2.0.1",
"rollup-watch": "^4.3.1",
"svelte": "^1.40.2",
"svelte-cli": "^1.4.0",
"uglify-js": "^3.1.3",
"zepto": "^1.2.0"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.