---
/** Unique symbol for storing a running index in `locals`. */
const currentGroupIndexSymbol = Symbol.for('starlight-sidebar-group-index');
const locals = Astro.locals as App.Locals & { [currentGroupIndexSymbol]: number };
/** The current sidebar group’s index retrieved from `locals` if set, starting at `0`. */
const index = locals[currentGroupIndexSymbol] || 0;
// Increment the index for the next instance.
locals[currentGroupIndexSymbol] = index + 1;
---
<sl-sidebar-restore data-index={index}></sl-sidebar-restore>