mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
fix(share): custom share templates no longer working
This commit is contained in:
parent
79dae44dbc
commit
b39119119b
Binary file not shown.
@ -33,4 +33,13 @@ describe("Share API test", () => {
|
|||||||
expect(cannotSetHeadersCount).toBe(0);
|
expect(cannotSetHeadersCount).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("renders custom share template", async () => {
|
||||||
|
const response = await supertest(app)
|
||||||
|
.get("/share/pQvNLLoHcMwH")
|
||||||
|
.expect(200);
|
||||||
|
expect(cannotSetHeadersCount).toBe(0);
|
||||||
|
expect(response.text).toContain("Content Start");
|
||||||
|
expect(response.text).toContain("Content End");
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -136,7 +136,7 @@ function renderImageAttachment(image: SNote, res: Response, attachmentName: stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
function register(router: Router) {
|
function register(router: Router) {
|
||||||
function renderNote(note: SNote, req: Request, res: Response) {
|
async function renderNote(note: SNote, req: Request, res: Response) {
|
||||||
if (!note) {
|
if (!note) {
|
||||||
console.log("Unable to find note ", note);
|
console.log("Unable to find note ", note);
|
||||||
res.status(404).render("share/404");
|
res.status(404).render("share/404");
|
||||||
@ -197,11 +197,10 @@ function register(router: Router) {
|
|||||||
try {
|
try {
|
||||||
const content = templateNote.getContent();
|
const content = templateNote.getContent();
|
||||||
if (typeof content === "string") {
|
if (typeof content === "string") {
|
||||||
import("ejs").then((ejs) => {
|
const ejs = await import("ejs");
|
||||||
const ejsResult = ejs.render(content, opts, { includer });
|
const ejsResult = ejs.render(content, opts, { includer });
|
||||||
res.send(ejsResult);
|
res.send(ejsResult);
|
||||||
useDefaultView = false; // Rendering went okay, don't use default view
|
useDefaultView = false; // Rendering went okay, don't use default view
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
const [errMessage, errStack] = safeExtractMessageAndStackFromError(e);
|
const [errMessage, errStack] = safeExtractMessageAndStackFromError(e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user