Skip to content

Build your personal knowledge base with Trilium Notes

fix(server): code block themes not listed again

Elian Doran73f69f91f263
diff --git a/apps/server/src/services/code_block_theme.spec.ts b/apps/server/src/services/code_block_theme.spec.ts
index 84482b4167..3a255ff291 100644
--- a/apps/server/src/services/code_block_theme.spec.ts
+++ b/apps/server/src/services/code_block_theme.spec.ts
@@ -1,11 +1,12 @@
import { describe, expect, it } from "vitest";
-import { getStylesDirectory, readThemesFromFileSystem } from "./code_block_theme.js";
+import { readThemesFromFileSystem } from "./code_block_theme.js";
import themeNames from "./code_block_theme_names.json" with { type: "json" };
+import path = require("path");
describe("Code block theme", () => {
it("all themes are mapped", () => {
- const themes = readThemesFromFileSystem(getStylesDirectory());
+ const themes = readThemesFromFileSystem(path.join(__dirname, "../../node_modules/@highlightjs/cdn-assets/styles"));
const mappedThemeNames = new Set(Object.values(themeNames));
const unmappedThemeNames = new Set<string>();
diff --git a/apps/server/src/services/code_block_theme.ts b/apps/server/src/services/code_block_theme.ts
index bb0a14921d..14b9ce57a9 100644
--- a/apps/server/src/services/code_block_theme.ts
+++ b/apps/server/src/services/code_block_theme.ts
@@ -30,7 +30,7 @@ interface ColorTheme {
* @returns the supported themes, grouped.
*/
export function listSyntaxHighlightingThemes() {
- const path = join(getResourceDir(), getStylesDirectory());
+ const path = getStylesDirectory();
const systemThemes = readThemesFromFileSystem(path);
return {
@@ -46,11 +46,11 @@ export function listSyntaxHighlightingThemes() {
export function getStylesDirectory() {
if (isElectron && !isDev) {
- return "styles";
+ return join(getResourceDir(), "styles");
} else if (!isDev) {
- return "node_modules/@highlightjs/cdn-assets/styles";
+ return join(getResourceDir(), "node_modules/@highlightjs/cdn-assets/styles");
} else {
- return join(__dirname, "../../node_modules/@highlightjs/cdn-assets/styles");
+ return join(__dirname, "../node_modules/@highlightjs/cdn-assets/styles");
}
}