import { createRouter, createWebHistory } from 'vue-router'

const routes = [
    {
        path: '/',
        component: () => import('@/layouts/MainLayout.vue'),
        children: [
            {
                path: '',
                name: 'home',
                component: () => import('@/views/ArticleList.vue'),
                meta: { keepAlive: true }
            },
            {
                path: 'purchased',
                name: 'purchased',
                component: () => import('@/views/PurchasedArticles.vue')
            },
            {
                path: 'profile',
                name: 'profile',
                component: () => import('@/views/UserProfile.vue')
            }
        ]
    },
    {
        path: '/posts/:id',
        name: 'article-detail',
        component: () => import('@/views/ArticleDetail.vue')
    }
]

export const router = createRouter({
    history: createWebHistory(),
    routes
})
