Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML frontmatter tags support #72

Closed
Darkbluetest opened this issue Apr 22, 2022 · 13 comments
Closed

YAML frontmatter tags support #72

Darkbluetest opened this issue Apr 22, 2022 · 13 comments

Comments

@Darkbluetest
Copy link

Hi,

Unless I missed something, it seems that only the #hashtags are recognized in map view so to filter by tags, but not the tags defined in the note's YAMLfrontmatter. It would be better if all ways to declare tags in notes were supported, otherwise it seems risky/confusing as it "makes" two types of tags, tags readable by Map View search function and tags usable/readable by Obsidian search.

Tx

@esm7
Copy link
Owner

esm7 commented Apr 24, 2022

Sounds like Obsidian's CachedMetadata.tags API does not include front matter tags, I'll add them.

@esm7
Copy link
Owner

esm7 commented Apr 24, 2022

I just tested this and the following already works:

---
location: [31.8340099,35.5375804]
tags:
  - hike
---

With no other tags listed in the note, it gets recognized as expected.
Can you elaborate what you are doing that is not working as expected?

(I was not aware of this being natively supported but followed the example on https://help.obsidian.md/How+to/Working+with+tags and it just worked)

@Darkbluetest
Copy link
Author

Yes, I tested that format and it did not work. I have just re tested it does not work on my side...

@esm7
Copy link
Owner

esm7 commented Apr 25, 2022

Can you share the front matter that doesn't work?

@Darkbluetest
Copy link
Author

Darkbluetest commented Apr 25, 2022

Hi

The one you posted for example. Or another I tested :

---
location: [42, 10]
tags: [me]
---

@gentlegiantJGC
Copy link
Contributor

The example provided works correctly for me

@Darkbluetest
Copy link
Author

I have just tested it in another, brand new, obsidian vault, with only map view plugin installed and tag panel activated, as the only modifications from vanilla obsidian. I created 2 notes. It does not work. Tested with inline and frontmatter locations...

I don't get why it does not work...

@gentlegiantJGC
Copy link
Contributor

Actually reading through this again I realised that I tested wrong.
You are correct. Tags in the front matter are not checked.

@esm7
Copy link
Owner

esm7 commented May 13, 2022

I tested this right now again, exactly like the example above. A note without any tags gets marked in the correct icons when I set tags: [hike] in the front-matter. I don't get why I can't recreate it.
@gentlegiantJGC, if you can recreate it perhaps you can track the reason the getAllTags Obsidian API call doesn't return the right tags for you guys.

@gentlegiantJGC
Copy link
Contributor

Yeh I will have a look into why it isn't working.
It was getting a bit late yesterday

@gentlegiantJGC
Copy link
Contributor

Just so we are on the same page. For me the icons display correctly even if the tag is in the front matter.
What does not work correctly is the search tool.

In summary this may be a bug in Obsidian or it may be intended behaviour. I am tempted to say a bug.
this.app.metadataCache.getFileCache(file) sometimes does not have a tags attribute even though tags are defined in the front matter.
They are available through the front matter attribute though.
image

I will do some more debugging later.

gentlegiantJGC added a commit to gentlegiantJGC/obsidian-map-view that referenced this issue May 13, 2022
`this.app.metadataCache.getFileCache(file)[:].tags` only contained tags in the body of the file not files in the front matter.
The function getAllTags takes the file cache and returns a list of formatted tags from the front matter and the body.
Refactored the logic a bit to make it faster and easier to read.
@gentlegiantJGC
Copy link
Contributor

Looks like getAllTags was needed. It looks like you have used this in other places but did not call it there.

#83 Fixes this issue

@esm7
Copy link
Owner

esm7 commented May 20, 2022

Added in the just-released 2.0.0 version.

@esm7 esm7 closed this as completed May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants