Spookie/assets/js/router/index.js

87 lines
1.6 KiB
JavaScript
Raw Normal View History

2022-05-11 14:48:04 +02:00
import { createRouter, createWebHistory } from 'vue-router'
import LoginForm from '@/components/LoginForm'
import Quotes from '@/components/quotes'
2022-05-23 16:25:55 +02:00
import Pages from '@/components/pages/PagesIndex'
2022-05-11 14:48:04 +02:00
import PagesEdit from '@/components/pages/edit'
import ProjectsList from '@/components/projects'
import ProjectsDetails from '@/components/projects/ProjectDetails'
2022-05-23 16:25:55 +02:00
import BlogIndex from '@/components/blog/BlogIndex'
import BlogPost from '@/components/blog/BlogPost'
2022-05-11 14:48:04 +02:00
import ProfileView from '@/components/users/ProfileView'
2022-05-23 16:25:55 +02:00
import TheAbout from '@/components/TheAbout'
2022-05-11 14:48:04 +02:00
import NotFound from '@/components/NotFound'
2022-05-06 13:52:18 +02:00
2022-05-11 14:48:04 +02:00
const routes = [
{
path: '/',
name: 'Home',
component: Quotes
},
2022-05-23 16:25:55 +02:00
{
path: '/about',
name: 'About',
component: TheAbout
},
2022-05-11 14:48:04 +02:00
{
path: '/form_login',
name: 'LoginForm',
component: LoginForm
},
{
path: '/projects',
name: 'Projects',
component: ProjectsList
},
{
path: '/projects/:id',
name: 'ProjectDetails',
component: ProjectsDetails
},
2022-05-23 16:25:55 +02:00
{
path: '/blog',
name: 'Blog',
component: BlogIndex
},
{
path: '/blog/post/:id',
name: 'BlogPost',
component: BlogPost
},
2022-05-11 14:48:04 +02:00
{
path: '/pages/:slug',
name: 'Pages',
component: Pages,
props: true
},
{
path: '/pages/edit/:slug',
component: PagesEdit,
meta: { requiredAuth: true }
},
{
path: '/profile/:username?',
name: 'Profile',
component: ProfileView
},
{
path: '/:pathMatch(.*)*',
name: 'NotFound',
component: NotFound
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
2022-05-23 16:25:55 +02:00
/*
2022-05-11 14:48:04 +02:00
router.beforeEach((to) => {
if (to.meta.requiredAuth && !window.user) {
return { name: 'LoginForm' }
}
})
2022-05-23 16:25:55 +02:00
*/
2022-05-11 14:48:04 +02:00
export default router