shabegom / buttons

Buttons in Obsidian
The Unlicense
477 stars 50 forks source link

How to use buttons to navigate to a note #134

Closed mayankkalbhor closed 8 months ago

mayankkalbhor commented 1 year ago

I read all the docs and also tutorials but did not found this. So if i have button and i need an action to go to a note say "XYZ.md" how to write the action for this

shabegom commented 1 year ago

In the file explorer, right click on the note you want to navigate to. You should see an option to copy the uri for the note.

Create a link button:

name Goto Note type link action $COOIED_URI

A PR adding this to the docs would be accepted and merged.

mayankkalbhor commented 1 year ago

Ok i did this and its working fine

name Home
type link
action obsidian://open?vault=General&file=Home
color blue

But it takes some time to navigate to the desired note. Cant we make this fast like Obsidians Navigate forward and backward buttons at the top. They are really fast.

Is the above correct button syntax i am using?

sm-alejandro commented 1 year ago

Ok i did this and its working fine

name Home
type link
action obsidian://open?vault=General&file=Home
color blue

But it takes some time to navigate to the desired note. Cant we make this fast like Obsidians Navigate forward and backward buttons at the top. They are really fast.

Is the above correct button syntax i am using?

I used the same button as you and for me it is as fast as the Navigation buttons. Are you opening a note on the same vault or on another one?

ReaderGuy42 commented 1 year ago

Hi I just found this plugin and thread. I'm having a similar issue. I'm trying to link a note in the same vault and it takes a while and then opens up another instance of Obsidian. Is there a way to just switch to another note as one would do if you were to click a plain link?

sm-alejandro commented 1 year ago

Hi I just found this plugin and thread. I'm having a similar issue. I'm trying to link a note in the same vault and it takes a while and then opens up another instance of Obsidian. Is there a way to just switch to another note as one would do if you were to click a plain link?

could you share the code you are using? the snippet I pasted above works for me

ReaderGuy42 commented 1 year ago

Thanks for the offer, I don't know what changed, I have exactly what @mayankkalbhor has above, and yesterday it wasn't working (or rather it opened another instance of Obsidian) but now it works perfectly. Maybe rebooting my PC did it, as I had even restarted Obsidian. Oh well, now it works, so thanks!

ReaderGuy42 commented 1 year ago

Hey so I again don't know what changed, but now it's back to opening a new instance of Obsidian again. This is the button snippet:

```button
name Audiobooks
type link
action obsidian://open?vault=Books%20and%20Movies&file=Tracker%20and%20Want%20to%20Read%2FYears%2FAll%20Audiobooks
color blue

^button-onlyaudio

sm-alejandro commented 1 year ago

Hey so I again don't know what changed, but now it's back to opening a new instance of Obsidian again. This is the button snippet:

```button
name Audiobooks
type link
action obsidian://open?vault=Books%20and%20Movies&file=Tracker%20and%20Want%20to%20Read%2FYears%2FAll%20Audiobooks
color blue

^button-onlyaudio

I don't see anything wrong with it either. Could you try renaming the vault so that it does not contain whitespaces? Maybe that is the problem. If I discover something else I'll let you know, but for now I don't have nothing better than that.

filmgal commented 1 year ago

Do we really have to use "open vault" to open a local file within the same vault?

sm-alejandro commented 1 year ago

Do we really have to use "open vault" to open a local file within the same vault?

From what I have read in the docs yes. If you want it to be fast just use a normal link [[link]] to the note. Another possibility is, if you manage to create a command that takes you to that note you can call that command from a button.