mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-21 02:18:22 +02:00
Auto detect favicon type and add fallback
This commit is contained in:
parent
176f14df70
commit
26ab9c7b05
@ -50,6 +50,7 @@ type config struct {
|
|||||||
LogoText string `yaml:"logo-text"`
|
LogoText string `yaml:"logo-text"`
|
||||||
LogoURL string `yaml:"logo-url"`
|
LogoURL string `yaml:"logo-url"`
|
||||||
FaviconURL string `yaml:"favicon-url"`
|
FaviconURL string `yaml:"favicon-url"`
|
||||||
|
FaviconType string `yaml:"-"`
|
||||||
AppName string `yaml:"app-name"`
|
AppName string `yaml:"app-name"`
|
||||||
AppIconURL string `yaml:"app-icon-url"`
|
AppIconURL string `yaml:"app-icon-url"`
|
||||||
AppBackgroundColor string `yaml:"app-background-color"`
|
AppBackgroundColor string `yaml:"app-background-color"`
|
||||||
|
@ -127,11 +127,17 @@ func newApplication(c *config) (*application, error) {
|
|||||||
config.Theme.CustomCSSFile = app.resolveUserDefinedAssetPath(config.Theme.CustomCSSFile)
|
config.Theme.CustomCSSFile = app.resolveUserDefinedAssetPath(config.Theme.CustomCSSFile)
|
||||||
config.Branding.LogoURL = app.resolveUserDefinedAssetPath(config.Branding.LogoURL)
|
config.Branding.LogoURL = app.resolveUserDefinedAssetPath(config.Branding.LogoURL)
|
||||||
|
|
||||||
if config.Branding.FaviconURL == "" {
|
config.Branding.FaviconURL = ternary(
|
||||||
config.Branding.FaviconURL = app.StaticAssetPath("favicon.png")
|
config.Branding.FaviconURL == "",
|
||||||
} else {
|
app.StaticAssetPath("favicon.svg"),
|
||||||
config.Branding.FaviconURL = app.resolveUserDefinedAssetPath(config.Branding.FaviconURL)
|
app.resolveUserDefinedAssetPath(config.Branding.FaviconURL),
|
||||||
}
|
)
|
||||||
|
|
||||||
|
config.Branding.FaviconType = ternary(
|
||||||
|
strings.HasSuffix(config.Branding.FaviconURL, ".svg"),
|
||||||
|
"image/svg+xml",
|
||||||
|
"image/png",
|
||||||
|
)
|
||||||
|
|
||||||
if config.Branding.AppName == "" {
|
if config.Branding.AppName == "" {
|
||||||
config.Branding.AppName = "Glance"
|
config.Branding.AppName = "Glance"
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
<meta name="theme-color" content="{{ .Request.Theme.BackgroundColorAsHex }}">
|
<meta name="theme-color" content="{{ .Request.Theme.BackgroundColorAsHex }}">
|
||||||
<link rel="apple-touch-icon" sizes="512x512" href='{{ .App.Config.Branding.AppIconURL }}'>
|
<link rel="apple-touch-icon" sizes="512x512" href='{{ .App.Config.Branding.AppIconURL }}'>
|
||||||
<link rel="manifest" href='{{ .App.VersionedAssetPath "manifest.json" }}'>
|
<link rel="manifest" href='{{ .App.VersionedAssetPath "manifest.json" }}'>
|
||||||
<link rel="icon" type="image/png" href="{{ .App.Config.Branding.FaviconURL }}" />
|
<link rel="icon" type="image/png" href='{{ .App.StaticAssetPath "favicon.png" }}' />
|
||||||
|
<link rel="icon" type="{{ .App.Config.Branding.FaviconType }}" href="{{ .App.Config.Branding.FaviconURL }}" />
|
||||||
<link rel="stylesheet" href='{{ .App.StaticAssetPath "css/bundle.css" }}'>
|
<link rel="stylesheet" href='{{ .App.StaticAssetPath "css/bundle.css" }}'>
|
||||||
<script type="module" src='{{ .App.StaticAssetPath "js/main.js" }}'></script>
|
<script type="module" src='{{ .App.StaticAssetPath "js/main.js" }}'></script>
|
||||||
<style id="theme-style">
|
<style id="theme-style">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user