Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
123 additions
and
72 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Configure Routes | ||
|
||
<Environment type="client" /> | ||
|
||
Add your pages to the Slidev app. | ||
|
||
## Usage | ||
|
||
Create `./setup/routes.ts` with the following content: | ||
|
||
```ts | ||
import { defineRoutesSetup } from '@slidev/types' | ||
|
||
export default defineRoutesSetup((routes) => { | ||
return [ | ||
...routes, | ||
{ | ||
path: '/my-page', | ||
component: () => import('../pages/my-page.vue'), | ||
}, | ||
] | ||
}) | ||
``` | ||
|
||
Learn more about routes in the [Vue Router documentation](https://router.vuejs.org/). |
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router' | ||
import configs from '#slidev/configs' | ||
import setups from '#slidev/setups/routes' | ||
|
||
export default function setupRoutes() { | ||
const routes: RouteRecordRaw[] = [] | ||
|
||
if (__SLIDEV_FEATURE_PRESENTER__) { | ||
function passwordGuard(to: RouteLocationNormalized) { | ||
if (!configs.remote || configs.remote === to.query.password) | ||
return true | ||
if (configs.remote && to.query.password === undefined) { | ||
// eslint-disable-next-line no-alert | ||
const password = prompt('Enter password') | ||
if (configs.remote === password) | ||
return true | ||
} | ||
if (to.params.no) | ||
return { path: `/${to.params.no}` } | ||
return { path: '' } | ||
} | ||
|
||
routes.push( | ||
{ | ||
name: 'entry', | ||
path: '/entry', | ||
component: () => import('../pages/entry.vue'), | ||
}, | ||
{ | ||
name: 'overview', | ||
path: '/overview', | ||
component: () => import('../pages/overview.vue'), | ||
}, | ||
{ | ||
name: 'notes', | ||
path: '/notes', | ||
component: () => import('../pages/notes.vue'), | ||
beforeEnter: passwordGuard, | ||
}, | ||
{ | ||
name: 'presenter', | ||
path: '/presenter/:no', | ||
component: () => import('../pages/presenter.vue'), | ||
beforeEnter: passwordGuard, | ||
}, | ||
{ | ||
path: '/presenter', | ||
redirect: { path: '/presenter/1' }, | ||
}, | ||
) | ||
} | ||
|
||
if (__SLIDEV_HAS_SERVER__) { | ||
routes.push( | ||
{ | ||
name: 'print', | ||
path: '/print', | ||
component: () => import('../pages/print.vue'), | ||
}, | ||
{ | ||
path: '/presenter/print', | ||
component: () => import('../pages/presenter/print.vue'), | ||
}, | ||
) | ||
} | ||
|
||
routes.push( | ||
{ | ||
name: 'play', | ||
path: '/:no', | ||
component: () => import('../pages/play.vue'), | ||
}, | ||
{ | ||
path: '', | ||
redirect: { path: '/1' }, | ||
}, | ||
) | ||
|
||
return setups.reduce((routes, setup) => setup(routes), routes) | ||
} |
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
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
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