mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 19:19:03 +01:00 
			
		
		
		
	fix(export/share): missing templates after merge
This commit is contained in:
		
							parent
							
								
									ea53665e64
								
							
						
					
					
						commit
						aa102ab393
					
				| @ -1,8 +1,9 @@ | ||||
| import type NoteMeta from "../../meta/note_meta.js"; | ||||
| import { escapeHtml } from "../../utils"; | ||||
| import cssContent from "@triliumnext/ckeditor5/content.css"; | ||||
| import { escapeHtml, getResourceDir, isDev } from "../../utils"; | ||||
| import html from "html"; | ||||
| import { ZipExportProvider } from "./abstract_provider.js"; | ||||
| import path from "path"; | ||||
| import fs from "fs"; | ||||
| 
 | ||||
| export default class HtmlExportProvider extends ZipExportProvider { | ||||
| 
 | ||||
| @ -164,6 +165,10 @@ export default class HtmlExportProvider extends ZipExportProvider { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         const cssFile = isDev | ||||
|             ? path.join(__dirname, "../../../../../node_modules/ckeditor5/dist/ckeditor5-content.css") | ||||
|             : path.join(getResourceDir(), "ckeditor5-content.css"); | ||||
|         const cssContent = fs.readFileSync(cssFile, "utf-8"); | ||||
|         this.archive.append(cssContent, { name: cssMeta.dataFileName }); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -189,15 +189,22 @@ function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs) | ||||
|     } | ||||
| 
 | ||||
|     // Render with the default view otherwise.
 | ||||
|     const templatePath = join(getResourceDir(), "share-theme", "templates", "page.ejs"); | ||||
|     const templatePath = getDefaultTemplatePath("page"); | ||||
|     return ejs.render(readTemplate(templatePath), opts, { | ||||
|         includer: (path) => { | ||||
|             const templatePath = join(getResourceDir(), "share-theme", "templates", `${path}.ejs`); | ||||
|             return { template: readTemplate(templatePath) }; | ||||
|             // Path is relative to apps/server/dist/assets/views
 | ||||
|             return { template: readTemplate(getDefaultTemplatePath(path)) }; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| function getDefaultTemplatePath(template: string) { | ||||
|     // Path is relative to apps/server/dist/assets/views
 | ||||
|     return process.env.NODE_ENV === "development" | ||||
|         ? join(__dirname, `../../../../packages/share-theme/src/templates/${template}.ejs`) | ||||
|         : `../../share-theme/templates/${template}.ejs`; | ||||
| } | ||||
| 
 | ||||
| function readTemplate(path: string) { | ||||
|     const cachedTemplate = templateCache.get(path); | ||||
|     if (cachedTemplate) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran