fix: copy templates to the distribution

This commit is contained in:
2026-02-22 19:30:40 +01:00
parent a1c6930355
commit 9cd16885d4
3 changed files with 41 additions and 5 deletions

View File

@@ -815,6 +815,28 @@ export function recordToMap(record: unknown): Map<string, string> {
);
}
export function resolvePageRendererTemplateRoots(options?: {
moduleDir?: string;
cwd?: string;
resourcesPath?: string;
}): string[] {
const moduleDir = options?.moduleDir ?? __dirname;
const cwd = options?.cwd ?? process.cwd();
const resourcesPath = options?.resourcesPath ?? process.resourcesPath;
const roots = [
path.resolve(moduleDir, 'templates'),
path.resolve(cwd, 'dist', 'main', 'engine', 'templates'),
path.resolve(cwd, 'src', 'main', 'engine', 'templates'),
];
if (typeof resourcesPath === 'string' && resourcesPath.length > 0) {
roots.unshift(path.resolve(resourcesPath, 'templates'));
}
return Array.from(new Set(roots));
}
export class PageRenderer {
private readonly mediaEngine: MediaEngineContract;
private readonly postMediaEngine: PostMediaEngineContract;
@@ -826,11 +848,7 @@ export class PageRenderer {
this.postMediaEngine = postMediaEngine;
this.postEngineForMacros = postEngineForMacros;
const templateRoots = [
path.resolve(__dirname, 'templates'),
path.resolve(process.cwd(), 'dist', 'main', 'engine', 'templates'),
path.resolve(process.cwd(), 'src', 'main', 'engine', 'templates'),
];
const templateRoots = resolvePageRendererTemplateRoots();
this.liquid = new Liquid({
root: templateRoots,