From 03d1a57fea650c13f7ca05481f5c84ffabeb2757 Mon Sep 17 00:00:00 2001 From: Noah Campbell Date: Tue, 1 Oct 2013 12:51:00 -0700 Subject: [PATCH] Set the name of the Nav attribute to select --- transform/nav.go | 7 ++++++- transform/nav_test.go | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/transform/nav.go b/transform/nav.go index c3dfe7900..b085c39a2 100644 --- a/transform/nav.go +++ b/transform/nav.go @@ -8,6 +8,7 @@ import ( type NavActive struct { Section string + AttrName string } func (n *NavActive) Apply(r io.Reader, w io.Writer) (err error) { @@ -22,7 +23,11 @@ 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) } diff --git a/transform/nav_test.go b/transform/nav_test.go index 997fe33f6..78e00f7df 100644 --- a/transform/nav_test.go +++ b/transform/nav_test.go @@ -12,8 +12,8 @@ const HTML_WITH_NAV = ` @@ -23,8 +23,8 @@ const EXPECTED_HTML_WITH_NAV_1 = `