UNCLASSIFIED - NO CUI

Skip to content
Snippets Groups Projects
index.js 7.35 KiB
Newer Older
jtwidt's avatar
jtwidt committed
import Vue from 'vue';
import VueRouter from 'vue-router';
graham.smith's avatar
graham.smith committed

jtwidt's avatar
jtwidt committed
import VueBodyClass from 'vue-body-class';
import Home from '../views/Home.vue';
Graham Smith's avatar
Graham Smith committed

Vue.use(VueRouter);

const routes = [
  {
jtwidt's avatar
jtwidt committed
    path: '/',
    name: 'Home',
Graham Smith's avatar
Graham Smith committed
    component: Home,
    meta: {
jtwidt's avatar
jtwidt committed
      title: 'Platform One',
      bodyClass: 'home-page',
    },
Graham Smith's avatar
Graham Smith committed
  },
Graham Smith's avatar
Graham Smith committed
  {
jtwidt's avatar
jtwidt committed
    path: '/products',
    name: 'Products',
Graham Smith's avatar
Graham Smith committed
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
jtwidt's avatar
jtwidt committed
      import(/* webpackChunkName: "services" */ '@/views/Products.vue'),
Graham Smith's avatar
Graham Smith committed
    meta: {
jtwidt's avatar
jtwidt committed
      title: 'Platform One | Products',
      bodyClass: 'products-page',
      breadcrumb: 'Products',
    },
Graham Smith's avatar
Graham Smith committed
  },
Graham Smith's avatar
Graham Smith committed
  {
jtwidt's avatar
jtwidt committed
    path: '/services',
    name: 'Services',
Graham Smith's avatar
Graham Smith committed
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
jtwidt's avatar
jtwidt committed
      import(/* webpackChunkName: "services" */ '@/views/Services.vue'),
Graham Smith's avatar
Graham Smith committed
    meta: {
jtwidt's avatar
jtwidt committed
      title: 'Platform One | Services',
      bodyClass: 'services-page',
      breadcrumb: 'Services',
    },
Graham Smith's avatar
Graham Smith committed
  },
  {
jtwidt's avatar
jtwidt committed
    path: '/who-we-are',
    name: 'WhoWeAre',
Graham Smith's avatar
Graham Smith committed
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
jtwidt's avatar
jtwidt committed
      import(/* webpackChunkName: "who-we-are" */ '@/views/WhoWeAre.vue'),
Graham Smith's avatar
Graham Smith committed
    meta: {
jtwidt's avatar
jtwidt committed
      title: 'Platform One | Who We Are',
      bodyClass: 'who-we-are-page',
      breadcrumb: 'Who We Are',
    },
graham.smith's avatar
graham.smith committed
  },
jtwidt's avatar
jtwidt committed
  {
    path: '/who-we-are/leadership',
    name: 'Leadership',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "who-we-are" */ '@/views/Leadership.vue'),
    meta: {
      title: 'Platform One | Who We Are | Leadership',
      bodyClass: 'leadership-page',
      breadcrumb: 'Leadership Team',
    },
  },
jtwidt's avatar
jtwidt committed
  {
    path: '/products/abms-adce/onboarding/3-day-workshop',
    name: '3DayWorkshop',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
        /* webpackChunkName: "3-day-workshop" */ '@/views/3DayWorkshop.vue'
      ),
    meta: {
      title:
        'Platform One | Products | The Party Bus Onboarding | 3 Day Workshop',
      bodyClass: '3-day-workshop-page',
      breadcrumb: '3 Day Workshop',
    },
  },
  {
    path: '/products/big-bang/onboarding/gbsd-workshop',
    name: 'GBSDWorkshop',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
        /* webpackChunkName: "GBSD-workshop" */ '@/views/GBSDWorkshop.vue'
      ),
    meta: {
      title:
        'Platform One | Products | The Party Bus Onboarding | GBSD Workshop',
      bodyClass: 'gbsd-workshop-page',
      breadcrumb: 'GBSD Workshop',
    },
  },
jtwidt's avatar
jtwidt committed
    path: '/products/abms-adce',
    name: 'ADCE',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "adce" */ '@/views/ADCE.vue'),
    meta: {
      title: 'Platform One | Products | The Party Bus',
      bodyClass: 'adce-page',
      breadcrumb: 'The Party Bus',
    },
  },
  { path: '/partybus-onboarding', redirect: '/products/abms-adce/onboarding' },
  {
    path: '/products/abms-adce/onboarding',
    name: 'ADCEOnboarding',
luke.glasscock's avatar
luke.glasscock committed
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
jtwidt's avatar
jtwidt committed
        /* webpackChunkName: "adce-onboarding" */ '@/views/ADCEOnboarding.vue'
luke.glasscock's avatar
luke.glasscock committed
      ),
    meta: {
jtwidt's avatar
jtwidt committed
      title: 'Platform One | Products | The Party Bus Onboarding',
      bodyClass: 'adce-onboarding-page',
      breadcrumb: 'Onboarding',
    },
jtwidt's avatar
jtwidt committed
    path: '/products/abms-adce/onboarding/faqs',
    name: 'ADCEOnboardingFAQs',
jtwidt's avatar
jtwidt committed
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
jtwidt's avatar
jtwidt committed
        /* webpackChunkName: "adce-onboarding-faqs" */ '@/views/ADCEOnboardingFAQs.vue'
jtwidt's avatar
jtwidt committed
    meta: {
jtwidt's avatar
jtwidt committed
      title: 'Platform One | Products | The Party Bus Onboarding FAQs',
      bodyClass: 'adce-onboarding-faqs-page',
      breadcrumb: 'FAQs',
    },
jtwidt's avatar
jtwidt committed
  },
jtwidt's avatar
jtwidt committed
  { path: '/bigbangonboarding', redirect: '/products/big-bang/onboarding' },
  { path: '/bigbang-onboarding', redirect: '/products/big-bang/onboarding' },
jtwidt's avatar
jtwidt committed
  {
jtwidt's avatar
jtwidt committed
    path: '/products/big-bang/onboarding',
    name: 'BigBangOnboarding',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
jtwidt's avatar
jtwidt committed
        /* webpackChunkName: "big-bang-onboarding" */ '@/views/BigBangOnboarding.vue'
      ),
    meta: {
jtwidt's avatar
jtwidt committed
      title: 'Platform One | Products | Big Bang Onboarding',
      bodyClass: 'big-bang-onboarding-page',
      breadcrumb: 'Big Bang Onboarding',
    },
jtwidt's avatar
jtwidt committed
  { path: '/bigbang', redirect: '/products/big-bang' },
  { path: '/big-bang', redirect: '/products/big-bang' },
jtwidt's avatar
jtwidt committed
    path: '/products/big-bang',
    name: 'BigBang',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
jtwidt's avatar
jtwidt committed
      import(/* webpackChunkName: "big-bang" */ '@/views/BigBang.vue'),
    meta: {
jtwidt's avatar
jtwidt committed
      title: 'Platform One | Products | Big Bang',
      bodyClass: 'big-bang-page',
      breadcrumb: 'Big Bang',
    },
graham.smith's avatar
graham.smith committed
  {
jtwidt's avatar
jtwidt committed
    path: '/contact-us',
    name: 'ContactUs',
graham.smith's avatar
graham.smith committed
    // route level code-splitting
    // this generates a separate chunk (ContactUs.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
jtwidt's avatar
jtwidt committed
      import(/* webpackChunkName: "ContactUs" */ '@/views/ContactUs.vue'),
graham.smith's avatar
graham.smith committed
    meta: {
jtwidt's avatar
jtwidt committed
      title: 'Platform One | Contact Us',
      bodyClass: 'contact-us-page',
      breadcrumb: 'Contact Us',
    },
  },
Graham Smith's avatar
Graham Smith committed
];

const router = new VueRouter({
  base: process.env.BASE_URL,
Graham Smith's avatar
Graham Smith committed
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    }
    if (to.hash) {
      return {
jtwidt's avatar
jtwidt committed
        selector: to.hash,
Graham Smith's avatar
Graham Smith committed
      };
    }

    return { x: 0, y: 0 };
jtwidt's avatar
jtwidt committed
  },
Graham Smith's avatar
Graham Smith committed
});

graham.smith's avatar
graham.smith committed
const vueBodyClass = new VueBodyClass(routes);
Graham Smith's avatar
Graham Smith committed

Graham Smith's avatar
Graham Smith committed
// This callback runs before every route change, including on page load.
router.beforeEach((to, from, next) => {
graham.smith's avatar
graham.smith committed
  vueBodyClass.guard(to, next);
Graham Smith's avatar
Graham Smith committed
  // This goes through the matched routes from last to first, finding the closest route with a title.
  // eg. if we have /some/deep/nested/route and /some, /deep, and /nested have titles, nested's will be chosen.
  const nearestWithTitle = to.matched
    .slice()
    .reverse()
jtwidt's avatar
jtwidt committed
    .find((r) => r.meta && r.meta.title);
Graham Smith's avatar
Graham Smith committed

  // If a route with a title was found, set the document (page) title to that value.
  if (nearestWithTitle) {
    document.title = nearestWithTitle.meta.title;
  }

  next();
});

export default router;