Puedes echar un vistazo a cómo se integra el plugin de chat con la barra lateral:
En este caso, el estado de los enlaces se mantiene en el objeto de servicio y, siempre que cambia el estado, se actualiza la barra lateral:
Una solución potencial sería suscribirse al evento de cambio de página y actualizar los enlaces. El pseudocódigo podría parecerse a:
import { tracked } from "@glimmer/tracking";
api.addSidebarSection(
(BaseCustomSidebarSection, BaseCustomSidebarSectionLink) => {
const TestSectionLink = class extends BaseCustomSidebarSectionLink {
// define tus propiedades de enlace personalizadas aquí
};
const SidebarTestSection = class extends BaseCustomSidebarSection {
@tracked links = [];
constructor() {
super(...arguments);
this.#updateLinks();
this.onAppEvent("page:changed", () => this.#updateLinks());
}
get newLinksArray() {
// lista de enlaces basada en la URL actual
}
#updateLinks() {
this.links = this.newLinksArray.map(
(link) =>
new TestSectionLink({
link,
})
);
}
get sectionLinks() {
return this.links;
}
};
return SidebarTestSection;
}
);