aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/plugins/theme-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/plugins/theme-utils.ts')
-rw-r--r--server/lib/plugins/theme-utils.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/server/lib/plugins/theme-utils.ts b/server/lib/plugins/theme-utils.ts
new file mode 100644
index 000000000..066339e65
--- /dev/null
+++ b/server/lib/plugins/theme-utils.ts
@@ -0,0 +1,24 @@
1import { DEFAULT_THEME } from '../../initializers/constants'
2import { PluginManager } from './plugin-manager'
3import { CONFIG } from '../../initializers/config'
4
5function getThemeOrDefault (name: string) {
6 if (isThemeRegistered(name)) return name
7
8 // Fallback to admin default theme
9 if (name !== CONFIG.THEME.DEFAULT) return getThemeOrDefault(CONFIG.THEME.DEFAULT)
10
11 return DEFAULT_THEME
12}
13
14function isThemeRegistered (name: string) {
15 if (name === DEFAULT_THEME) return true
16
17 return !!PluginManager.Instance.getRegisteredThemes()
18 .find(r => r.name === name)
19}
20
21export {
22 getThemeOrDefault,
23 isThemeRegistered
24}