├── .github ├── dependabot.yml └── workflows │ └── semantic-release.yml ├── .gitignore ├── LICENSE ├── README.md ├── components └── Navigator.js ├── index.js ├── package-lock.json └── package.json /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | versioning-strategy: lockfile-only 9 | ignore: 10 | - dependency-name: semantic-release 11 | versions: 12 | - 17.3.7 13 | - 17.3.8 14 | - 17.3.9 15 | - 17.4.0 16 | - 17.4.1 17 | -------------------------------------------------------------------------------- /.github/workflows/semantic-release.yml: -------------------------------------------------------------------------------- 1 | name: Semantic Release CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | release: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v1 14 | - uses: actions/setup-node@v1 15 | with: 16 | node-version: 12.x 17 | - run: | 18 | npm install 19 | npm run semantic-release --if-present 20 | env: 21 | CI: true 22 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 23 | NPM_TOKEN: ${{secrets.NPM_TOKEN}} 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 NativeScript-Vue 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NativeScript-Vue-Navigator 2 | 3 | NativeScript-Vue-Navigator is a simple router implementation that is suitable for NativeScript-Vue. 4 | 5 | ## Quick Start 6 | 7 | ```shell 8 | $ npm install --save nativescript-vue-navigator 9 | ``` 10 | 11 | ```diff 12 | // main.js 13 | import Vue from 'nativescript-vue' 14 | ... 15 | + import Navigator from 'nativescript-vue-navigator' 16 | + import {routes} from './routes' 17 | + Vue.use(Navigator, { routes }) 18 | 19 | new Vue({ 20 | - render: h => h('frame', App), 21 | + render: h => h(App), 22 | }).$start() 23 | ``` 24 | 25 | ```js 26 | // routes.js 27 | import HomePage from './components/HomePage' 28 | import LoginPage from './components/LoginPage' 29 | 30 | export const routes = { 31 | '/home': { 32 | component: HomePage, 33 | }, 34 | '/login': { 35 | component: LoginPage, 36 | }, 37 | } 38 | ``` 39 | 40 | ```diff 41 | // App.vue 42 | 45 | ``` 46 | 47 | ### Attaching extra data to a route 48 | 49 | ```diff 50 | // routes.js 51 | import HomePage from './components/HomePage' 52 | import LoginPage from './components/LoginPage' 53 | 54 | export const routes = { 55 | '/home': { 56 | component: HomePage, 57 | + // we are using `meta` as a good practice, but you are free to use something else 58 | + meta: { needsAuth: true } 59 | }, 60 | '/login': { 61 | component: LoginPage, 62 | + meta: { needsAuth: false } 63 | }, 64 | } 65 | ``` 66 | 67 | ```xml 68 | 69 |