Active NavElement

This commit is contained in:
Sebastian Frank 2019-02-13 13:14:16 +01:00
parent 39769a89c0
commit 01fa98b28c
Signed by: apairon
GPG Key ID: 7270D06DDA7FE8C3
5 changed files with 27 additions and 7 deletions

View File

@ -36,4 +36,21 @@ a {
footer {
padding: 20px;
}
.nav ul {
list-style-type: square;
}
.nav li>a {
color: #555;
text-decoration: none;
}
.nav li>a:hover, .nav li.active>a {
color: #000;
}
.nav li.active>a {
font-weight: bold;
}

View File

@ -8,4 +8,4 @@ Meta:
Lorem ipsum...
Hier steht dann ne Menge Text. Der kann auch ***formatiert*** _werden_.
Hier steht dann ne Menge Text. Der kann auch ***formatiert*** _werden_.

View File

@ -1,8 +1,8 @@
<footer>
<footer class="nav">
<div><b>service Level 1</b></div>
<ul>
{{#each NavMap.de.SubMap.service.SubSlice }}
<li><a href="{{ GoTo }}">{{ Navname }}</a></li>
<li {{#if Active }}class="active"{{/if }}><a href="{{ GoTo }}">{{ Navname }}</a></li>
{{/each}}
</ul>
</footer>

View File

@ -1,14 +1,14 @@
<header>
<div id="logoDiv"><img src="../assets/img/logo.png"></div>
<div id="mainNavDiv">
<div id="mainNavDiv" class="nav">
<div><b>main Level 1</b></div>
<ul>
{{#each NavMap.de.SubMap.main.SubSlice }}
<li><a href="{{ GoTo }}">{{ Navname }}</a>
<li {{#if Active }}class="active"{{/if }}><a href="{{ GoTo }}">{{ Navname }}</a>
{{#if SubSlice }}
<ul>
{{#each SubSlice }}
<li><a href="{{ GoTo }}">{{ Navname }}</a></li>
<li {{#if Active }}class="active"{{/if }}><a href="{{ GoTo }}">{{ Navname }}</a></li>
{{/each }}
</ul
{{/if }}

View File

@ -249,6 +249,7 @@ func readContentDir(inBase string, outBase string, dir string, conf *PathConfig,
type navElement struct {
Navname string
GoTo string
Active bool
SubMap *map[string]*navElement
SubSlice *[]*navElement
@ -256,13 +257,15 @@ type navElement struct {
func buildNavigation(conf *PathConfigTree, curNavMap *map[string]*navElement, curNavSlice *[]*navElement, activeNav string) {
for _, el := range conf.Sub {
elPath := strings.TrimPrefix(el.OutputPath, *outDir+"/")
subMap := make(map[string]*navElement)
subSlice := make([]*navElement, 0)
navEl := navElement{
Active: strings.HasPrefix(activeNav, elPath),
SubMap: &subMap,
SubSlice: &subSlice,
}
elPath := strings.TrimPrefix(el.OutputPath, *outDir+"/")
n := el.Config.This.Navname
if n != nil {