frthjf / obsidian-zotero-sync-client

A Zotero Sync client for Obsidian
GNU Affero General Public License v3.0
24 stars 3 forks source link

Template modification : zotero tags #3

Closed marckcolina closed 1 year ago

marckcolina commented 1 year ago

Hello ! I have tried to modify the template so the tags could be imported as the notes.

even if the number of tags come ok (i had 7 tags in a document and the number of references were ok in obsidian) the tags came empty, showing only « object » as reference for each… have you tried this before ? Any ideas ? Thanks !

frthjf commented 1 year ago

Hi @marckcolina! It might be that you are trying to print the entire tag object which consists of the tag name and the type. You should be able to map over them to extract the names, for example, you might try something like this:

n += '\n\nTags: ' + data.tags.map(t => '#' + t.tag).join(', ') + '\n';

If that does not work, could you share the code example and data?

marckcolina commented 1 year ago

Hi frthjf. That worked perfectly.

I've tried something a lot more complicated, even if it worked at the end, but not pretty at all. It was something like that :

if (data.tags && data.tags.length == 1) { n += '#'+data.tags[0]['tag']; }

and to repeat for number of tags...

Have to say, that i know nothing at all in java language, i'm a social sciences researcher !

thank you very much

marckcolina commented 1 year ago

would you kindly help me with the necessary code to import the abstract as well ? Thanks in advance...

frthjf commented 1 year ago

Fair enough!

You can find out how to access the data by switching to the View JSON data option (see screenshot below).

For example, for the abstract you'll likely want abstractNote, so something like this:

n += '\n\nAbstract: ' + data.abstractNote + '\n\n'

image

marckcolina commented 1 year ago

Dear frthjf, sorry to disturb you again. Do you know why some references from the same author don't get imported into Obsidian ? I'm having this issue with several articles. For exemple, in these images you'll see that i have two publications from "Motta" in Zotero, but in obsidian i only get one of them... Thank you in advance !

Capture d’écran 2023-10-30 à 16 33 26

Capture d’écran 2023-10-30 à 16 33 14

frthjf commented 1 year ago

I am not sure, do both articles appear in the plugin settings?

marckcolina commented 1 year ago

As I can see, only one of them appears... The other one, (Motta, 2015) doesn't appear at all. And it is not the only case. You'll find the two articles in CSV attached in the case it helps... and thanks again...

Capture d’écran 2023-10-30 à 17 44 43

Motta.csv

frthjf commented 1 year ago

I've added the reference, but I am afraid I can't reproduce the issue as it appears in my list.

One thing you could try is to write return data.key; above everything else in the top-left editor and check if the key JWNW5RMY and 45P2GC8J are part of the list. If they are, then check the JSON view to see if data.creators field is empty. The if (data.creators) { means that any entries with a missing data.creators are omitted.

marckcolina commented 1 year ago

Thanks ! Well, i've done all that. I found the issue. If the creator is not an "author" and at the top of the list in Zotero, the plugin omite it (in this case, first where the editors than the author).

I changed that in zotero and the reference came effectively into Obsidian...

Capture d’écran 2023-10-30 à 18 26 46

Capture d’écran 2023-10-30 à 18 27 58

Thanks again !

frthjf commented 1 year ago

Ok great, glad you've found the issue.

marckcolina commented 1 year ago

Instead, there's another one. Institutional Authors are not imported (those with no difference between first and last name)... But i'll change them to normal author with no first name, that will fix the issue as well.

Capture d’écran 2023-10-30 à 18 42 18