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 { footer {
padding: 20px; 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... 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> <div><b>service Level 1</b></div>
<ul> <ul>
{{#each NavMap.de.SubMap.service.SubSlice }} {{#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}} {{/each}}
</ul> </ul>
</footer> </footer>

View File

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

View File

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