type NavActive struct {
Section string
+ AttrName string
}
func (n *NavActive) Apply(r io.Reader, w io.Writer) (err error) {
return
}
- tr.Apply(htmltran.ModifyAttrib("class", "active"), fmt.Sprintf("li[data-nav=%s]", n.Section))
+ if n.AttrName == "" {
+ n.AttrName = "hugo-nav"
+ }
+
+ tr.Apply(htmltran.ModifyAttrib("class", "active"), fmt.Sprintf("li[%s=%s]", n.AttrName, n.Section))
return tr.Render(w)
}
<body>
<nav>
<ul class="nav navbar-nav">
- <li data-nav="section_1"><a href="#">Section 1</a></li>
- <li data-nav="section_2"><a href="#">Section 2</a></li>
+ <li hugo-nav="section_1"><a href="#">Section 1</a></li>
+ <li hugo-nav="section_2"><a href="#">Section 2</a></li>
</ul>
</nav>
</body>
<body>
<nav>
<ul class="nav navbar-nav">
- <li data-nav="section_1"><a href="#">Section 1</a></li>
- <li data-nav="section_2" class="active"><a href="#">Section 2</a></li>
+ <li hugo-nav="section_1"><a href="#">Section 1</a></li>
+ <li hugo-nav="section_2" class="active"><a href="#">Section 2</a></li>
</ul>
</nav>