dendronhq / dendron

The personal knowledge management (PKM) tool that grows as you do!
https://wiki.dendron.so
Apache License 2.0
6.66k stars 252 forks source link

Enable linking to files via aliases #92

Open j-steinbach opened 4 years ago

j-steinbach commented 4 years ago

I try to replace Quoll with Dendron/Roam.

The single most featue I am missing is being able to create aliases for files, which I then can link to.

For example I write "is [[death]] just another journey?" and it points me to death.md.

Now in a different document I exclaim: "and so he went on his [[final journey]]. I don't want this to point to final journey.md, I also want it to link to death.md.

Furthermore, I don't want to write it as [[final journey|death]]:


From a technical perspective, I don't imagine it to be difficult. AFAIK, Dendron already uses YAML-Frontmatter, so adding an "alias"-field there and updating the link database should to the trick - not that I actually know what I am talking about :)

kevinslin commented 4 years ago

so implementing aliases is a little bit more involved just because there's lots of ways a file can be opened (eg. clicking link in preview, using lookup, going to definition, another extension)

i've put together a prototype that will check if a note is an alias and if so, open up the note its pointing to. currently there's a slight flicker because we actually open and then close the original document before opening the alias:

the alias is defined in a schema file with an alias field. would something like this work for your use case?

j-steinbach commented 4 years ago

Thanks for the fast reply! It seems workable, but I would not call it perfect.. (yeah, yeah, beggars choosers)

Ideally, it would allow me to either write the alias directly to the target (death.md), or allow me to manage all my aliases in a central file. As I understand your implementation, I would have to create an alias file for each alias (and who says that we stop at one alias?).

Also, I am concerned about the flickering. It kinda works for me, but if it gets added to the master, outsiders* might take it as a a bug. I am also a bit worried about unintended results the opening and closing might have - for example, the creation might trigger some code cleanup or beautifer (Beautifer, Prettier) and misbehave. Now that I think about it, I run like 30 something extensions. I can't be sure if this won't trigger some erratic behaviour.

If this is too much trouble, I am completely fine with you shelving the issue until more people become aware.

*people that do not know about this this issue/conversation

kevinslin commented 4 years ago

yeah, definitely not perfect. i'm going to do some thinking on this. i do want to support the ability for aliases in the future but also need to consider the ux.

i'm hesitant to make alias configurable on the note frontmatter because if a note is an alias and always navigates to the note that its pointing it to, how do you edit the alias note after the fact?

i think aliases will be defined in either one of two places:

leaning towards putting aliases inside dendron.yml but will spend some time thinking about it. as for the flickering, what we might do to start off with is only enable aliases when you navigate by shortcut. we can slowly add alias support in other parts as they come up (eg. via the preview and the lookup)

j-steinbach commented 4 years ago

That sounds like a plan. Wait, what exactly do you mean with "if a note is an alias". Isn't a note a file that contains links?

If I navigate the link [[final journey]] it leads me to death.md where I can easily edit the alias again.

kevinslin commented 4 years ago

ah, i see. that would work.

I was thinking of having a file called final journey.md with the following frontmatter.

---
alias: death.md
---

what you are saying is much more sensible 😅

j-steinbach commented 4 years ago

Great, and sorry for the confusion. Explaining things in text is hard... But I think we got there. The whole point of this is to not have a file called final journey.md :)

funkotron commented 4 years ago

This may be possible with symlinks on UNIX based operating systems (Mac OS X and linux)

kevinslin commented 4 years ago

Symlinks can work - only issue is that it won't be portable across computers (eg. if you commit to git/dropbox, you will lose the symlink)

boticello commented 3 years ago

As I'm sure you're aware, this is available in Obsidian, and the UX works very nicely. It's the one feature that is holding me back from using Dendron. It's good to hear that you're thinking it through thoroughly. Symlinks would be a bad solution for me, for the reason you say – it will break across machines and in git repos. Looking forward to seeing the Dendron solution.

Heniker commented 3 years ago

According to this stackoverflow answer, git can handle symlinks correctly. But implementing a symlink solution will require some special directory, under which real files should be kept (to prevent issues with broken symlinks). And, perhaps some mechanism to detect files that should be symlinks, but are not (e.g. because workspace was backed up to cloud storage that doesn't support symlinks). Alternatively, if it's okay to duplicate files, it might make sense to create an actual copy of a file and update all of it's aliases once one of the copies changes. This would require to add original file name to it's own aliases.

kevinslin commented 3 years ago

Thanks for the update. The way we're planning on handling symlinks is the same way Obsidian is doing it. Just haven't been able to find bandwidth to work on this feature yet. Will highlight this in our dev channel to see if someone wants to jump on this.

TaxDevOp commented 2 years ago

Hmmm... i guess not... 1 year gone since last update and still no solution.

TaxDevOp commented 1 year ago

Hmmm... again nearly a year gone and still nothing happened....

alexandrupetrini commented 1 year ago

Hmmm... again nearly a year gone and still nothing happened....

Dendron in no longer in active development, see here: https://discordapp.com/channels/717965437182410783/737323300967022732/1072563304289030164