I’m working on a space Lua script that exports some files to host on my personal website, and I’d like the script to call Space: Reindex before it starts its work, just to make sure everything is up to date when it starts querying things.
Unfortunately, I haven’t been able to find a method to do so. Also I know there’s a whole Library/Std, but I haven’t been able to find a way to actually list the files there. The only way I know to even get to one of the files is by clicking a link to it. It would be useful to be able to search or navigate to those pages.
to list all pages inside Library/Std you could do something like this:
${query[[from index.tag "page"
where name:startsWith("Library/Std")
select {
Page = "[[" .. ref .."|".. name .. "]]",
Tags = tags
}]]}
or you could try the treeview plug, which will give you the complete tree of your space: TreeView - Silverbullet Plug
and for the reindexing you could do a
editor.invokeCommand("Space: Reindex")
this will reindex your current editor client and depending on the size of your space, could take a while. Are you sure you want reindex and not “sync” or “reload”. what would be the exact purpose of your reindex?
I want to make sure that things like front matter have been parsed and fully up to date, so I don’t, for example, export a page I’ve removed the “public: true” part on.
I don’t mind the command taking awhile. I might have it give progress updates via toasts if it’s slow.
I think then what you are looking for is a simple “sync” & “reload” cycle rather than a whole “reindex” of the page.
Here I tried to detail the process what each command does (from what I understood, but I may be wrong):
Sync File: it “saves” the single opened page from the editor (Web-Client) to the file on your server where Silverbullet is running and also back if a file was changed on the server it loads/updates it your web client. And i’m not sure it also does the indexing, but only for the delta (differences/changes) for the current file.
Sync Space: Same as the above only for the whole space, and not only one file. And i’m not sure, but I think it also does the indexing, but only for the delta (differences/changes), not a complete reindex.
Reindex: (This is one way only), it checks all physical files on the server and rebuilds the Database in the Local Storage of the Browser (in your opened session)
Reload: It reloads all space-lua & space-style bits from the Database of your Local Storage and reapplies them in your browser session.
Plugs: Update: it deletes the _plug folder and downloads all plugs fresh from the plugs URL’s.
Reload UI: It does a Webpage Refresh - same as Ctrl-R or F5
@zef can you please correct me if I’m wrong with the above detail. This is how I understand&use each command. Maybe it would be an idea & useful to detail the steps what each command does also in the documentation?
There is a Meta Picker for all the meta pages. There is also a document picker and a picker with all pages. Just search for them in the command palette and it will show the corresponding keyboard shortcuts.
The Metapicker/Document picker is indeed a good choice if you know exactly what you are looking for. But the small search window only show 4-5 pages at once. And usually when I don’t know exactly what i’m looking for or just want an overview, I do a query with the whole list of possible options without scrolling too much up and down. The Library/Std/Pages/Space Overview is also a go to page, when I am looking for meta pages I don’t know their name.
Thanks, this has been helpful. As a bit of a followup, is there a way to make a folder not get indexed? My output files are md files, but with links that are relative to the website root, and it wants to list those as aspiring pages now
I put the exported files in /space/.garden/. I was hoping the . in the folder name would hide it. (that folder then gets mounted by the container that hosts the site)