Zotlit (previously Obsidian-Zotero) import templates?

Okay, I’ll go first. I managed to implement (most of) my nunjucks template for Zotero Integration in Eta for the Obsidian-Zotero plugin. See that post for details on the template.

In Obsidian-Zotero, there are three template files that get combined. There’s the template for the actual Literature note ( zt-note.eta), then the template for formatting individual annotations ( zt-annot.eta), and the a template for bulk import of annotations ( zt-annots.eta).

You need to specify the template folder path in Obsidian-Zotero settings, and then eject the template files into the template folder. After this, you can customize them.

Here’s the code and below are screenshots:

zt-note.eta:


# [<%= it.title %>](<%= it.backlink %>)


> [!NOTE]+ Info
> 
> [Open in Zotero](<%= it.backlink %>)
> [DOI](https://doi.org/<%= it.DOI %>)


> [!abstract]- Abstract
><%= it.abstractNote %>


## Notes
<%~  include("annots", it.annotations) %>

zt-annot.eta:

---
callout: false
---

<% if (it.imgEmbed) { %>
- <%= it.imgEmbed %>
<% } %>
<% if (it.comment) { %>
- <% if (it.comment.startsWith('todo ')) { %>[ ] **<%= it.comment.substring(5) %>:**<% } else { %>**<%= it.comment %>:**<% } %>  
	- ==<%= it.text %>== [p. <%= it.pageLabel %>](zotero://open-pdf/library/items/<%= it.parentItem %>?page=<%= it.pageLabel %>&annotation=<%= it.key %>)
<% } else if (it.text) { %>
- ==<%= it.text %>== [p. <%= it.pageLabel %>](zotero://open-pdf/library/items/<%= it.parentItem %>?page=<%= it.pageLabel %>&annotation=<%= it.key %>)
<% } %>

The yaml field callout: false is required here if you want to format the annotations as a bullet list, and not in individual callouts for each annotation. Without this, each line will start with >, thus breaking the formatting of the bullet list. I am not sure if this breaks some plugin behavior, but it might. See this: [FR] Simplify templating and use a single template file · Issue #101 · aidenlx/zotlit · GitHub

zt-annots.eta:

<% for (const color of ['#e56eee', '#5fb236', '#f19837', '#2ea8e5', '#ffd400', '#a28ae5', '#ff6666', '#aaaaaa']) { %>
<% let annotations = it.filter(annotation => annotation.color === color) %>
<% if (annotations.length > 0) { %>

<% if (color === '#e56eee') { %>
### ⚡ Hypotheses
<% } %>
<% if (color === '#5fb236') { %>
### 💡 Main ideas and conclusions
<% } %>
<% if (color === '#f19837') { %>
### ⚙️ Method
<% } %>
<% if (color === '#2ea8e5') { %>
### ❔ Questions
<% } %>
<% if (color === '#ffd400') { %>
### ⭐ Important
<% } %>
<% if (color === '#a28ae5') { %>
### 🧩 Definitions and concepts
<% } %>
<% if (color === '#ff6666') { %>
### ⛔ Weaknesses and caveats
<% } %>
<% if (color === '#aaaaaa') { %>
### 📣 Survey instruments
<% } %>

<% for (const annotation of annotations) { %>
<%~ include("annotation", annotation) %>
<% } %>
<% } %>
<% } %>

As for the yaml fields you want to import from Zotero, those have to be set in the plugin settings under Mapping:

Screenshots

Here’s what the result looks like:



4 Likes