Fix metadata isFirstImport issue

This should fix the issue with the index & metadata section being overwritten on a second import.
This commit is contained in:
Luke 2023-06-23 20:16:16 +02:00 committed by GitHub
parent 7caffb5ef1
commit dd1438a76e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 10 deletions

View File

@ -1,11 +1,12 @@
--- ---
tags: {%- if itemType == "book" %} tags: {% if itemType == "book" %}
- 📥/📚{% else %} - 📥/📚{% else %}
- 📥/📑{% endif %} - 📥/📑{% endif %}
alias: " alias: "
{%- if creators -%} {%- if creators -%}
{{creators[0].lastName}} {{creators[0].lastName}}
{%- if creators|length > 1 %} et al.{% endif -%} {%- if creators|length == 2 %} & {{creators[1].lastName}}{% endif -%}
{%- if creators|length > 2 %} et al.{% endif -%}
{%- endif -%} {%- endif -%}
{%- if date %} ({{date | format("YYYY")}}){% endif -%} {%- if date %} ({{date | format("YYYY")}}){% endif -%}
{%- if shortTitle %} {{shortTitle | safe}} {%- else %} {{title | safe}} {%- endif -%} {%- if shortTitle %} {{shortTitle | safe}} {%- else %} {{title | safe}} {%- endif -%}
@ -13,20 +14,25 @@ alias: "
date: {{importDate|format("YYYY-MM-DD")}} date: {{importDate|format("YYYY-MM-DD")}}
lastmod: {{importDate|format("YYYY-MM-DD")}} lastmod: {{importDate|format("YYYY-MM-DD")}}
--- ---
{% if isFirstImport %} {#- METADATA AND PERMANENT INDEX -#}
{#- This part only gets inserted once -#}
{#- You can use this space to take permanent notes, e.g. to create an index or write a summary, or link to other notes #}
{% persist "notes" %}{% if isFirstImport %}
# {{title}} # {{title}}
## 📇 Index ## 📇 Index
- -
> [!meta]+ Metadaten {% for attachment in attachments | filterby("path", "endswith", ".pdf") %}[PDF{% if not loop.first %} {{loop.index}}{% endif %}]({{attachment.desktopURI|replace("/select/", "/open-pdf/")}}){% if not loop.last %}, {% endif %}{% endfor %} > [!important]+ Metadaten {% for attachment in attachments | filterby("path", "endswith", ".pdf") %}[PDF{% if not loop.first %} {{loop.index}}{% endif %}]({{attachment.desktopURI|replace("/select/", "/open-pdf/")}}){% if not loop.last %}, {% endif %}{% endfor %}
> {{bibliography}} > {{bibliography}}
> >
> - **Projekte**:: > - **Projekte**::
> - **Keywords**:: > - **Keywords**::
> - [Zotero öffnen]({{select}}) > - [Zotero öffnen]({{select}})
> {% endif %}{% persist "annotations" %} > {% endif %}{% endpersist %}{% persist "annotations" %}
{#- COLOR VARIABLES -#}
{%- {%-
set zoteroColors = { set zoteroColors = {
"#2ea8e5": "blue", "#2ea8e5": "blue",
@ -45,12 +51,14 @@ lastmod: {{importDate|format("YYYY-MM-DD")}}
"blue": "⭐ Main", "blue": "⭐ Main",
"green": "✅ Definition", "green": "✅ Definition",
"purple": "🧩 Methodology", "purple": "🧩 Methodology",
"yellow": "📚 Investigate", "yellow": "📚 Further Reading",
"red": "⭕ Caveats/Lookup", "red": "⭕ Questions",
"magenta": " Info",
"other": "Misc" "other": "Misc"
} }
-%} -%}
{#- ANNOTATION TYPES -#}
{%- macro calloutHeader(type) -%} {%- macro calloutHeader(type) -%}
{%- switch type -%} {%- switch type -%}
{%- case "highlight" -%} {%- case "highlight" -%}
@ -62,6 +70,7 @@ lastmod: {{importDate|format("YYYY-MM-DD")}}
{%- endswitch -%} {%- endswitch -%}
{%- endmacro %} {%- endmacro %}
{#- SET CUSTOM ANNOTATION COLORS -#}
{%- set newAnnot = [] -%} {%- set newAnnot = [] -%}
{%- set newAnnotations = [] -%} {%- set newAnnotations = [] -%}
{%- set annotations = annotations | filterby("date", "dateafter", lastImportDate) %} {%- set annotations = annotations | filterby("date", "dateafter", lastImportDate) %}
@ -112,10 +121,10 @@ lastmod: {{importDate|format("YYYY-MM-DD")}}
{%- endif %} {%- endif %}
{%- if annot.comment %} {%- if annot.comment %}
> **{{annot.comment|nl2br}}** > **{{annot.comment|nl2br}}**
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- endfor -%} {%- endfor -%}
{% endif %} {% endif -%}
{% endpersist -%} {% endpersist -%}