%# --------------------------------------------------------------- # docmd : the zero-config documentation engine. # @website https://docmd.io # [docmd-source] - Please do not remove this header. # --------------------------------------------------------------- %> <% if (locals.workspace && workspace.projects && workspace.projects.length > 0) { const currentPrefix = config._activePrefix || '/'; const switcherConfig = workspace.switcher || { enabled: true, position: 'sidebar-top' }; if (switcherConfig.enabled !== false) { const isCompact = typeof compact !== 'undefined' && compact; const currentProject = workspace.projects.find(p => { const pfx = p.prefix === '/' ? '/' : p.prefix.replace(/\/$/, ''); return pfx === currentPrefix; }) || workspace.projects[0]; const getProjectLabel = (p) => { if (p.title) return p.title; // Fallback: Use the last part of the source directory as a title if prefix is root if (p.prefix === '/' || !p.prefix.replace(/^\//, '')) { const srcParts = p.src.split(/[\/\\]/); const raw = srcParts[srcParts.length - 1]; return raw.split(/[\/-]/).map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '); } // Fallback for subprojects: use the prefix return p.prefix.replace(/^\//, '').split(/[\/-]/).map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '); }; %>