Files
Trilium/src/templates/tree_item.ejs
2023-09-27 16:20:04 -04:00

26 lines
1.1 KiB
Plaintext

<%
const linkClass = `type-${note.type}` + (activeNote.noteId === note.noteId ? " active" : "");
const isExternalLink = note.hasLabel("shareExternal");
const linkHref = isExternalLink ? note.getLabelValue("shareExternal") : `./${note.shareId}`;
const target = isExternalLink ? ` target="_blank" rel="noopener noreferrer"` : "";
%>
<% if (note.noteId !== subRoot.noteId) { %>
<a class="<%= linkClass %>" href="<%= linkHref %>"<%= target %>>
<% if (note.hasVisibleChildren()) { %><button class="collapse-button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon right-triangle"><path d="M3 8L12 17L21 8"></path></svg></button><% } %>
<%= note.title %>
</a>
<% } %>
<% if (note.hasVisibleChildren()) { %>
<ul>
<% note.getVisibleChildNotes().forEach(function (childNote) { %>
<% const hasChildren = childNote.hasVisibleChildren(); %>
<li class="<% if (hasChildren) { %>submenu-<% } %>item">
<%- include('tree_item', {note: childNote, subRoot: subRoot}) %>
</li>
<% }) %>
</ul>
<% } %>