thoughtbot / middleman-aria_current

Accessibly indicate a current (active) link in Middleman
MIT License
8 stars 4 forks source link

Matching to path issue #15

Open chrism opened 7 years ago

chrism commented 7 years ago

Using the gem I've found that the current_path includes forward slashes like this /link/ so that it fails to match the path using ==.

I've managed to fix this by changing it to

    if current_path.include? path
      link_options.merge!("aria-current" => aria_current)
    end

But wondered if this is a good approach?

tysongach commented 7 years ago

Can you share the source for the links you’re generating? I’m curious why it seems to match fine in our tests, but you have a case where it is not matching.

chrism commented 7 years ago

Sure,

I don't think I'm doing anything too unusual but am new to middleman.

I've created a template in my source directory called writing.html.erb and in my layouts/layout.erb am referencing it like this

<%= current_link_to 'Writing', 'writing' %>
monicakogler commented 7 years ago

I had the same issue – thanks for the fix @chrism!