mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
add shareHTML relation
This commit is contained in:
parent
be35584f9a
commit
d483b6e840
@ -66,6 +66,7 @@ export default [
|
|||||||
{ type: "label", name: "shareDisallowRobotIndexing" },
|
{ type: "label", name: "shareDisallowRobotIndexing" },
|
||||||
{ type: "label", name: "shareCredentials" },
|
{ type: "label", name: "shareCredentials" },
|
||||||
{ type: "label", name: "shareIndex" },
|
{ type: "label", name: "shareIndex" },
|
||||||
|
{ type: "label", name: "shareHTMLLocation" },
|
||||||
{ type: "label", name: "displayRelations" },
|
{ type: "label", name: "displayRelations" },
|
||||||
{ type: "label", name: "hideRelations" },
|
{ type: "label", name: "hideRelations" },
|
||||||
{ type: "label", name: "titleTemplate", isDangerous: true },
|
{ type: "label", name: "titleTemplate", isDangerous: true },
|
||||||
@ -105,6 +106,7 @@ export default [
|
|||||||
{ type: "relation", name: "renderNote", isDangerous: true },
|
{ type: "relation", name: "renderNote", isDangerous: true },
|
||||||
{ type: "relation", name: "shareCss" },
|
{ type: "relation", name: "shareCss" },
|
||||||
{ type: "relation", name: "shareJs" },
|
{ type: "relation", name: "shareJs" },
|
||||||
|
{ type: "relation", name: "shareHTML" },
|
||||||
{ type: "relation", name: "shareTemplate" },
|
{ type: "relation", name: "shareTemplate" },
|
||||||
{ type: "relation", name: "shareFavicon" }
|
{ type: "relation", name: "shareFavicon" }
|
||||||
];
|
];
|
||||||
|
@ -1,7 +1,31 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<% const hasTree = subRoot.note.hasVisibleChildren(); %>
|
<%
|
||||||
|
const hasTree = subRoot.note.hasVisibleChildren();
|
||||||
|
|
||||||
|
// Collect HTML snippets by location
|
||||||
|
const htmlSnippetsByLocation = {};
|
||||||
|
for (const htmlRelation of note.getRelations("shareHTML")) {
|
||||||
|
const htmlNote = htmlRelation.targetNote;
|
||||||
|
if (htmlNote) {
|
||||||
|
let location = htmlNote.getLabelValue("shareHTMLLocation") || "content:end";
|
||||||
|
// Default to :end if no position specified
|
||||||
|
if (!location.includes(":")) {
|
||||||
|
location = location + ":end";
|
||||||
|
}
|
||||||
|
if (!htmlSnippetsByLocation[location]) {
|
||||||
|
htmlSnippetsByLocation[location] = [];
|
||||||
|
}
|
||||||
|
htmlSnippetsByLocation[location].push(htmlNote.getContent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const renderSnippets = (location) => {
|
||||||
|
const snippets = htmlSnippetsByLocation[location];
|
||||||
|
return snippets ? snippets.join("\n") : "";
|
||||||
|
};
|
||||||
|
%>
|
||||||
|
<%- renderSnippets("head:start") %>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
@ -53,6 +77,7 @@
|
|||||||
<meta name="twitter:image" content="<%= openGraphImage %>">
|
<meta name="twitter:image" content="<%= openGraphImage %>">
|
||||||
<!-- Meta Tags Generated via https://opengraph.dev -->
|
<!-- Meta Tags Generated via https://opengraph.dev -->
|
||||||
<meta name="theme-color" content="<%= openGraphColor %>">
|
<meta name="theme-color" content="<%= openGraphColor %>">
|
||||||
|
<%- renderSnippets("head:end") %>
|
||||||
</head>
|
</head>
|
||||||
<%
|
<%
|
||||||
const customLogoId = subRoot.note.getRelation("shareLogo")?.value;
|
const customLogoId = subRoot.note.getRelation("shareLogo")?.value;
|
||||||
@ -72,6 +97,7 @@ content = content.replaceAll(headingRe, (...match) => {
|
|||||||
});
|
});
|
||||||
%>
|
%>
|
||||||
<body data-note-id="<%= note.noteId %>" class="type-<%= note.type %><%= themeClass %>" data-ancestor-note-id="<%= subRoot.note.noteId %>">
|
<body data-note-id="<%= note.noteId %>" class="type-<%= note.type %><%= themeClass %>" data-ancestor-note-id="<%= subRoot.note.noteId %>">
|
||||||
|
<%- renderSnippets("body:start") %>
|
||||||
<div id="mobile-header">
|
<div id="mobile-header">
|
||||||
<a href="<%= shareRootLink %>">
|
<a href="<%= shareRootLink %>">
|
||||||
<img src="<%= logoUrl %>" width="32" height="<%= mobileLogoHeight %>" alt="Logo" />
|
<img src="<%= logoUrl %>" width="32" height="<%= mobileLogoHeight %>" alt="Logo" />
|
||||||
@ -121,8 +147,8 @@ content = content.replaceAll(headingRe, (...match) => {
|
|||||||
</div>
|
</div>
|
||||||
<div id="right-pane">
|
<div id="right-pane">
|
||||||
<div id="main">
|
<div id="main">
|
||||||
|
|
||||||
<div id="content" class="type-<%= note.type %><% if (note.type === "text") { %> ck-content<% } %><% if (isEmpty) { %> no-content<% } %>">
|
<div id="content" class="type-<%= note.type %><% if (note.type === "text") { %> ck-content<% } %><% if (isEmpty) { %> no-content<% } %>">
|
||||||
|
<%- renderSnippets("content:start") %>
|
||||||
<h1 id="title"><%= note.title %></h1>
|
<h1 id="title"><%= note.title %></h1>
|
||||||
<% if (isEmpty && (!note.hasVisibleChildren() && note.type !== "book")) { %>
|
<% if (isEmpty && (!note.hasVisibleChildren() && note.type !== "book")) { %>
|
||||||
<p>This note has no content.</p>
|
<p>This note has no content.</p>
|
||||||
@ -132,6 +158,7 @@ content = content.replaceAll(headingRe, (...match) => {
|
|||||||
%>
|
%>
|
||||||
<%- content %>
|
<%- content %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<%- renderSnippets("content:end") %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if (note.hasVisibleChildren() || note.type === "book") { %>
|
<% if (note.hasVisibleChildren() || note.type === "book") { %>
|
||||||
@ -205,5 +232,6 @@ content = content.replaceAll(headingRe, (...match) => {
|
|||||||
<% } %>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<%- renderSnippets("body:end") %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user