]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/plugins/theme-utils.ts
Merge remote-tracking branch 'weblate/develop' into develop
[github/Chocobozzz/PeerTube.git] / server / lib / plugins / theme-utils.ts
CommitLineData
ffb321be 1import { DEFAULT_THEME_NAME, DEFAULT_USER_THEME_NAME } from '../../initializers/constants'
7cd4d2ba
C
2import { PluginManager } from './plugin-manager'
3import { CONFIG } from '../../initializers/config'
4
ffb321be 5function getThemeOrDefault (name: string, defaultTheme: string) {
7cd4d2ba
C
6 if (isThemeRegistered(name)) return name
7
8 // Fallback to admin default theme
ffb321be 9 if (name !== CONFIG.THEME.DEFAULT) return getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
7cd4d2ba 10
ffb321be 11 return defaultTheme
7cd4d2ba
C
12}
13
14function isThemeRegistered (name: string) {
ffb321be 15 if (name === DEFAULT_THEME_NAME || name === DEFAULT_USER_THEME_NAME) return true
7cd4d2ba
C
16
17 return !!PluginManager.Instance.getRegisteredThemes()
18 .find(r => r.name === name)
19}
20
21export {
22 getThemeOrDefault,
23 isThemeRegistered
24}