diff --git a/website/assets/script.js b/website/assets/script.js new file mode 100644 index 0000000..69c4906 --- /dev/null +++ b/website/assets/script.js @@ -0,0 +1,11 @@ +document.addEventListener('DOMContentLoaded', function() { + var menuItems = document.querySelector('.menu-items'); + menuItems.addEventListener('click', function(event) { + if (event.target.tagName === 'SPAN') { + var checkboxes = document.querySelectorAll('#toggle-menu'); + checkboxes.forEach(function(checkbox) { + checkbox.checked = false; + }); + } + }); +}); diff --git a/website/modify_build.rb b/website/modify_build.rb index 2afe660..b50a203 100644 --- a/website/modify_build.rb +++ b/website/modify_build.rb @@ -40,6 +40,7 @@ class ModifyBuild text = remove_section_table_of_contents(text) text = mark_menu_as_selected_if_on_page(text, extract_file_from_path(filename)) text = add_canonical_for_duplicates(text, extract_file_from_path(filename)) + text = include_javascript(text) File.open(filename, "w") {|file| file.puts text } end @@ -367,6 +368,16 @@ class ModifyBuild doc.to_html end + def include_javascript(text) + doc = build_doc(text) + head = doc.css("head")[0] + js_tag_html = %Q{ + + } + head.inner_html = "#{head.inner_html} #{js_tag_html}" + doc.to_html + end + def build_doc(text) Nokogiri::HTML(text) end