I am thinking in doing something similar to authors list, than I can create personal descritptions and identify publications.
Do you think is possible to apply a similar code to authors, when importing zotero files?
Not sure about OP, but I am looking for this solution. My use case is:
I use zotero integration to import bibliographic data and annotations into Literature Notes.
I also have Scholar Notes (for key scholars), the title = author name.
I have an author property in the Literature Notes template that uses Zotero Integration [[{{authors}}]] so that it will link to a note of that name.
This works fine if the Literature Note only has one author, but Iām running into issues when there are multiple authors as it groups the different authors into the one property (even if I use a list).
Iām sure itās the function Iām using, but I havenāt figured out the fix yet.
I have a partial solution for you, although I am still working out how to adjust the code for a false outcome. This is likely not sophisticated at all (I am learning as I go), but it could help you figure it out.
I have a properties field that extracts the creator data, doing this in a list format so that the property will link to a scholar note (if one exists) to create a relationship between scholar and literature notes.
For my purposes (since itās in the list properties) I need to enter this multiple times, changing the zeros to 1, then 2 etc. This will then pick up the corresponding author in the list. I donāt have sources with more than four authors (or I wouldnāt need the data for them) so I have authors 0, 1, 2, and 3.
The limitation with this is when there isnāt data to export (i.e., I fewer authors than Iām looking for with the code) it returns āundefined undefinedā for each property lacking an author. I am hoping to figure out a solution for this soon. It also tries to link authors that do not have a scholar page (although Iām not bothered by that).
You could apply something like this in your template, formatting the exported fields as a heading. For example:
Links in the properties have to be surrounded by quotation marks outside the square brackets to be recognized as links. Like so: "[[{{creators[0].firstName + " " + creators[0].lastName}}]]".
Instead of hardcoding how many authors there are, or you expect, you can just use a for-loop to apply the same formatting to every creator.
I donāt format them as links in the properties, but hereās how I do it:
{%- set camelRegex = r/([a-z])([A-Z])/g %}
{%- for type, creators in creators | groupby("creatorType") %}
{% if creators.length > 1 %}{{type | replace(camelRegex, "$1 $2") | lower | trim}}s:{%- for creator in creators %}{% if creator.name %}
- {{creator.name}}{% else%}
- {{creator.firstName}} {{creator.lastName}} {% endif %}{%- endfor %} {% else -%}
{{type | replace(camelRegex, "$1-$2") | lower | trim}}:{%- for creator in creators %}{% if creator.name %} "{{creator.name}}"{% else%} "{{creator.firstName}} {{creator.lastName}}"{% endif -%}{%- endfor -%}{% endif -%}{% endfor %}
This looks extra convoluted because I am not putting all creators under ācreatorsā, but instead I have them grouped under their creatorType, which can be stuff like āauthorā, āeditorā, ādirectorā, ācontributerā etc.
I am also accounting for the fact that creators can have a creator.name which is a single line name, typically the case for organizations, or they can have firstName and lastName.
I am using the camelRegex to remove the camelCase, so it becomes āseries-editorā instead of āseriesEditorā, for example.
Lastly, I check for the number of creators in each creatorType group. If thereās only one, the key is singular, e.g. āauthor: John Doeā, and plural if there are several creators of that type, e.g.
authors:
- John Doe
- Jane Doe
The code is ugly, but the output is not.
For a simpler implementation of a non-grouped for-loop over all creators, formatted as links, you could do something like:
---
creators:
{% for creator in creators %}
{%- if creator.name -%}
- "[[{{creator.name}}]]"
{%- else -%}
- "[[{{creator.firstName}} {{creator.lastName}}]]"
{%- endif %}
{% endfor -%}
---