Skip to content

Commit 56f8878

Browse files
cpriestblakeembrey
authored andcommitted
Attempt to load theme.js when rendering (#504)
1 parent 4460268 commit 56f8878

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/lib/output/renderer.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,21 @@ export class Renderer extends ChildableComponent<Application, RendererComponent>
201201
}
202202
}
203203

204-
this.theme = this.addComponent('theme', new DefaultTheme(this, path));
204+
const filename = Path.join(path, 'theme.js');
205+
if (!FS.existsSync(filename)) {
206+
this.theme = this.addComponent('theme', new DefaultTheme(this, path));
207+
} else {
208+
try {
209+
const themeClass = typeof require(filename) === 'function' ? require(filename) : require(filename).default;
210+
211+
this.theme = this.addComponent('theme', new (themeClass)(this, path));
212+
} catch (err) {
213+
throw new Error(
214+
`Exception while loading "${filename}". You must export a \`new Theme(renderer, basePath)\` compatible class.\n` +
215+
err
216+
);
217+
}
218+
}
205219
}
206220

207221
this.theme.resources.activate();

0 commit comments

Comments
 (0)