Skip to content

Commit c15333e

Browse files
committed
GTD-14: Do not generate the current page content twice when parsing for heading structure, as it increments the heading ids, and causes a mismatch between the navigation and the page content
1 parent 2d62b65 commit c15333e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/source/layouts/layout.erb

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ wrap_layout :core do
55
content_for(:toc_module, "in-page-navigation")
66

77
content_for :sidebar do
8-
%>
9-
<% sitemap.resources.select{ |r| r.path.end_with?('.html')}.sort_by{ |r| [r.data.weight ? 0 : 1,r.data.weight || 0] }.each do |resource| %>
10-
<% content = resource.render({layout: false}) %>
8+
9+
sitemap.resources.select{ |r| r.path.end_with?('.html')}.sort_by{ |r| [r.data.weight ? 0 : 1,r.data.weight || 0] }.each do |resource|
10+
11+
# Reuse the generated content for the active page
12+
# If we generate it twice it increments the heading ids
13+
if active_page(resource.url)
14+
content = html
15+
else
16+
content = resource.render({layout: false})
17+
end
18+
%>
1119
<%=
1220
table_of_contents(
1321
content,

0 commit comments

Comments
 (0)