mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
WIP plugins: add theme support
This commit is contained in:
parent
8d76959e11
commit
7cd4d2ba10
34 changed files with 311 additions and 38 deletions
24
server/lib/plugins/theme-utils.ts
Normal file
24
server/lib/plugins/theme-utils.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { DEFAULT_THEME } from '../../initializers/constants'
|
||||
import { PluginManager } from './plugin-manager'
|
||||
import { CONFIG } from '../../initializers/config'
|
||||
|
||||
function getThemeOrDefault (name: string) {
|
||||
if (isThemeRegistered(name)) return name
|
||||
|
||||
// Fallback to admin default theme
|
||||
if (name !== CONFIG.THEME.DEFAULT) return getThemeOrDefault(CONFIG.THEME.DEFAULT)
|
||||
|
||||
return DEFAULT_THEME
|
||||
}
|
||||
|
||||
function isThemeRegistered (name: string) {
|
||||
if (name === DEFAULT_THEME) return true
|
||||
|
||||
return !!PluginManager.Instance.getRegisteredThemes()
|
||||
.find(r => r.name === name)
|
||||
}
|
||||
|
||||
export {
|
||||
getThemeOrDefault,
|
||||
isThemeRegistered
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue