Created
September 18, 2016 22:32
-
-
Save sethvincent/eda58020eabb121e8f068b77496627db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var choo = require('choo') | |
var html = require('choo/html') | |
var app = choo() | |
app.router(function (route) { | |
return [ | |
route('/', home) | |
route('/:page', page) | |
] | |
}) | |
app.start() | |
function home (state, prev, send) { | |
return html`<h1>home</h1>` | |
} | |
function page (state, prev, send) { | |
var pagename = state.params.page | |
// can also access state.location.pathname which mirrors window.location.pathname | |
return html`<h1>${pagename}</h1>` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment