Question on Deeper Nesting #992
-
Operating system: ✍️ TODO ✍️ TODO write your issue here When adding a second level of nesting, I'm not sure exactly how to implement the change in layout.erb. Referring to this:
Where in this sequence does it go?
Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Took me some time to get it working as well but after a series of trial and errors, I managed to get it working, here's how it should look like: <div id="toc" class="toc-list-h1">
<% toc_data(page_content).each do |h1| %>
<li>
<a href="#<%= h1[:id] %>" class="toc-h1 toc-link" data-title="<%= h1[:content].to_s.parameterize %>"><%= h1[:content] %></a>
<% if h1[:children].length > 0 %>
<ul class="toc-list-h2">
<% h1[:children].each do |h2| %>
<li>
<a href="#<%= h2[:id] %>" class="toc-h2 toc-link" data-title="<%= h2[:content].to_s.parameterize %>"><%= h2[:content] %></a>
<% if h2[:children].length > 0 %>
<ul class="toc-list-h3">
<% h2[:children].each do |h3| %>
<li>
<a href="#<%= h3[:id] %>" class="toc-h3 toc-link" data-title="<%= h3[:content].to_s.parameterize %>"><%= h3[:content] %></a>
</li>
<% end %>
</ul>
<% end %>
</li>
<% end %>
</ul>
<% end %>
</li>
<% end %>
</div> |
Beta Was this translation helpful? Give feedback.
-
Thanks, Josh. Much appreciated. I'll close this issue. |
Beta Was this translation helpful? Give feedback.
Took me some time to get it working as well but after a series of trial and errors, I managed to get it working, here's how it should look like: