feat(core)!: introduce runtime extension registry and flat module conventions
BREAKING CHANGE: sup config now derives entries from package.json#exports and a server/client glob instead of manual lists; module structure follows flat + barrel convention with .server.js/.client.js runtime suffixes
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
registerNavSection,
|
||||
registerNavItem,
|
||||
getNavSections,
|
||||
getNavItems,
|
||||
} from './registry.js';
|
||||
|
||||
// Sections et items core — enregistrés à l'import de ce module.
|
||||
registerNavSection({ id: 'dashboard', title: 'Tableau de bord', icon: 'DashboardSquare03Icon', order: 10 });
|
||||
registerNavSection({ id: 'system', title: 'Utilisateurs', icon: 'UserMultiple02Icon', order: 20 });
|
||||
|
||||
registerNavItem({ id: 'dashboard', label: 'Tableau de bord', icon: 'DashboardSquare03Icon', href: '/admin/dashboard', sectionId: 'dashboard', order: 10 });
|
||||
registerNavItem({ id: 'users', label: 'Utilisateurs', icon: 'UserMultiple02Icon', href: '/admin/users', sectionId: 'system', order: 10 });
|
||||
registerNavItem({ id: 'roles', label: 'Rôles', icon: 'Crown03Icon', href: '/admin/roles', sectionId: 'system', order: 20 });
|
||||
|
||||
/**
|
||||
* Build sections for AdminSidebar. Items are sérialisables (pas de composants),
|
||||
* icônes en chaînes résolues côté client.
|
||||
*/
|
||||
export function buildNavigationSections(pathname) {
|
||||
const sections = getNavSections();
|
||||
const items = getNavItems();
|
||||
|
||||
const bySection = new Map();
|
||||
for (const item of items) {
|
||||
const list = bySection.get(item.sectionId) || [];
|
||||
list.push({
|
||||
name: item.label,
|
||||
href: item.href,
|
||||
icon: item.icon,
|
||||
current: pathname === item.href || pathname.startsWith(item.href + '/'),
|
||||
});
|
||||
bySection.set(item.sectionId, list);
|
||||
}
|
||||
|
||||
return sections
|
||||
.filter(s => bySection.has(s.id))
|
||||
.map(s => ({ id: s.id, title: s.title, icon: s.icon, items: bySection.get(s.id) }));
|
||||
}
|
||||
Reference in New Issue
Block a user