mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +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/>";
|
||||
const attachment = image.getAttachmentByTitle(attachmentName);
|
||||
if (!attachment) {
|
||||
res.status(404).render("share/404");
|
||||
res.status(404);
|
||||
renderDefault(res, "404");
|
||||
return;
|
||||
}
|
||||
const content = attachment.getContent();
|
||||
@ -140,7 +141,8 @@ function register(router: Router) {
|
||||
function renderNote(note: SNote, req: Request, res: Response) {
|
||||
if (!note) {
|
||||
console.log("Unable to find note ", note);
|
||||
res.status(404).render("share/404");
|
||||
res.status(404);
|
||||
renderDefault(res, "404");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -212,9 +214,7 @@ function register(router: Router) {
|
||||
}
|
||||
|
||||
if (useDefaultView) {
|
||||
// Path is relative to apps/server/dist/assets/views
|
||||
const shareThemePath = "../../share-theme/templates/page.ejs";
|
||||
res.render(shareThemePath, opts);
|
||||
renderDefault(res, "page", 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 {
|
||||
register
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user