samwho / obsidian-wikidata-importer

A plugin for importing data from Wikidata into your Obsidian vault.
MIT License
25 stars 6 forks source link

Search Entity from note title if no entity id is set #10

Closed smor closed 3 months ago

smor commented 3 months ago

When there is no wikidata entry id YAML frontmatter property, the plugin will launch a search in the modal for entities matching the file name. If the user finds a satisfying entity, a click will create the Wikidata entity file.

Note

When using wikidata entry id, the plugin adds the properties to the current file containing the id. With my update, it runs a search and allows the user to import the Wikidata Entity using the other command's behavior, creating the file in db/${label}. Thus, the current file is not modified. This may seem weird at first sight, but as I see it this behavior is not much of an issue, for the following reasons.

First, I like to keep all Wikidata items nicely stored in the db folder to be able to keep the internal links clean and working. I can then click on an item in one of the Wikidata properties, wgucg creates the file is missing, them update it as required, including adding Wikidata (which is made easier with this PR). This way, the behavior is "transparent", as the active file is the same as the "Wikidata file".

Then, if one takes the trouble to manually insert a YAML frontmatter property into a file, she would naturally expect the file to be updated, not a new one to be created. Then, the actual behavior with the wikidata entity id (update the current file) is preserved.

Possible workarounds if another behavior is preferred would be to either :

Demo

https://github.com/samwho/obsidian-wikidata-importer/assets/39006/359c1a5f-d7eb-4879-96df-8e1fbf389e84

Closes #1