server: Refactor code block theme search into own service

This commit is contained in:
Elian Doran
2024-10-27 23:12:55 +02:00
parent 5682b2d819
commit b8eb09b46b
2 changed files with 19 additions and 14 deletions

View File

@@ -0,0 +1,17 @@
import fs from "fs";
export function listSyntaxHighlightingThemes() {
const path = "node_modules/@highlightjs/cdn-assets/styles";
const allThemes = fs
.readdirSync(path)
.filter((el) => el.endsWith(".min.css"))
.map((name) => {
const nameWithoutExtension = name.replace(".min.css", "");
return {
val: `default:${nameWithoutExtension}`,
title: nameWithoutExtension.replace(/-/g, " ")
};
});
return allThemes;
}