code: function() {
        var t = this,
            sbJSON = t.sidebar.toJSON({deep:true, trim:true});
  
        // Function to trim closed sub-branches from a tree
        var trimSubBranch = function(tree) {
          var branches = tree.branches;
          for (var i in branches) {
            var subTree = branches[i];
            if (subTree.isOpen && !subTree.isLoading) {
              branches[i] = trimSubBranch(subTree);
            } else {
              branches[i] = {
                id: subTree.id,
              };
              if (subTree.label) {
                branches[i].label = subTree.label;
              }
            }
          }
          return tree;
        };
  
        // Trim sub-tree elements in pages, and save
        for (var i = 0; i < sbJSON.tree.branches.length; i++) {
          sbJSON.tree.branches[i] = trimSubBranch(sbJSON.tree.branches[i]);
        }
        localStorage.sidebar = JSON.stringify(sbJSON);
      }
docs: Save the sidebar to localStorage