Put the table of contents where it's supposed to go (#267)

This commit is contained in:
Natalie Weizenbaum 2018-12-28 14:49:59 -08:00 committed by Jina Anne
parent 8b2d48f774
commit 97c5ac21af
2 changed files with 4 additions and 7 deletions

View File

@ -54,6 +54,8 @@ before_render do |body, _, _, template_class|
if current_page.data.table_of_contents &&
template_class == Middleman::Renderers::RedcarpetTemplate
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML_TOC.new)
markdown.render(body).sub(/<ul( |>)/, '<ul class="table-of-contents"\1') + body
current_page.add_metadata(table_of_contents:
markdown.render(body).sub(/<ul( |>)/, '<ul class="table-of-contents"\1'))
body
end
end

View File

@ -6,10 +6,5 @@
- if current_page.data.table_of_contents
- content_for :complementary do
-# Put table of contents here and make it conditional
%nav.sl-c-list-navigation-wrapper
:markdown
- put
- your
- links
- here
= current_page.metadata[:table_of_contents]