### Adding Tags to Note Properties Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config Example of adding a 'tags' field to the note frontmatter. It demonstrates using square brackets to ensure proper parsing of tags with spaces. ```yaml tags: [<%= it.tags %>] ``` -------------------------------- ### Eta Template with Extra Lines Source: https://zotlit.aidenlx.top/faq/slurp This example shows how Eta preserves newlines around script blocks, potentially introducing extra empty lines in the output. ```html - Hello <% if (true) { %> - World <% } %> ``` -------------------------------- ### Get Abstract in a Single Paragraph Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Retrieves the abstract and formats it into a single paragraph by replacing newline characters with spaces. ```ejs ## Abstract <%= it.abstractNote.first().replace(/[ ]+/g, " ") %> ``` -------------------------------- ### Get Literature Import Date Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Displays the date when the literature was imported into Zotero. ```ejs import-date: <%= it.dateAccessed %> ``` -------------------------------- ### Get List of Authors in Full Names Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Retrieves a list of all authors in their full names. ```ejs authors: [<%= it.authors %>] ``` -------------------------------- ### Get List of Collections Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Retrieves a list of all collections the literature belongs to. ```ejs collections: [<%= it.collections %>] ``` -------------------------------- ### Get Publish Date Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Displays the publication date of the literature. ```ejs publish-date: <%= it.date %> ``` -------------------------------- ### Get List of Authors by First Name Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Retrieves a list of authors' first names. Note that first names may not always be available. ```ejs authors: [<%= it.authors.map(v => v.firstName) %>] ``` -------------------------------- ### Get Author Shorthand in Annotation Template Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Displays the author shorthand within an annotation template, using parent literature information. ```ejs from <%= it.docItem.authorsShort %> ``` -------------------------------- ### Get Collection Path Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Retrieves the full path of collections the literature belongs to. ```ejs collections: [<%= it.collections.map(c => c.path) %>] ``` -------------------------------- ### Annotation Template with Color Callout Type Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config This example modifies the default annotation template to use the annotation's color name as the callout type instead of 'note'. ```html [!<%= it.colorName %>] Page <%= it.pageLabel %> <%= it.imgEmbed %><%= it.text %> <% if (it.comment) { %> --- <%= it.comment %> <% } %> ``` -------------------------------- ### JavaScript Switch Statement in Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Use a switch statement to execute different code blocks based on the value of a variable. This example handles different 'it.rating' values, with a default case. ```html <% switch (it.rating) { case 5: %>Excellent<% break; case 4: %>Good<% break; case 3: %>Average<% break; case 2: %>Below Average<% break; default: %>No rating available<% }%> ``` -------------------------------- ### Get List of Authors by Last Name Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Retrieves a list of authors' last names. Note that last names may not always be available. ```ejs authors: [<%= it.authors.map(v => v.lastName) %>] ``` -------------------------------- ### Get Author Shorthand Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Retrieves the shorthand representation of authors. Renders as 'Gerasimavicius et al.'. ```ejs authors: <%= it.authorsShort %> ``` -------------------------------- ### Get Top-Level Collections Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Retrieves a unique list of top-level collections the literature belongs to. ```ejs top-collections: [<%= [...new Set(it.collections.map(c => c.path[0]))] %>] ``` -------------------------------- ### Template to Filter Authors by Last Name Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Apply the `filter` method to the 'authors' array to conditionally include only authors whose last name starts with 'A'. This demonstrates data filtering within templates. ```eta <%= it.authors.filter(author => author.lastName.startsWith("A")) %> ``` -------------------------------- ### Get Collection Path with Custom Separator Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Retrieves the full path of collections, joining path segments with a custom separator (e.g., '/'). ```ejs collections: [<%= it.collections.map(c => c.path.join("/")) %>] ``` -------------------------------- ### Template to Iterate and Render Authors Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Utilize the `forEach` method to loop through the 'authors' array and render each author, typically as a list item. This uses eta's 'Scriptlet' tag `<%- ... %>` for control flow without outputting newlines. ```eta - authors: <%- it.authors.forEach(author => { %> - <%= author -%> <% }) %> ``` -------------------------------- ### Configure Background Connection in Zotero Source: https://zotlit.aidenlx.top/getting-started/basic-usage/annotation-view Enables the notification service in Zotero for ZotLit integration. Ensure the port number matches the one configured in Obsidian. ```markdown Settings > ZotLit > Notify > Enable Notify ``` -------------------------------- ### Open Zotero Annotation View Source: https://zotlit.aidenlx.top/getting-started/basic-usage/annotation-view Opens the Zotero Annotation View in a side panel within Obsidian. This is the primary command to access your annotations. ```markdown Open Zotero Annotation View in Side Panel ``` -------------------------------- ### Configure Background Connection in Obsidian Source: https://zotlit.aidenlx.top/getting-started/basic-usage/annotation-view Enables background connection for ZotLit within Obsidian. This setting is required for the 'Follow Zotero Reader' feature. ```markdown Settings Tab > Connect > Backgound Connect > Enable ``` -------------------------------- ### Eta Template Rendering with Extra Lines Source: https://zotlit.aidenlx.top/faq/slurp Illustrates the rendered output of the previous Eta template, showing an unexpected empty line. ```markdown - Hello - World ``` -------------------------------- ### Basic Note Filename Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Use this template to include only the title in the note filename. It utilizes the eta output tag `<%= ... %>` to render the 'title' variable. ```eta <%= it.title %>.md ``` -------------------------------- ### Eta Template Rendering After Trimming Source: https://zotlit.aidenlx.top/faq/slurp Shows the rendered output of the Eta template using the -%> tag, where the extra empty line has been removed. ```markdown - Hello - World ``` -------------------------------- ### Basic Note Content Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics A simple template to display the date and authors. This can result in incomplete output if date or authors are undefined. ```html <%= it.date %>; <%= it.authors %> ``` -------------------------------- ### Template to Join Authors with Separator Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Use the `join` method on the 'authors' array to create a single string with a specified separator (e.g., ', '). This is useful for formatted lists. ```eta <%= it.authors.join(", ") %> ``` -------------------------------- ### Simple Note Filename Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config Replace the default template to include only the title in the note filename. Press 'Apply' after setting this template. ```html <%= it.title %>.md ``` -------------------------------- ### Eta Template with Newline Trimming (-%>) Source: https://zotlit.aidenlx.top/faq/slurp Demonstrates using the -%> tag to trim the newline after a script block, preventing extra empty lines in the output. ```html - Hello <% if (true) { -%> - World <% } %> ``` -------------------------------- ### Default Note Properties Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config This is the default YAML template for setting note frontmatter. It includes variables for title and citekey. ```yaml title: "<%= it.title %>" citekey: "<%= it.citekey %>" ``` -------------------------------- ### Template to Display First or Last Author Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Access specific elements from the 'authors' array using index notation (e.g., `[0]`) or the `.at()` method. Obsidian provides `.first()` and `.last()` as helpers. ```eta <%= it.authors[0] /** or it.authors.at(0) */ %> <%= it.authors.at(-1) %> ``` -------------------------------- ### Default Note Content Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config The default template for note content. It includes the note title, a link to the Zotero entry, and a placeholder for annotations. ```html # <%= it.title %> [Zotero](<%= it.backlink %>) <%= it.fileLink %> <%~ include("annots", it.annotations) %> ``` -------------------------------- ### Template to Display All Authors Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Renders a comma-separated list of authors from the 'authors' array. This is a basic usage of the 'it' variable containing array data. ```eta <%= it.authors %> ``` -------------------------------- ### Default Annotation Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config The default template for rendering individual annotations. It displays the page number, image embed, excerpt text, and an optional comment. ```html [!note] Page <%= it.pageLabel %> <%= it.imgEmbed %><%= it.text %> <% if (it.comment) { %> --- <%= it.comment %> <% } %> ``` -------------------------------- ### Note Filename Template with Suffix Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Append a custom suffix to the note filename by concatenating strings within the eta output tag. This demonstrates using JavaScript expressions for dynamic filenames. ```eta <%= it.title + "_suffix" %>.md ``` -------------------------------- ### Annotation Template with Divider Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config This template demonstrates how to add a horizontal divider between each annotation when batch importing. It includes the 'annotation' template and then adds a '---' separator. ```ejs <% for (const annotation of it) { %> <%~ include("annotation", annotation) %> --- <% } %> ``` -------------------------------- ### Default Value for Note Filename Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Provides a default value for the note filename using the nullish coalescing operator `??`. It selects the first defined value among `citekey`, `DOI`, `title`, and `key`. ```html <%= it.citekey ?? it.DOI ?? it.title ?? it.key %>.md ``` -------------------------------- ### Group Annotations by Color Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Groups annotations by their color name and iterates through each group to display them. Requires the 'annotation' partial. ```ejs <% const byColor = Object.groupBy(it, (annot) => annot.colorName); for (const color in byColor) { -%> ## <%= color %> <%_ for (const annot of byColor[color]) { %> <%~ include("annotation", annot) %> <%_ } %> <% } %> ``` -------------------------------- ### Group Annotations by Color with Customized Labels Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Groups annotations by color and displays them using customized labels defined in a map. It handles both predefined and unexpected colors. ```ejs <% const byColor = Object.groupBy(it, (annot) => annot.colorName); const label = { "red": "Important", "orange": "Question", "yellow": "Summary", "gray": "Comment", "green": "Answer", "cyan": "Task", "blue": "Definition", "navy": "Source", "purple": "Quote", "brown": "To Do", "magenta": "Fact", }; const colorSet = new Set([...Object.keys(label), ...Object.keys(byColor)]); for (const color of colorSet) { if (!(color in byColor)) continue -%> ### <%= label[color] ?? color %> <%_ for (const annot of byColor[color]) { %> <%~ include("annotation", annot) %> <%_ } %> <% } %> ``` -------------------------------- ### Conditional Note Content Rendering Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Uses an `if` statement to conditionally render the date and first author only if both are defined. Prevents rendering a leading semicolon when data is missing. ```html <% if ( it.date && it.authors.first() ) { %> <%= it.date %>; <%= it.authors.first() %> <% } %> ``` -------------------------------- ### Safe Property Access for Author's Last Name Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Safely accesses the `lastName` property of the first author using the `?.` operator. Prevents errors if the first author is undefined. ```html <%= it.authors.first()?.lastName %> ``` -------------------------------- ### Conditional Note Content with Else Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Uses an `if...else` statement to render the date and first author with a semicolon if both are defined, otherwise renders them without a semicolon. Handles cases where date or author might be missing. ```html <% if ( it.date && it.authors[0] ) { %> <%= it.date %>; <%= it.authors[0] %> <% } else { %> <%= it.date %><%= it.authors[0] %> <% } %> ``` -------------------------------- ### Include Only Manually Created Tags Source: https://zotlit.aidenlx.top/how-to/template-cheatsheet Filters and includes only manually created tags (type 0) in the output. This was the default behavior before v1.1.0. ```ejs tags: [<%= it.tags.filter(t => t.type === 0) %>] ``` -------------------------------- ### JavaScript If-Else Statement in Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Use an if-else statement to render one piece of content if a condition is true, and another if it's false. This snippet shows content for 'it.date' or a fallback message. ```html <% if (it.date) { %> The date is <%= it.date %> <% } else { %> Date is not available <% } %> ``` -------------------------------- ### Escaping Tags with JSON.stringify Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config This template snippet shows how to use JSON.stringify to escape tags that may contain special characters like brackets or commas, ensuring they are parsed correctly. ```yaml tags: <%= JSON.stringify(it.tags) %> ``` -------------------------------- ### Including Abstract in Note Content Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config This template snippet demonstrates how to include the abstract of a literature note using the 'abstractNote' variable. ```html <%= it.abstractNote.first() %> ``` -------------------------------- ### Default Annotation Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config This is the default template for processing multiple annotations. It iterates through each annotation and includes the 'annotation' template for individual processing. ```ejs <% for (const annotation of it) { %> <%~ include("annotation", annotation) %> <% } %> ``` -------------------------------- ### Disabling YAML Formatter Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config Add this line to your template to disable Zotlit's built-in YAML formatter and manage frontmatter formatting manually. ```yaml --- raw: true --- ``` -------------------------------- ### JavaScript If-Else If-Else Statement in Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Use an if-else if-else structure to check multiple conditions sequentially. This snippet prioritizes 'it.date', then 'it.year', and provides a final fallback. ```html <% if (it.date) { %> The date is <%= it.date %> <% } else if (it.year) { %> The year is <%= it.year %> <% } else { %> Neither date nor year is available <% } %> ``` -------------------------------- ### Disable Callout Wrapper for Annotations Source: https://zotlit.aidenlx.top/getting-started/basic-usage/update-notes Opt-out of wrapping annotations with callouts by adding this YAML frontmatter to your annotation template. ```yaml --- callout: false --- ``` -------------------------------- ### JavaScript If Statement in Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Use an if statement to conditionally render content when a specific data property is defined. This snippet renders text only if 'it.date' exists. ```html <% if (it.date) { %> The date is <%= it.date %> <% } %> ``` -------------------------------- ### Adding Literature Title to Annotation Template Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-config This snippet shows how to include the title of the parent literature item within the annotation template using the 'docItem.title' variable. ```html [!note] Page <%= it.pageLabel %> <%= it.docItem.title %> <%= it.imgEmbed %><%= it.text %> <% if (it.comment) { %> --- <%= it.comment %> <% } %> ``` -------------------------------- ### JavaScript Ternary Operator for Variable Assignment Source: https://zotlit.aidenlx.top/getting-started/basic-usage/template-basics Use the ternary operator as a concise shorthand for simple if-else assignments. This snippet assigns 'it.author' or 'Unknown' to a variable based on its existence. ```html The author is <%= it.author ? it.author : 'Unknown' %> ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.