mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
fix(share): crash if sharing single note without tree
This commit is contained in:
parent
dd6660a6cd
commit
3b81d00de7
@ -100,6 +100,7 @@ const themeClass = currentTheme === "light" ? " theme-light" : " theme-dark";
|
||||
const headingRe = /(<h[1-6]>)(.+?)(<\/h[1-6]>)/g;
|
||||
const headingMatches = [...content.matchAll(headingRe)];
|
||||
const slugify = (text) => text.toLowerCase().replace(/[^\w]/g, "-");
|
||||
const hasTree = subRoot.note.hasVisibleChildren();
|
||||
content = content.replaceAll(headingRe, (...match) => {
|
||||
match[0] = match[0].replace(match[3], `<a id="${slugify(match[2])}" class="toc-anchor" name="${slugify(match[2])}" href="#${slugify(match[2])}">#</a>${match[3]}`);
|
||||
return match[0];
|
||||
@ -135,7 +136,7 @@ content = content.replaceAll(headingRe, (...match) => {
|
||||
<input type="text" class="search-input" placeholder="Search...">
|
||||
</div>
|
||||
</div>
|
||||
<% if (subRoot.note.hasVisibleChildren()) { %>
|
||||
<% if (hasTree) { %>
|
||||
<nav id="menu">
|
||||
<%
|
||||
const ancestors = [];
|
||||
@ -198,7 +199,9 @@ content = content.replaceAll(headingRe, (...match) => {
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<%- include("prev_next", { note: note, subRoot: subRoot }) %>
|
||||
<% if (hasTree) { %>
|
||||
<%- include("prev_next", { note: note, subRoot: subRoot }) %>
|
||||
<% } %>
|
||||
</footer>
|
||||
</div>
|
||||
<%
|
||||
|
Loading…
x
Reference in New Issue
Block a user