mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 09:49:20 +02:00
server/server -> server/core
This commit is contained in:
parent
114327d4ce
commit
5a3d0650c9
838 changed files with 111 additions and 111 deletions
24
server/core/lib/plugins/theme-utils.ts
Normal file
24
server/core/lib/plugins/theme-utils.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { DEFAULT_THEME_NAME, DEFAULT_USER_THEME_NAME } from '../../initializers/constants.js'
|
||||
import { PluginManager } from './plugin-manager.js'
|
||||
import { CONFIG } from '../../initializers/config.js'
|
||||
|
||||
function getThemeOrDefault (name: string, defaultTheme: string) {
|
||||
if (isThemeRegistered(name)) return name
|
||||
|
||||
// Fallback to admin default theme
|
||||
if (name !== CONFIG.THEME.DEFAULT) return getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
|
||||
|
||||
return defaultTheme
|
||||
}
|
||||
|
||||
function isThemeRegistered (name: string) {
|
||||
if (name === DEFAULT_THEME_NAME || name === DEFAULT_USER_THEME_NAME) 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