π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
β»οΈ Small refactor, to use shared makePageSlug instead of re-implementing
Alicia Sykesf7b57a5d2313
diff --git a/src/components/LinkItems/Section.vue b/src/components/LinkItems/Section.vueindex e5e6881f..f3178f40 100644--- a/src/components/LinkItems/Section.vue+++ b/src/components/LinkItems/Section.vue@@ -110,6 +110,7 @@ import IframeModal from '@/components/LinkItems/IframeModal.vue';import EditSection from '@/components/InteractiveEditor/EditSection.vue';import ContextMenu from '@/components/LinkItems/SectionContextMenu.vue';import ErrorHandler from '@/utils/ErrorHandler';+import { makePageSlug } from '@/utils/ConfigHelpers';import StoreKeys from '@/utils/StoreMutations';import {sortOrder as defaultSortOrder,@@ -252,9 +253,7 @@ export default {ErrorHandler('Cannot open section without a valid name');return;}- const parse = (section) => section.replace(' ', '-').toLowerCase().trim();- const sectionIdentifier = parse(this.title);- router.push({ path: `/home/${sectionIdentifier}` });+ router.push({ path: makePageSlug(this.title, 'home') });this.closeContextMenu();},/* Toggle sections collapse state */diff --git a/src/components/MinimalView/MinimalSection.vue b/src/components/MinimalView/MinimalSection.vueindex 95a5c8a3..5db0330a 100644--- a/src/components/MinimalView/MinimalSection.vue+++ b/src/components/MinimalView/MinimalSection.vue@@ -49,6 +49,7 @@ import Item from '@/components/LinkItems/Item.vue';import WidgetBase from '@/components/Widgets/WidgetBase';import SubItemGroup from '@/components/LinkItems/SubItemGroup.vue';import IframeModal from '@/components/LinkItems/IframeModal.vue';+import { makePageSlug } from '@/utils/ConfigHelpers';export default {name: 'ItemGroup',@@ -102,9 +103,7 @@ export default {},/* Navigate to the section's single-section view page */navigateToSection() {- const parse = (section) => section.replace(' ', '-').toLowerCase().trim();- const sectionIdentifier = parse(this.title);- router.push({ path: `/home/${sectionIdentifier}` });+ router.push({ path: makePageSlug(this.title, 'home') });},},};diff --git a/src/utils/ConfigHelpers.js b/src/utils/ConfigHelpers.jsindex a4ceb2c0..92abd80d 100644--- a/src/utils/ConfigHelpers.js+++ b/src/utils/ConfigHelpers.js@@ -26,6 +26,7 @@ export const makePageSlug = (pageName, pageType) => {/* Put fetch path for additional configs in correct format */export const formatConfigPath = (configPath) => {+ if (!configPath) return configPath;if (configPath.includes('http')) return configPath;if (configPath.substring(0, 1) !== '/') return `/${configPath}`;return configPath;diff --git a/src/views/Home.vue b/src/views/Home.vueindex ca73a8bb..5ca8987f 100644--- a/src/views/Home.vue+++ b/src/views/Home.vue@@ -66,6 +66,7 @@ import AddNewSection from '@/components/InteractiveEditor/AddNewSectionLauncher.import NotificationThing from '@/components/Settings/LocalConfigWarning.vue';import StoreKeys from '@/utils/StoreMutations';import { modalNames } from '@/utils/defaults';+import { makePageName } from '@/utils/ConfigHelpers';import ErrorHandler from '@/utils/ErrorHandler';import BackIcon from '@/assets/interface-icons/back-arrow.svg';@@ -147,15 +148,10 @@ export default {/* If on sub-route, and section exists, then return only that section */findSingleSection: (allSections, sectionTitle) => {if (!sectionTitle) return undefined;- let sectionToReturn;- const parse = (section) => section.replaceAll(' ', '-').toLowerCase().trim();- allSections.forEach((section) => {- if (parse(sectionTitle) === parse(section.name || '')) {- sectionToReturn = [section];- }- });- if (!sectionToReturn) ErrorHandler(`No section named '${sectionTitle}' was found`);- return sectionToReturn;+ const target = makePageName(sectionTitle);+ const match = allSections.find((s) => makePageName(s.name || '') === target);+ if (!match) ErrorHandler(`No section named '${sectionTitle}' was found`);+ return match ? [match] : undefined;},/* Returns an array of links to external CSS from the Config */getExternalCSSLinks() {