document.addEventListener("DOMContentLoaded", function () {
  var aside = document.querySelector("aside.sidebar");
  if (!aside || !aside.children.length) return;

  var fab = document.createElement("button");
  fab.type = "button";
  fab.className = "btn btn-fab fab";
  fab.title = "Menu";
  fab.setAttribute("aria-label", "Menu");
  fab.setAttribute("aria-expanded", "false");
  fab.textContent = "≡";
  fab.addEventListener("click", function () {
    var open = aside.classList.toggle("is-open");
    fab.setAttribute("aria-expanded", open ? "true" : "false");
  });
  aside.addEventListener("click", function (e) {
    if (e.target.tagName === "A") {
      aside.classList.remove("is-open");
      fab.setAttribute("aria-expanded", "false");
    }
  });
  document.body.appendChild(fab);
});
