Fixes pageInfo not being read in router (#645)

This commit is contained in:
Alicia Sykes 2022-05-14 13:20:53 +01:00
parent 24e487cde5
commit 9b33a6e277
1 changed files with 7 additions and 16 deletions

View File

@ -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