Skip to content

Commit

Permalink
GTD-14: Do not generate the current page content twice when parsing f…
Browse files Browse the repository at this point in the history
…or heading structure, as it increments the heading ids, and causes a mismatch between the navigation and the page content
  • Loading branch information
lewisnyman committed Jun 5, 2018
1 parent 2d62b65 commit c15333e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/source/layouts/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ wrap_layout :core do
content_for(:toc_module, "in-page-navigation")

content_for :sidebar do
%>
<% sitemap.resources.select{ |r| r.path.end_with?('.html')}.sort_by{ |r| [r.data.weight ? 0 : 1,r.data.weight || 0] }.each do |resource| %>
<% content = resource.render({layout: false}) %>

sitemap.resources.select{ |r| r.path.end_with?('.html')}.sort_by{ |r| [r.data.weight ? 0 : 1,r.data.weight || 0] }.each do |resource|

# Reuse the generated content for the active page
# If we generate it twice it increments the heading ids
if active_page(resource.url)
content = html
else
content = resource.render({layout: false})
end
%>
<%=
table_of_contents(
content,
Expand Down

0 comments on commit c15333e

Please sign in to comment.