Skip to content

Instantly share code, notes, and snippets.

@sethvincent
Created September 18, 2016 22:32
Show Gist options
  • Save sethvincent/eda58020eabb121e8f068b77496627db to your computer and use it in GitHub Desktop.
Save sethvincent/eda58020eabb121e8f068b77496627db to your computer and use it in GitHub Desktop.
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