Skip to content

Commit

Permalink
setting to allow hiding of default NavBarItems (#53)
Browse files Browse the repository at this point in the history
* add Enable flag to navbar items

* Update app.ini

* Update setting.go

* Update navbar.html


Co-authored-by: ᴊ. ᴄʜᴇɴ <u@gogs.io>
  • Loading branch information
jkupersmith and unknwon committed Aug 11, 2019
1 parent a7af434 commit 21348ea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
5 changes: 4 additions & 1 deletion conf/app.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ USE_CUSTOM_TPL = false
-: github

[navbar.home]
ENABLED = true
LOCALE = navbar.home
LINK = /

[navbar.documentation]
ENABLED = true
LOCALE = navbar.documentation
LINK = /docs

[navbar.github]
ENABLED = true
ICON = github
LOCALE = GitHub
LINK = https://github.com/peachdocs/peach
Expand Down Expand Up @@ -62,4 +65,4 @@ DUOSHUO_SHORT_NAME =
HIGHLIGHTJS_CUSTOM_CSS =
ENABLE_SEARCH = true
; Full code block of Google Analytics
GA_BLOCK =
GA_BLOCK =
8 changes: 5 additions & 3 deletions pkg/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import (
)

type NavbarItem struct {
Icon string
Locale, Link string
Blank bool
Icon string
Locale, Link string
Blank bool
Enabled bool
}

const (
Expand Down Expand Up @@ -165,6 +166,7 @@ func NewContext() {
Locale: Cfg.Section(secName).Key("LOCALE").MustString(secName),
Link: Cfg.Section(secName).Key("LINK").MustString("/"),
Blank: Cfg.Section(secName).Key("BLANK").MustBool(),
Enabled: Cfg.Section(secName).Key("ENABLED").MustBool(true),
}
}

Expand Down
14 changes: 8 additions & 6 deletions templates/navbar.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<div class="ui container">
<div class="ui large secondary inverted menu">
{% for item in Navbar.Items %}
<a class="{% if item.Link == Link %}active{% endif %} item" href="{{item.Link}}" {% if item.Blank %}target="_blank"{% endif %}>
{% if item.Icon %}<i class="{{item.Icon}} icon"></i>{% endif %}
{{Tr(Lang, item.Locale)}}
</a>
{% for item in Navbar.Items %}
{% if item.Enabled %}
<a class="{% if item.Link == Link %}active{% endif %} item" href="{{item.Link}}" {% if item.Blank %}target="_blank"{% endif %}>
{% if item.Icon %}<i class="{{item.Icon}} icon"></i>{% endif %}
{{Tr(Lang, item.Locale)}}
</a>
{% endif %}
{% endfor %}
<div class="right item">
{% if Extension.EnableSearch %}
Expand All @@ -27,4 +29,4 @@
</div>
</div>
</div>
</div>
</div>

0 comments on commit 21348ea

Please sign in to comment.