Skip to content

Question on Deeper Nesting #992

Answered by JoelTroch
billhennessy asked this question in General
Discussion options

You must be logged in to vote

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>
       …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by lord
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #992 on May 20, 2020 22:23.