In Obsidian there is no build-in command to reload active page. But sometimes you need to. Some plugins, like dataview or supercharged links won’t refresh in real time, and you have to leave the page and open it again to refresh the view. It can be a little bothersome.
Luckily, you can easily reload your page with obsidian api. This simple line does the trick:
app.workspace.activeLeaf.rebuildView()
Now, how would you turn this little script into runnable Obsidian command (without writing the whole new plugin)? There are several ways to do this. For ones, you can use the Templater plugin. Create template like this:
<%*
app.workspace.activeLeaf.rebuildView()
%>
and bind it to the hotkey. Now the command is created by Templater. The only downside is that Templater for now is not working in canvas. Since my use case was to refresh supercharged links specificly in canvas, I looked for another options.
Another way is installing the “User Plugins” plugin. It’s a little more complicated, but works everywhere, unlike Templater. Create the js file and write this code in it:
module.exports = {}
module.exports.onload = function(plugin) {
plugin.addCommand({
id: 'reload-page',
name: 'Reload page',
callback: () => {
app.workspace.activeLeaf.rebuildView()
}
});
}
Then enable the script in the User Plugins settings. It also creates command you can bind to hotkey or call from the command palette.
I hope the developers will add build-in command to reload files in the future, but this works for me for now.