mirror of
https://github.com/Lissy93/dashy.git
synced 2025-07-26 23:24:38 +02:00
🚧 Display additional routes based on pages object
This commit is contained in:
parent
cc1b9c823b
commit
07f6bfeddc
@ -18,6 +18,8 @@ import { isAuthEnabled, isLoggedIn, isGuestAccessEnabled } from '@/utils/Auth';
|
|||||||
import { metaTagData, startingView, routePaths } from '@/utils/defaults';
|
import { metaTagData, startingView, routePaths } from '@/utils/defaults';
|
||||||
import ErrorHandler from '@/utils/ErrorHandler';
|
import ErrorHandler from '@/utils/ErrorHandler';
|
||||||
|
|
||||||
|
import { pages } from '../public/conf.yml';
|
||||||
|
|
||||||
Vue.use(Router);
|
Vue.use(Router);
|
||||||
const progress = new Progress({ color: 'var(--progress-bar)' });
|
const progress = new Progress({ color: 'var(--progress-bar)' });
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ const getConfig = () => {
|
|||||||
return {
|
return {
|
||||||
appConfig: Accumulator.appConfig(),
|
appConfig: Accumulator.appConfig(),
|
||||||
pageInfo: Accumulator.pageInfo(),
|
pageInfo: Accumulator.pageInfo(),
|
||||||
|
pages: Accumulator.pages(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,6 +64,24 @@ const makeMetaTags = (defaultTitle) => ({
|
|||||||
metaTags: metaTagData,
|
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' */
|
/* Routing mode, can be either 'hash', 'history' or 'abstract' */
|
||||||
const mode = appConfig.routingMode || 'history';
|
const mode = appConfig.routingMode || 'history';
|
||||||
|
|
||||||
@ -68,6 +89,7 @@ const mode = appConfig.routingMode || 'history';
|
|||||||
const router = new Router({
|
const router = new Router({
|
||||||
mode,
|
mode,
|
||||||
routes: [
|
routes: [
|
||||||
|
...makeMultiPageRoutes(pages),
|
||||||
{ // The default view can be customized by the user
|
{ // The default view can be customized by the user
|
||||||
path: '/',
|
path: '/',
|
||||||
name: `landing-page-${getStartingView()}`,
|
name: `landing-page-${getStartingView()}`,
|
||||||
|
@ -23,6 +23,10 @@ export default class ConfigAccumulator {
|
|||||||
this.conf = $store.state.remoteConfig;
|
this.conf = $store.state.remoteConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pages() {
|
||||||
|
return this.conf.pages;
|
||||||
|
}
|
||||||
|
|
||||||
/* App Config */
|
/* App Config */
|
||||||
appConfig() {
|
appConfig() {
|
||||||
let appConfigFile = {};
|
let appConfigFile = {};
|
||||||
@ -88,6 +92,7 @@ export default class ConfigAccumulator {
|
|||||||
appConfig: this.appConfig(),
|
appConfig: this.appConfig(),
|
||||||
pageInfo: this.pageInfo(),
|
pageInfo: this.pageInfo(),
|
||||||
sections: this.sections(),
|
sections: this.sections(),
|
||||||
|
pages: this.pages(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user