mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
chore(share): integrate root template
This commit is contained in:
parent
8e27d877a1
commit
881a015f68
@ -236,7 +236,8 @@
|
||||
],
|
||||
"esbuildOptions": {
|
||||
"loader": {
|
||||
".css": "text"
|
||||
".css": "text",
|
||||
".ejs": "text"
|
||||
}
|
||||
},
|
||||
"declarationRootDir": "apps/server/src"
|
||||
@ -285,7 +286,8 @@
|
||||
"esbuildOptions": {
|
||||
"splitting": false,
|
||||
"loader": {
|
||||
".css": "text"
|
||||
".css": "text",
|
||||
".ejs": "text"
|
||||
}
|
||||
},
|
||||
"additionalEntryPoints": [
|
||||
|
@ -17,6 +17,8 @@ import type SAttachment from "./shaca/entities/sattachment.js";
|
||||
import utils, { isDev, safeExtractMessageAndStackFromError } from "../services/utils.js";
|
||||
import options from "../services/options.js";
|
||||
import { t } from "i18next";
|
||||
import shareThemeRoot from "@triliumnext/share-theme/templates/page.ejs";
|
||||
import ejs from "ejs";
|
||||
|
||||
function getSharedSubTreeRoot(note: SNote): { note?: SNote; branch?: SBranch } {
|
||||
if (note.noteId === shareRoot.SHARE_ROOT_NOTE_ID) {
|
||||
@ -136,7 +138,7 @@ function renderImageAttachment(image: SNote, res: Response, attachmentName: stri
|
||||
}
|
||||
|
||||
function register(router: Router) {
|
||||
async function renderNote(note: SNote, req: Request, res: Response) {
|
||||
function renderNote(note: SNote, req: Request, res: Response) {
|
||||
if (!note) {
|
||||
console.log("Unable to find note ", note);
|
||||
res.status(404).render("share/404");
|
||||
@ -197,7 +199,6 @@ function register(router: Router) {
|
||||
try {
|
||||
const content = templateNote.getContent();
|
||||
if (typeof content === "string") {
|
||||
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
|
||||
@ -210,7 +211,14 @@ function register(router: Router) {
|
||||
}
|
||||
|
||||
if (useDefaultView) {
|
||||
res.render("share/page", opts);
|
||||
console.log("Got share theme path", shareThemeRoot);
|
||||
const ejsResult = ejs.render(shareThemeRoot, opts, {
|
||||
includer(originalPath, parsedPath: string) {
|
||||
console.log("Path ", originalPath, parsedPath);
|
||||
throw new Error("Hi");
|
||||
}
|
||||
})
|
||||
res.send(ejsResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
6
apps/server/src/types.d.ts
vendored
6
apps/server/src/types.d.ts
vendored
@ -27,3 +27,9 @@ declare module "@triliumnext/ckeditor5/content.css" {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
|
||||
declare module "@triliumnext/share-theme/*.ejs" {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
@ -37,6 +37,9 @@
|
||||
{
|
||||
"path": "../../packages/ckeditor5/tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/share-theme"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/turndown-plugin-gfm/tsconfig.lib.json"
|
||||
},
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "trilium.rocks",
|
||||
"name": "@triliumnext/share-theme",
|
||||
"version": "1.0.3",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
@ -12,6 +12,9 @@
|
||||
"dist": "esrun scripts/build.ts -- --minify",
|
||||
"test": "esrun src/scripts/test.ts"
|
||||
},
|
||||
"exports": {
|
||||
"./*": "./src/*"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
|
14
pnpm-lock.yaml
generated
14
pnpm-lock.yaml
generated
@ -473,6 +473,9 @@ importers:
|
||||
'@braintree/sanitize-url':
|
||||
specifier: 7.1.1
|
||||
version: 7.1.1
|
||||
'@digitalmaas/esbuild-plugin-ejs':
|
||||
specifier: 1.0.0
|
||||
version: 1.0.0(esbuild@0.25.5)
|
||||
'@electron/remote':
|
||||
specifier: 2.1.2
|
||||
version: 2.1.2(electron@36.4.0)
|
||||
@ -2326,6 +2329,12 @@ packages:
|
||||
'@digitak/grubber@3.1.4':
|
||||
resolution: {integrity: sha512-pqsnp2BUYlDoTXWG34HWgEJse/Eo1okRgNex8IG84wHrJp8h3SakeR5WhB4VxSA2+/D+frNYJ0ch3yXzsfNDoA==}
|
||||
|
||||
'@digitalmaas/esbuild-plugin-ejs@1.0.0':
|
||||
resolution: {integrity: sha512-R6FHotduWyXExphqMJuv0CK42ZCt5Z+gZATFOXvL/lVHLyRVRdTlZqvKyP6DRCQVGz9ecYpk++AWhRzkNODKwQ==}
|
||||
engines: {node: '>=14'}
|
||||
peerDependencies:
|
||||
esbuild: '>=0.25.0'
|
||||
|
||||
'@dual-bundle/import-meta-resolve@4.1.0':
|
||||
resolution: {integrity: sha512-+nxncfwHM5SgAtrVzgpzJOI1ol0PkumhVo469KCf9lUi21IGcY90G98VuHm9VRrUypmAzawAHO9bs6hqeADaVg==}
|
||||
|
||||
@ -14973,6 +14982,11 @@ snapshots:
|
||||
|
||||
'@digitak/grubber@3.1.4': {}
|
||||
|
||||
'@digitalmaas/esbuild-plugin-ejs@1.0.0(esbuild@0.25.5)':
|
||||
dependencies:
|
||||
ejs: 3.1.10
|
||||
esbuild: 0.25.5
|
||||
|
||||
'@dual-bundle/import-meta-resolve@4.1.0': {}
|
||||
|
||||
'@electron-forge/cli@7.8.1(encoding@0.1.13)':
|
||||
|
Loading…
x
Reference in New Issue
Block a user