Skip to content
Snippets Groups Projects
Select Git revision
  • 92ef9519a15bddd63e4c27221542911248341985
  • master default protected
  • 2.0.0-alpha-11
  • 2.0.0-alpha-10
  • 2.0.0-alpha-9
  • 2.0.0-alpha-8
  • 2.0.0-alpha-7
  • 2.0.0-alpha-6
  • 2.0.0-alpha-5
  • 2.0.0-alpha-4
  • 2.0.0-alpha-3
  • 2.0.0-alpha-2
  • 2.0.0-alpha-1
  • 1.8.0
  • 1.7.0
  • 1.6.4
  • 1.6.3
  • 1.6.2
  • 1.6.1
  • 1.6.0
  • 1.5.5
  • 1.5.4
22 results

Navbar.vue

Blame
  • Forked from TO / Weby / ui-styleguide
    Source project has a limited visibility.
    index.js 1.26 KiB
    import { createRouter, createWebHistory } from 'vue-router'
    import TEMPLATES from '../templates'
    
    import defaultFavicon from '../assets/favicon.png'
    
    let routes = [
        {
            path: '/avatar',
            name: 'avatar',
            component: () => import('../views/avatar/Avatar.vue'),
            meta: {
                title: 'Profilové obrázky'
            }
        }
    ];
    
    for (let [identifier, templateData] of Object.entries(TEMPLATES)) {
        routes.push({
            path: templateData.path,
            name: identifier,
            component: templateData.component,
            meta: templateData.meta
        })
    }
    
    const router = createRouter({
        history: createWebHistory(import.meta.env.BASE_URL),
        routes: routes
    })
    
    router.beforeEach(
        (to, from, next) => {
            document.title = 'Generátor grafiky'
    
            if (to.meta.title) {
                document.title = `${to.meta.title} | ${document.title}`
            }
            // END Title
    
            // BEGIN Favicon
            const link = document.createElement('link')
            link.rel = 'icon'
    
            if (to.meta.favicon !== undefined) {
                link.href = to.meta.favicon
            } else {
                link.href = defaultFavicon
            }
    
            document.head.appendChild(link)
            // END Favicon
    
            next()
        }
    )
    
    export default router