Closed lifeiscontent closed 4 years ago
If anyone else wants a nested structure like I did.
this is how you do it.
at the top of the _header.html file put this
_header.html
<% parent_blocks = @blocks.select { |b| b[:children] = nil; b[:parent].nil? } %> <% @blocks.reject { |b| b[:parent].nil? }.each { |b| parent_blocks.find { |pb| pb[:name] == b[:parent].get_hash[:name] }[:children] = b[:parent].children.keys } %>
in your section nav you can write something like this
<ul> <li><%= title %> nav</li> <% parent_blocks.each do |block| %> <li> <a href="#<%= block[:name] %>"><%= block[:title] %></a> <% unless block[:children].nil? %> <ul> <% block[:children].each do |child| %> <% child = @blocks.find { |b| b[:name] == child } %> <li> <a href="#<%= child[:name] %>"><%= child[:title] %></a> </li> <% end %> </ul> <% end %> </li> <% end %> </ul>
This is great: thanks!
If anyone else wants a nested structure like I did.
this is how you do it.
at the top of the
_header.html
file put thisin your section nav you can write something like this