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 headingRe = /(<h[1-6]>)(.+?)(<\/h[1-6]>)/g;
|
||||||
const headingMatches = [...content.matchAll(headingRe)];
|
const headingMatches = [...content.matchAll(headingRe)];
|
||||||
const slugify = (text) => text.toLowerCase().replace(/[^\w]/g, "-");
|
const slugify = (text) => text.toLowerCase().replace(/[^\w]/g, "-");
|
||||||
|
const hasTree = subRoot.note.hasVisibleChildren();
|
||||||
content = content.replaceAll(headingRe, (...match) => {
|
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]}`);
|
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];
|
return match[0];
|
||||||
@ -135,7 +136,7 @@ content = content.replaceAll(headingRe, (...match) => {
|
|||||||
<input type="text" class="search-input" placeholder="Search...">
|
<input type="text" class="search-input" placeholder="Search...">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% if (subRoot.note.hasVisibleChildren()) { %>
|
<% if (hasTree) { %>
|
||||||
<nav id="menu">
|
<nav id="menu">
|
||||||
<%
|
<%
|
||||||
const ancestors = [];
|
const ancestors = [];
|
||||||
@ -198,7 +199,9 @@ content = content.replaceAll(headingRe, (...match) => {
|
|||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<%- include("prev_next", { note: note, subRoot: subRoot }) %>
|
<% if (hasTree) { %>
|
||||||
|
<%- include("prev_next", { note: note, subRoot: subRoot }) %>
|
||||||
|
<% } %>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<%
|
<%
|
||||||
|
Loading…
x
Reference in New Issue
Block a user