mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-28 03:13:14 +00:00
Fix buildThemeList() function to ensure no duplicates (#1466)
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
This commit is contained in:
parent
902930bb9d
commit
0247f8a2cf
|
@ -4,15 +4,20 @@ import { readdir } from "fs/promises";
|
||||||
const extraThemesFolder =
|
const extraThemesFolder =
|
||||||
process.env["LEMMY_UI_EXTRA_THEMES_FOLDER"] || "./extra_themes";
|
process.env["LEMMY_UI_EXTRA_THEMES_FOLDER"] || "./extra_themes";
|
||||||
|
|
||||||
const themes = ["darkly", "darkly-red", "litely", "litely-red"];
|
const themes: ReadonlyArray<string> = [
|
||||||
|
"darkly",
|
||||||
|
"darkly-red",
|
||||||
|
"litely",
|
||||||
|
"litely-red",
|
||||||
|
];
|
||||||
|
|
||||||
export async function buildThemeList(): Promise<string[]> {
|
export async function buildThemeList(): Promise<ReadonlyArray<string>> {
|
||||||
if (existsSync(extraThemesFolder)) {
|
if (existsSync(extraThemesFolder)) {
|
||||||
const dirThemes = await readdir(extraThemesFolder);
|
const dirThemes = await readdir(extraThemesFolder);
|
||||||
const cssThemes = dirThemes
|
const cssThemes = dirThemes
|
||||||
.filter(d => d.endsWith(".css"))
|
.filter(d => d.endsWith(".css"))
|
||||||
.map(d => d.replace(".css", ""));
|
.map(d => d.replace(".css", ""));
|
||||||
themes.push(...cssThemes);
|
return themes.concat(cssThemes);
|
||||||
}
|
}
|
||||||
return themes;
|
return themes;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue