Advertisement
DubStepMad

Untitled

Sep 22nd, 2022
942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { createRouter, createWebHistory } from "vue-router";
  2.  
  3. const routes = [ {
  4.     name: "Simulator FM",
  5.     mode: "history",
  6.     linkActiveClass: "border-transparent",
  7.     routes: [
  8.         {
  9.             path: "/home",
  10.             name: "Home",
  11.             component: () => import("./components/Home.vue"),
  12.         },
  13.         {
  14.             path: "/request",
  15.             name: "Request",
  16.             component: () => import("./components/Request.vue"),
  17.         },
  18.         {
  19.             path: "/timetable",
  20.             name: "Timetable",
  21.             component: () => import("./components/Timetable.vue"),
  22.         },
  23.         {
  24.             path: "/team",
  25.             name: "Team",
  26.             component: () => import("./components/Team.vue"),
  27.         },
  28.         {
  29.             path: "/contact-us",
  30.             name: "Contact Us",
  31.             component: () => import("./components/Contact.vue"),
  32.         },
  33.         {
  34.             path: "/apply",
  35.             name: "Apply",
  36.             component: () => import("./components/Apply.vue"),
  37.         },
  38.         {
  39.             path: "/streamer",
  40.             name: "Streamer",
  41.             component: () => import("./components/Streamer.vue"),
  42.         },
  43.         {
  44.             path: "/post/:slug",
  45.             name: "Post",
  46.             component: () => import("./components/Post.vue"),
  47.         },
  48.         {
  49.             path: "/song",
  50.             name: "Song",
  51.             component: () => import("./components/Song.vue"),
  52.         },
  53.     ],
  54.     components: {
  55.         "player": () => import("./components/Player.vue").default,
  56.     },
  57. }];
  58.  
  59. const router = createRouter({
  60.     history: createWebHistory(),
  61.     routes,
  62.     linkActiveClass: "active",
  63. });
  64.  
  65. router.afterEach((to, from) => {
  66.     if (to.meta != null && to.meta.title != null)
  67.         document.title = to.meta.title;
  68.  
  69.     Array.from(document.querySelectorAll('[data-vue-meta]')).map(el => el.parentNode.removeChild(el));
  70.  
  71.     if (to.meta && to.meta.metaTags) {
  72.         to.meta.metaTags.map(tagDef => {
  73.             let tag = document.createElement('meta');
  74.  
  75.             Object.keys(tagDef).forEach(key => tag.setAttribute(key, tagDef[key]));
  76.  
  77.             tag.setAttribute('data-vue-meta', '');
  78.  
  79.             return tag;
  80.         }).forEach(tag => document.head.appendChild(tag));
  81.     }
  82. });
  83.  
  84. export default router
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement