diff --git a/README.md b/README.md index 455bb63..032b33f 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,9 @@ yarn add svelte-router import Welcome from './Welcome.html' import Animal from './Animal.html' + // import custom (browser) history + import history from './history' + const { createRouter, RouterLink } = SvelteRouter const router = createRouter({ @@ -58,7 +61,7 @@ yarn add svelte-router } } } - }) + }, history) export default { oncreate () { diff --git a/build/index.html b/build/index.html index 1a5d163..8b88c1e 100644 --- a/build/index.html +++ b/build/index.html @@ -10,6 +10,6 @@
- + diff --git a/example/app.html b/example/app.html index a6ffe44..3ce13f9 100644 --- a/example/app.html +++ b/example/app.html @@ -15,6 +15,9 @@ import Hello from './Hello.html' import NotFound from './NotFound.html' + // import custom (browser) history + import history from './history' + const { createRouter, RouterLink } = SvelteRouter const store = new Store({ @@ -39,7 +42,7 @@ }, }, default: NotFound - }) + }, history) createRouter.listen(() => { console.log('router changed') }) diff --git a/src/utils/history.js b/example/history.js similarity index 50% rename from src/utils/history.js rename to example/history.js index b30cb25..1109eca 100644 --- a/src/utils/history.js +++ b/example/history.js @@ -1,4 +1,4 @@ -import createHistory from 'history/createHashHistory' +import createHistory from 'history/createBrowserHistory' const history = createHistory() diff --git a/rollup.config.js b/rollup.config.js index 404b38a..96877b9 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -45,6 +45,7 @@ if (process.env.NODE_ENV === 'production') { config.input = './example/main.js' config.plugins.unshift( serve({ + historyApiFallback: true, contentBase: ['lib', 'build'] }), livereload('release') diff --git a/src/components/RouterLink.html b/src/components/RouterLink.html index 8595e5a..fe0225b 100644 --- a/src/components/RouterLink.html +++ b/src/components/RouterLink.html @@ -3,7 +3,6 @@