This repository has been archived on 2020-11-22. You can view files and clone it, but cannot push or open issues or pull requests.
mangareader/frontend/src/router.js
Simon Bruder dda87410b8
Some checks reported errors
continuous-integration/drone/push Build was killed
Set title according to current view
2019-12-07 19:43:15 +00:00

50 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import API from '@/api-client.js'
import Reader from './views/Reader.vue'
import Router from 'vue-router'
import SeriesList from './views/SeriesList.vue'
import VolumeList from './views/VolumeList.vue'
import Vue from 'vue'
Vue.use(Router)
const router = new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
{
path: '/',
name: 'series-list',
component: SeriesList,
meta: {
title: (to, callback) => callback('Home')
}
},
{
path: '/series/:id',
name: 'volume-list',
component: VolumeList,
meta: {
title: (to, callback) => API.getSeriesInfo(to.params.id, info => callback(info.title))
}
},
{
path: '/volume/:id',
name: 'reader',
component: Reader,
meta: {
title: (to, callback) => API.getVolumeInfo(to.params.id, info => callback(info.title))
}
}
]
})
// https://github.com/vuejs/vue-router/issues/914#issuecomment-261461921
router.beforeEach((to, from, next) => {
to.meta.title(to, (title) => {
document.title = `${title} Manga Reader`
})
next()
})
export default router