From 0c6c6dd938c4527f4a2d1c35527c79ff74be3eb7 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Thu, 5 Sep 2019 13:47:16 -0600 Subject: [PATCH] Improve Choo routing for viewmanager --- src/index.js | 2 ++ src/views/manager.js | 16 +++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index e01aa5f..2be2c2d 100644 --- a/src/index.js +++ b/src/index.js @@ -39,5 +39,7 @@ app.use((state, emitter) => { // which is given the app's state from above and the emitter.emit method that // triggers the app's emitter listeners. app.route('/', viewManager); +app.route('/:page', viewManager); +app.route('/404', viewManager); app.mount('body'); // Overwrite the `` tag with the content of the Choo app \ No newline at end of file diff --git a/src/views/manager.js b/src/views/manager.js index a57fd95..63c88ec 100644 --- a/src/views/manager.js +++ b/src/views/manager.js @@ -7,10 +7,7 @@ export const viewManager = (state, emit) => { // In viewManager all we are doing is checking the app's state // and passing the state and emit to the relevant view. let htmlContent = html`
loading
`; - if (state.query.hasOwnProperty('search')) { - state.currentView = 'search'; // Override view if there's a search query - } - switch (state.currentView) { + switch (state.params.page) { case 'home': default: { htmlContent = homeView(state, emit); @@ -37,11 +34,12 @@ export const viewManager = (state, emit) => {