The TreeView plug by joekrill shows your pages as a tree in a side panel. On a phone that panel takes over the screen. This setup keeps it as a sidebar on a desktop and makes it a pop-up on the phone, opened from a button in the top bar. On the phone, the pop-up closes by itself after you pick a page. System pages are left out of the tree.
CONFIG page.space-lua code block (three backticks followed by space-lua) and paste this code inside it. If you already have a plugs list, add the TreeView line to it instead of making a second one.-- true on a phone-sized screen (700px wide or less)
function treeviewIsPhone()
return js.window.innerWidth <= 700
end
config.set {
plugs = {
"github:joekrill/silverbullet-treeview/treeview.plug.js"
},
treeview = {
position = treeviewIsPhone() and "modal" or "lhs",
exclusions = {
{ type = "regex", rule = "^(?:CONFIG|STYLES|Library|Repositories).*$" }
}
}
}
space-lua block with the button and the auto close:actionButton.define {
icon = "sidebar",
description = "Toggle Tree View",
mobile = true,
run = function()
editor.invokeCommand("Tree View: Toggle")
end
}
event.listen {
name = "editor:pageLoaded",
run = function()
-- only the phone pop-up closes; the desktop sidebar stays open
if not treeviewIsPhone() then return end
-- wait a moment: the Tree View plug reopens itself on page load,
-- so hiding at the same instant loses the race
js.window.setTimeout(function()
system.invokeFunction("treeview.hide")
end, 400)
end
}
Plugs: Update to install the plug, then System: Reload.rule line, separated by |.