1set :base_url, "https://www.consul.io/" 2 3activate :hashicorp do |h| 4 h.name = "consul" 5 h.version = "1.6.2" 6 h.github_slug = "hashicorp/consul" 7end 8 9# Netlify redirects/headers 10proxy '_redirects', 'redirects.txt', ignore: true 11 12helpers do 13 # Returns a segment tracking ID such that local development is not 14 # tracked to production systems. 15 def segmentId() 16 if (ENV['ENV'] == 'production') 17 'IyzLrqXkox5KJ8XL4fo8vTYNGfiKlTCm' 18 else 19 '0EXTgkNx0Ydje2PGXVbRhpKKoe5wtzcE' 20 end 21 end 22 23 # Returns the FQDN of the image URL. 24 # 25 # @param [String] path 26 # 27 # @return [String] 28 def image_url(path) 29 File.join(base_url, image_path(path)) 30 end 31 32 # Get the title for the page. 33 # 34 # @param [Middleman::Page] page 35 # 36 # @return [String] 37 def title_for(page) 38 if page && page.data.page_title 39 return "#{page.data.page_title} - Consul by HashiCorp" 40 end 41 42 "Consul by HashiCorp" 43 end 44 45 # Get the description for the page 46 # 47 # @param [Middleman::Page] page 48 # 49 # @return [String] 50 def description_for(page) 51 description = (page.data.description || "Consul by HashiCorp") 52 .gsub('"', '') 53 .gsub(/\n+/, ' ') 54 .squeeze(' ') 55 56 return escape_html(description) 57 end 58 59 # This helps by setting the "active" class for sidebar nav elements 60 # if the YAML frontmatter matches the expected value. 61 def sidebar_current(expected) 62 current = current_page.data.sidebar_current || "" 63 if current.start_with?(expected) 64 return " class=\"active\"" 65 else 66 return "" 67 end 68 end 69 70 # Returns the id for this page. 71 # @return [String] 72 def body_id_for(page) 73 if !(name = page.data.sidebar_current).blank? 74 return "page-#{name.strip}" 75 end 76 if page.url == "/" || page.url == "/index.html" 77 return "page-home" 78 end 79 if !(title = page.data.page_title).blank? 80 return title 81 .downcase 82 .gsub('"', '') 83 .gsub(/[^\w]+/, '-') 84 .gsub(/_+/, '-') 85 .squeeze('-') 86 .squeeze(' ') 87 end 88 return "" 89 end 90 91 # Returns the list of classes for this page. 92 # @return [String] 93 def body_classes_for(page) 94 classes = [] 95 96 if !(layout = page.data.layout).blank? 97 classes << "layout-#{page.data.layout}" 98 end 99 100 if !(title = page.data.page_title).blank? 101 title = title 102 .downcase 103 .gsub('"', '') 104 .gsub(/[^\w]+/, '-') 105 .gsub(/_+/, '-') 106 .squeeze('-') 107 .squeeze(' ') 108 classes << "page-#{title}" 109 end 110 111 return classes.join(" ") 112 end 113end 114