diff --git a/apps/cat.config.json b/apps/cat.config.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/apps/cat.config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/client/src/routes/index.tsx b/client/src/routes/index.tsx index db6f42f35..87f000314 100644 --- a/client/src/routes/index.tsx +++ b/client/src/routes/index.tsx @@ -2,6 +2,20 @@ import type { ModuleCategory, ModuleConfig } from 'shared' let ROUTES: ModuleCategory[] = [] +const categoryFile = import.meta.glob('../../../apps/cat.config.json', { + eager: true +}) + +let categoriesSeq: string[] = [] + +console.log(categoryFile) + +if (categoryFile['../../../apps/cat.config.json']) { + categoriesSeq = ( + categoryFile['../../../apps/cat.config.json'] as { default: string[] } + ).default +} + await Promise.all( Object.entries( import.meta.glob(['../apps/**/manifest.ts', '../../../apps/**/manifest.ts']) @@ -49,7 +63,28 @@ ROUTES = ROUTES.sort((a, b) => { if (bIndex >= 1) return -1 // Settings, SSO, go last } - // Both are regular categories - alphabetical + if (categoriesSeq.length > 0) { + const aCatIndex = categoriesSeq.indexOf(a.title) + + const bCatIndex = categoriesSeq.indexOf(b.title) + + // Both found in sequence + if (aCatIndex !== -1 && bCatIndex !== -1) { + return aCatIndex - bCatIndex + } + + // Only a found in sequence + if (aCatIndex !== -1) { + return -1 + } + + // Only b found in sequence + if (bCatIndex !== -1) { + return 1 + } + } + + // Default to alphabetical return a.title.localeCompare(b.title) }).map(cat => ({ title: ['', ''].includes(cat.title) ? '' : cat.title,