From 07f6bfeddc4059ad4c854ae25d702566759280d4 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Fri, 15 Apr 2022 14:02:07 +0100 Subject: [PATCH 01/27] :construction: Display additional routes based on pages object --- src/router.js | 22 ++++++++++++++++++++++ src/utils/ConfigAccumalator.js | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/src/router.js b/src/router.js index 05db6f4261..176f59d49d 100644 --- a/src/router.js +++ b/src/router.js @@ -18,6 +18,8 @@ import { isAuthEnabled, isLoggedIn, isGuestAccessEnabled } from '@/utils/Auth'; import { metaTagData, startingView, routePaths } from '@/utils/defaults'; import ErrorHandler from '@/utils/ErrorHandler'; +import { pages } from '../public/conf.yml'; + Vue.use(Router); const progress = new Progress({ color: 'var(--progress-bar)' }); @@ -34,6 +36,7 @@ const getConfig = () => { return { appConfig: Accumulator.appConfig(), pageInfo: Accumulator.pageInfo(), + pages: Accumulator.pages(), }; }; @@ -61,6 +64,24 @@ const makeMetaTags = (defaultTitle) => ({ metaTags: metaTagData, }); +const makePageSlug = (pageName) => { + const formattedName = pageName.toLowerCase().replaceAll(' ', '-'); + return `/${formattedName}`; +}; + +const makeMultiPageRoutes = (userPages) => { + if (!userPages) return []; + const multiPageRoutes = []; + userPages.forEach((page) => { + multiPageRoutes.push({ + path: makePageSlug(page.name), + name: page.name, + component: Home, + }); + }); + return multiPageRoutes; +}; + /* Routing mode, can be either 'hash', 'history' or 'abstract' */ const mode = appConfig.routingMode || 'history'; @@ -68,6 +89,7 @@ const mode = appConfig.routingMode || 'history'; const router = new Router({ mode, routes: [ + ...makeMultiPageRoutes(pages), { // The default view can be customized by the user path: '/', name: `landing-page-${getStartingView()}`, diff --git a/src/utils/ConfigAccumalator.js b/src/utils/ConfigAccumalator.js index 320673c6a9..9a4083093a 100644 --- a/src/utils/ConfigAccumalator.js +++ b/src/utils/ConfigAccumalator.js @@ -23,6 +23,10 @@ export default class ConfigAccumulator { this.conf = $store.state.remoteConfig; } + pages() { + return this.conf.pages; + } + /* App Config */ appConfig() { let appConfigFile = {}; @@ -88,6 +92,7 @@ export default class ConfigAccumulator { appConfig: this.appConfig(), pageInfo: this.pageInfo(), sections: this.sections(), + pages: this.pages(), }; } } From 036bc008c54600fb08b1786b733aa5975caf744c Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Tue, 19 Apr 2022 21:16:27 +0100 Subject: [PATCH 02/27] :sparkles: Basic multi-page support working (#584) --- src/components/PageStrcture/Nav.vue | 16 ++++++++++++++-- src/mixins/HomeMixin.js | 20 +++++++++++++++++++- src/router.js | 27 ++++++++++++++++++++++----- src/store.js | 24 +++++++++++++++++++++++- src/utils/ConfigHelpers.js | 6 ++++++ src/utils/InitServiceWorker.js | 2 +- src/utils/StoreMutations.js | 2 ++ 7 files changed, 87 insertions(+), 10 deletions(-) diff --git a/src/components/PageStrcture/Nav.vue b/src/components/PageStrcture/Nav.vue index 3043610673..ec27496751 100644 --- a/src/components/PageStrcture/Nav.vue +++ b/src/components/PageStrcture/Nav.vue @@ -1,12 +1,12 @@