mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
refactor(share): relocate 404 template
This commit is contained in:
parent
a61d76deed
commit
828da2aabf
@ -108,7 +108,8 @@ function renderImageAttachment(image: SNote, res: Response, attachmentName: stri
|
|||||||
let svgString = "<svg/>";
|
let svgString = "<svg/>";
|
||||||
const attachment = image.getAttachmentByTitle(attachmentName);
|
const attachment = image.getAttachmentByTitle(attachmentName);
|
||||||
if (!attachment) {
|
if (!attachment) {
|
||||||
res.status(404).render("share/404");
|
res.status(404);
|
||||||
|
renderDefault(res, "404");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const content = attachment.getContent();
|
const content = attachment.getContent();
|
||||||
@ -140,7 +141,8 @@ function register(router: Router) {
|
|||||||
function renderNote(note: SNote, req: Request, res: Response) {
|
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);
|
||||||
|
renderDefault(res, "404");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,9 +214,7 @@ function register(router: Router) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (useDefaultView) {
|
if (useDefaultView) {
|
||||||
// Path is relative to apps/server/dist/assets/views
|
renderDefault(res, "page", opts);
|
||||||
const shareThemePath = "../../share-theme/templates/page.ejs";
|
|
||||||
res.render(shareThemePath, opts);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,6 +399,12 @@ function register(router: Router) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderDefault(res: Response<any, Record<string, any>>, template: "page" | "404", opts: any = {}) {
|
||||||
|
// Path is relative to apps/server/dist/assets/views
|
||||||
|
const shareThemePath = `../../share-theme/templates/${template}.ejs`;
|
||||||
|
res.render(shareThemePath, opts);
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
register
|
register
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user