aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/plugins/theme-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-09 11:45:19 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commit7cd4d2ba10106c10602c86f74f55743ded588896 (patch)
tree81f0dd7a7ef763511158d1035f3e09e09d5dcd2c /server/lib/plugins/theme-utils.ts
parent8d76959e11ab7172040853fa4fadaf8d53e6aa12 (diff)
downloadPeerTube-7cd4d2ba10106c10602c86f74f55743ded588896.tar.gz
PeerTube-7cd4d2ba10106c10602c86f74f55743ded588896.tar.zst
PeerTube-7cd4d2ba10106c10602c86f74f55743ded588896.zip
WIP plugins: add theme support
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}