chore(share): use rendered template (missing include)

This commit is contained in:
Elian Doran 2025-06-09 11:12:02 +03:00
parent 2d3265136d
commit d6bb790e26
No known key found for this signature in database
2 changed files with 7 additions and 23 deletions

View File

@ -17,10 +17,7 @@ import type SAttachment from "./shaca/entities/sattachment.js";
import utils, { isDev, safeExtractMessageAndStackFromError } from "../services/utils.js"; import utils, { isDev, safeExtractMessageAndStackFromError } from "../services/utils.js";
import options from "../services/options.js"; import options from "../services/options.js";
import { t } from "i18next"; import { t } from "i18next";
import shareThemeRoot from "@triliumnext/share-theme/templates/page.ejs"; import shareTheme from "@triliumnext/share-theme/templates.js";
import shareThemeTreeItem from "@triliumnext/share-theme/templates/tree_item.ejs";
import shareThemeTocItem from "@triliumnext/share-theme/templates/toc_item.ejs";
import shareThemeCss from "@triliumnext/share-theme/styles.css";
import ejs from "ejs"; import ejs from "ejs";
function getSharedSubTreeRoot(note: SNote): { note?: SNote; branch?: SBranch } { function getSharedSubTreeRoot(note: SNote): { note?: SNote; branch?: SBranch } {
@ -214,22 +211,8 @@ function register(router: Router) {
} }
if (useDefaultView) { if (useDefaultView) {
const ejsResult = ejs.render(shareThemeRoot, { const result = shareTheme(opts);
shareThemeCss, res.send(result);
...opts
}, {
includer(originalPath, parsedPath: string) {
switch (originalPath) {
case "tree_item":
return { template: shareThemeTreeItem };
case "toc_item":
return { template: shareThemeTocItem };
default:
throw new Error(`Unable to find template for ${originalPath}`);
}
}
})
res.send(ejsResult);
} }
} }

View File

@ -1,5 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<%
const { note, subRoot, assetPath, appPath } = locals;
let content = locals.content;
%>
<head> <head>
<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">
@ -56,9 +60,6 @@ const customServerYml = `- url: "{protocol}://{domain}:{port}/etapi"
<% if (note.hasLabel("shareDisallowRobotIndexing")) { %> <% if (note.hasLabel("shareDisallowRobotIndexing")) { %>
<meta name="robots" content="noindex,follow" /> <meta name="robots" content="noindex,follow" />
<% } %> <% } %>
<style>
<%- shareThemeCss %>
</style>
<% <%
const pageTitle = `${note.title}${note.noteId !== subRoot.note.noteId ? ` - ${subRoot.note.title}` : ""}`; const pageTitle = `${note.title}${note.noteId !== subRoot.note.noteId ? ` - ${subRoot.note.title}` : ""}`;