Skip to content

Commit

Permalink
add config option for logo and meta description
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Jan 16, 2024
1 parent 5c5f661 commit cd6112b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions handlers/pageData.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func InitPageData(w http.ResponseWriter, r *http.Request, active, path, title st
Year: time.Now().UTC().Year(),
ExplorerTitle: utils.Config.Frontend.SiteName,
ExplorerSubtitle: utils.Config.Frontend.SiteSubtitle,
ExplorerLogo: utils.Config.Frontend.SiteLogo,
ChainSlotsPerEpoch: utils.Config.Chain.Config.SlotsPerEpoch,
ChainSecondsPerSlot: utils.Config.Chain.Config.SecondsPerSlot,
ChainGenesisTimestamp: utils.Config.Chain.GenesisTimestamp,
Expand All @@ -60,6 +61,10 @@ func InitPageData(w http.ResponseWriter, r *http.Request, active, path, title st
MainMenuItems: createMenuItems(active, isMainnet),
}

if utils.Config.Frontend.SiteDescription != "" {
data.Meta.Description = utils.Config.Frontend.SiteDescription
}

acceptedLangs := strings.Split(r.Header.Get("Accept-Language"), ",")
if len(acceptedLangs) > 0 {
if strings.Contains(acceptedLangs[0], "ru") || strings.Contains(acceptedLangs[0], "RU") {
Expand Down
4 changes: 4 additions & 0 deletions templates/_layout/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
<nav id="nav" class="main-navigation navbar navbar-expand-lg navbar-light">
<div class="container d-flex">
<a class="navbar-brand col-10 col-lg-auto me-lg-3 " href="/">
{{ if eq .ExplorerLogo "" }}
<svg class="bi me-2" width="40" height="32" role="img" aria-label="Logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<use href="#logo"></use>
</svg>
{{ else }}
<img class="bi me-2" src="{{ .ExplorerLogo }}" height="32" role="img" aria-label="Logo">
{{ end }}

<div class="explorer-brand">
<div class="explorer-brand-container">
Expand Down
8 changes: 5 additions & 3 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ type Config struct {
Pprof bool `yaml:"pprof" envconfig:"FRONTEND_PPROF"`
Minify bool `yaml:"minify" envconfig:"FRONTEND_MINIFY"`

SiteDomain string `yaml:"siteDomain" envconfig:"FRONTEND_SITE_DOMAIN"`
SiteName string `yaml:"siteName" envconfig:"FRONTEND_SITE_NAME"`
SiteSubtitle string `yaml:"siteSubtitle" envconfig:"FRONTEND_SITE_SUBTITLE"`
SiteDomain string `yaml:"siteDomain" envconfig:"FRONTEND_SITE_DOMAIN"`
SiteLogo string `yaml:"siteLogo" envconfig:"FRONTEND_SITE_LOGO"`
SiteName string `yaml:"siteName" envconfig:"FRONTEND_SITE_NAME"`
SiteSubtitle string `yaml:"siteSubtitle" envconfig:"FRONTEND_SITE_SUBTITLE"`
SiteDescription string `yaml:"siteDescription" envconfig:"FRONTEND_SITE_DESCRIPTION"`

EthExplorerLink string `yaml:"ethExplorerLink" envconfig:"FRONTEND_ETH_EXPLORER_LINK"`
ValidatorNamesYaml string `yaml:"validatorNamesYaml" envconfig:"FRONTEND_VALIDATOR_NAMES_YAML"`
Expand Down
1 change: 1 addition & 0 deletions types/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type PageData struct {
Version string
BuildTime string
Year int
ExplorerLogo string
ExplorerTitle string
ExplorerSubtitle string
ChainSlotsPerEpoch uint64
Expand Down

0 comments on commit cd6112b

Please sign in to comment.