From 9b33a6e277fac444438cb7e9ce9942babb1ee60b Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 14 May 2022 13:20:53 +0100 Subject: [PATCH] Fixes pageInfo not being read in router (#645) --- src/router.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/router.js b/src/router.js index e034b0e0..bf520682 100644 --- a/src/router.js +++ b/src/router.js @@ -11,7 +11,6 @@ import { Progress } from 'rsup-progress'; // Import views, that are not lazy-loaded import Home from '@/views/Home.vue'; -import ConfigAccumulator from '@/utils/ConfigAccumalator'; // Import helper functions, config data and defaults import { isAuthEnabled, isLoggedIn, isGuestAccessEnabled } from '@/utils/Auth'; @@ -19,7 +18,8 @@ import { makePageSlug, makePageName } from '@/utils/ConfigHelpers'; import { metaTagData, startingView, routePaths } from '@/utils/defaults'; import ErrorHandler from '@/utils/ErrorHandler'; -import { pages } from '../public/conf.yml'; +// Import data from users conf file. Note that rebuild is required for this to update. +import { pages, pageInfo, appConfig } from '../public/conf.yml'; Vue.use(Router); const progress = new Progress({ color: 'var(--progress-bar)' }); @@ -32,17 +32,6 @@ const isAuthenticated = () => { return (!authEnabled || userLoggedIn || guestEnabled); }; -const getConfig = () => { - const Accumulator = new ConfigAccumulator(); - return { - appConfig: Accumulator.appConfig(), - pageInfo: Accumulator.pageInfo(), - pages: Accumulator.pages(), - }; -}; - -const { appConfig, pageInfo } = getConfig(); - /* Get the users chosen starting view from app config, or return default */ const getStartingView = () => appConfig.startingView || startingView; @@ -61,7 +50,7 @@ const getStartingComponent = () => { /* Returns the meta tags for each route */ const makeMetaTags = (defaultTitle) => ({ - title: pageInfo.title || defaultTitle, + title: pageInfo?.title || defaultTitle, metaTags: metaTagData, }); @@ -73,10 +62,12 @@ const makeSubConfigPath = (rawPath) => { /* For each additional config file, create routes for home, minimal and workspace views */ const makeMultiPageRoutes = (userPages) => { - if (!userPages) return []; + // If no multi pages specified, or is not array, then return nothing + if (!userPages || !Array.isArray(userPages)) return []; const multiPageRoutes = []; + // For each user page, create an additional route userPages.forEach((page) => { - if (!page.name || !page.path) { + if (!page.name || !page.path) { // Sumin not right, show warning ErrorHandler('Additional pages must have both a `name` and `path`'); } // Props to be passed to home mixin