module JekyllThemeGuidesMbland::NavigationMenu
Public Class Methods
check_for_orphaned_items(nav_data)
click to toggle source
# File lib/jekyll-theme-guides-mbland/navigation.rb, line 239 def self.check_for_orphaned_items(nav_data) orphan_urls = nav_data.map { |nav| nav[:orphan_url] }.compact return if orphan_urls.empty? raise StandardError, "Parent pages missing for the following:\n " + orphan_urls.join("\n ") end
remove_stale_children(parent)
click to toggle source
# File lib/jekyll-theme-guides-mbland/navigation.rb, line 210 def self.remove_stale_children(parent) children = (parent['children'] || []) children.delete_if { |nav| nav['delete'] } parent.delete 'children' if children.empty? children.each { |child| remove_stale_children(child) } end
validate_existing_data(nav_data)
click to toggle source
# File lib/jekyll-theme-guides-mbland/navigation.rb, line 139 def self.validate_existing_data(nav_data) errors = [] validate_existing_data_impl(nav_data, errors) err_msg = "Existing navigation entries contain errors:\n " + errors.join("\n ") + "\n_config.yml not updated" abort err_msg unless errors.empty? end
validate_existing_data_impl(nav_data, errors)
click to toggle source
# File lib/jekyll-theme-guides-mbland/navigation.rb, line 147 def self.validate_existing_data_impl(nav_data, errors) nav_data.each do |nav| if !nav['internal'] && nav['children'] errors << "#{nav['text']}: external navigation URLs " \ 'cannot have children' end validate_existing_data_impl(nav['children'] || [], errors) end end