Skip to content

Build your personal knowledge base with Trilium Notes

server: Fix loading of code block theme on server builds

Elian Dorana02146df1770
diff --git a/src/services/code_block_theme.ts b/src/services/code_block_theme.ts
index 9aeb23651d..037df7be59 100644
--- a/src/services/code_block_theme.ts
+++ b/src/services/code_block_theme.ts
@@ -8,8 +8,7 @@ import fs from "fs";
import themeNames from "./code_block_theme_names.json" with { type: "json" }
import { t } from "i18next";
import { join } from "path";
-import { getResourceDir } from "./utils.js";
-import env from "./env.js";
+import utils from "./utils.js";
/**
* Represents a color scheme for the code block syntax highlight.
@@ -31,8 +30,8 @@ interface ColorTheme {
* @returns the supported themes, grouped.
*/
export function listSyntaxHighlightingThemes() {
- const stylesDir = (env.isDev() ? "node_modules/@highlightjs/cdn-assets/styles" : "styles");
- const path = join(getResourceDir(), stylesDir);
+ const stylesDir = (!utils.isElectron() ? "node_modules/@highlightjs/cdn-assets/styles" : "styles");
+ const path = join(utils.getResourceDir(), stylesDir);
const systemThemes = readThemesFromFileSystem(path);
return {
diff --git a/src/services/utils.ts b/src/services/utils.ts
index 6e2cdab666..1d93d724cc 100644
--- a/src/services/utils.ts
+++ b/src/services/utils.ts
@@ -364,5 +364,6 @@ export default {
normalize,
hashedBlobId,
toMap,
- isString
+ isString,
+ getResourceDir
};