Skip to content

Commit

Permalink
Fixes pageInfo not being read in router (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed May 14, 2022
1 parent 24e487c commit 9b33a6e
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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';
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)' });
Expand All @@ -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;

Expand All @@ -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,
});

Expand All @@ -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
Expand Down

0 comments on commit 9b33a6e

Please sign in to comment.