import { Elena, html, unsafeHTML } from '@elenajs/core';
export interface SidebarItem {
label: string;
slug: string;
badge?: { text: string; variant?: string };
}
export interface SidebarGroup {
label: string;
items: SidebarItem[];
}
/**
*
* Renders grouped navigation links for the docs sidebar.
* Light DOM — styles scoped via @scope.
*
*/
export class StarlightSidebar extends Elena(HTMLElement) {
static tagName = 'starlight-sidebar';
static props = ['groups', 'currentslug'];
groups: SidebarGroup[] = [];
currentslug = '';
render() {
const groupsHtml = (this.groups || []).map(group => {
const itemsHtml = group.items.map(item => {
const current = this.currentslug === item.slug ? 'page' : 'false';
const badgeHtml = item.badge
? `${item.badge.text}`
: '';
return `
${item.label}
${badgeHtml}
`;
}).join('');
return ``;
}).join('');
return html`
`;
}
}
StarlightSidebar.define();
export default StarlightSidebar;