trulia / hologram

A markdown based documentation system for style guides.
http://trulia.github.io/hologram
Other
2.16k stars 200 forks source link

Duplicate menu items #162

Closed adispezio closed 9 years ago

adispezio commented 10 years ago

I'm seeing a weird issue where some of the blocks are being repeated in the menu. When I simply open the index.html file I see a menu (generated by the hologram build?) but when I load the same page via local server (mamp) I'm seeing duplicate entries in the menu.

The weird part is: it doesn't duplicate all the entries and some of the links work and others do not. It feels as though the build system and jquery are stepping on each other in some way.

I'll keep digging, but any help would be great, thanks!

hem-menu

shoesforindustry commented 10 years ago

I'm getting this as well, using the example files. Built on:

Any ideas how to fix this, a bit of an non starter otherwise?

jimlakey commented 9 years ago

I had the same thing when using the header and footer from the sample files in my code. Then I realized it's because I was using the following to generate the nav:

<% @blocks.each do |block| %>
    <li><a href="#<%= block[:name] %>"><%= block[:title] %></a></li>
<% end %>

and then in the footer partial, a few lines of jquery are basically doing the same thing:

  // build simple sidebar navigation
  var $headers = $('.main > h1');
  var $componentList = $('.componentList');

  $headers.each(function() {
    var headerText = $(this).text();
    $(this).attr('id', headerText);

    $componentList.append(
      '<li><a href="#' + headerText + '">' + headerText + '</a></li>'
    );
  });

If using the dynamically built nav with the above code, then get rid of the jQuery. Unless of course, I was just being a bit thick not to see that sooner and you guys have an actual bug, as the example files I downloaded had a hardcoded side nav instead of a dynamic one...

jdcantrell commented 9 years ago

Yea, we updated the example to generate the nav, but never removed the javascript hack we initially used to create that. Thanks for catching this!

jdcantrell commented 9 years ago

This is now corrected in the hologram-example repo.