basham / obsidian-alias-from-heading

Obsidian plugin: Implicitly add an alias matching the first heading in a document.
MIT License
16 stars 1 forks source link

YAML compatibility - clarification #2

Closed jebeaudoin closed 2 years ago

jebeaudoin commented 2 years ago

I really love the concept of this plugin because I use the "relative path to file" link format, which is practically unreadable when rendered. Lately, I've been using YAML aliases to generate a readable link.

I need a point of clarification, however. It appears that if the "aliases" key is present in a note's YAML, the ability to link to that note from its first header is disabled. Is that the case?

Example

Filename: Note A
---
Aliases: 
- 'Linus'
---

# Charlie Brown

When trying to link from Note B to Note A (after installing the plugin, obviously), I can use either "Note A" or "Linus" but I cannot use "Charlie Brown". Furthermore, even if the aliases value is empty, the alias from header functionality isn't working. Are these the expected behaviors?

Thanks, Jack

basham commented 2 years ago

As stated in the readme:

Any aliases defined in YAML continue to behave in their standard way.

The presence of a YAML alias does not disable the implicit heading alias. In your case, you should expect to have the following link suggestions when you type [[:

Which suggestions you see of course depends on what you type after [[.

I discovered an issue with the plugin that resulted in the implicit heading alias not being added to the list of suggestions on loading the vault. If you are using this plugin, I suspect your thought on the behavior being disabled is actually a result of this bug. I released v1.0.9 yesterday to resolve this.

Additionally, I thought of another issue that will need another bug fix (which also could have been the problem you are facing). As of v1.0.9, the entire vault will be scanned for these implicit heading aliases only if the plugin is loaded when the vault is loaded. If you installed the plugin and did not close and open the vault again, or if you disabled and then enabled the plugin — it likely has not rescanned the vault to provide the alias suggestions that you'd expect. So, until that fix is in place (likely a v1.0.10 release), please just restart Obsidian. Then it should work as expected.

Please let me know if any of this is helpful or (temporarily) addresses the issue you're facing.

basham commented 2 years ago

To help clarification, I can also update the readme to something like this:

This alias is not explicitly defined in YAML. Any aliases defined in YAML continue to behave in their standard way and do not affect the behavior of this plugin.

jebeaudoin commented 2 years ago

Thanks for responding, Chris. Some additional information:

Note A

Screen Shot 2022-06-29 at 2 31 44 PM

Note B

Screen Shot 2022-06-29 at 2 34 00 PM

If I remove the YAML from Note A, then the implicit alias from the first header works. Screen Shot 2022-06-29 at 2 36 16 PM

I hope this isn't a user error — I value your work and don't want to waste your time.

Jack

basham commented 2 years ago

I'm able to re-create the problem. Try updating aliases to alias. It should work, then.

I see that "aliases" is what is mentioned in the official documentation. But it seems both words work (if this plugin is not enabled). The plugin is only accounting for "alias" for now. So, I need to test test different YAML configurations and others. I'll work on that fix, so it shouldn't be too particular in the future. Thanks for pointing it out!

jebeaudoin commented 2 years ago

I'm happy to be of assistance now and in the future. Not a coder, but a willing beta tester. Cheers!

basham commented 2 years ago

@jebeaudoin Please test the new 1.0.10 release. I believe it resolved all problems mentioned by us in this issue.

jebeaudoin commented 2 years ago

Well, that was weird. Despite quitting and restarting several times, I was encountering the same bug in the sandbox vault. Then, I went back to it, changed the alias from "Lucy" to "Linus" and did a quit/restart cycle. And when it restarted, it worked as expected. I wonder if there was some kind of caching issue with Obsidian? Very weird.

But anyhow, it looks like it is working fine now. Thank you so much!

Jack