mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +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);
|
||||
});
|
||||
|
||||
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 renderNote(note: SNote, req: Request, res: Response) {
|
||||
async function renderNote(note: SNote, req: Request, res: Response) {
|
||||
if (!note) {
|
||||
console.log("Unable to find note ", note);
|
||||
res.status(404).render("share/404");
|
||||
@ -197,11 +197,10 @@ function register(router: Router) {
|
||||
try {
|
||||
const content = templateNote.getContent();
|
||||
if (typeof content === "string") {
|
||||
import("ejs").then((ejs) => {
|
||||
const ejsResult = ejs.render(content, opts, { includer });
|
||||
res.send(ejsResult);
|
||||
useDefaultView = false; // Rendering went okay, don't use default view
|
||||
});
|
||||
const ejs = await import("ejs");
|
||||
const ejsResult = ejs.render(content, opts, { includer });
|
||||
res.send(ejsResult);
|
||||
useDefaultView = false; // Rendering went okay, don't use default view
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
const [errMessage, errStack] = safeExtractMessageAndStackFromError(e);
|
||||
|
Loading…
x
Reference in New Issue
Block a user