github.com/diptanu/nomad@v0.5.7-0.20170516172507-d72e86cbe3d9/website/config.rb (about) 1 set :base_url, "https://www.nomadproject.io/" 2 3 activate :hashicorp do |h| 4 h.name = "nomad" 5 h.version = "0.5.6" 6 h.github_slug = "hashicorp/nomad" 7 end 8 9 helpers do 10 # Returns the FQDN of the image URL. 11 # 12 # @param [String] path 13 # 14 # @return [String] 15 def image_url(path) 16 File.join(base_url, image_path(path)) 17 end 18 19 # Get the title for the page. 20 # 21 # @param [Middleman::Page] page 22 # 23 # @return [String] 24 def title_for(page) 25 if page && page.data.page_title 26 return "#{page.data.page_title} - Nomad by HashiCorp" 27 end 28 29 "Nomad by HashiCorp" 30 end 31 32 # Get the description for the page 33 # 34 # @param [Middleman::Page] page 35 # 36 # @return [String] 37 def description_for(page) 38 description = (page.data.description || "") 39 .gsub('"', '') 40 .gsub(/\n+/, ' ') 41 .squeeze(' ') 42 43 return escape_html(description) 44 end 45 46 # This helps by setting the "active" class for sidebar nav elements 47 # if the YAML frontmatter matches the expected value. 48 def sidebar_current(expected) 49 current = current_page.data.sidebar_current || "" 50 if current.start_with?(expected) 51 return " class=\"active\"" 52 else 53 return "" 54 end 55 end 56 57 # Returns the id for this page. 58 # @return [String] 59 def body_id_for(page) 60 if !(name = page.data.sidebar_current).blank? 61 return "page-#{name.strip}" 62 end 63 if page.url == "/" || page.url == "/index.html" 64 return "page-home" 65 end 66 if !(title = page.data.page_title).blank? 67 return title 68 .downcase 69 .gsub('"', '') 70 .gsub(/[^\w]+/, '-') 71 .gsub(/_+/, '-') 72 .squeeze('-') 73 .squeeze(' ') 74 end 75 return "" 76 end 77 78 # Returns the list of classes for this page. 79 # @return [String] 80 def body_classes_for(page) 81 classes = [] 82 83 if !(layout = page.data.layout).blank? 84 classes << "layout-#{page.data.layout}" 85 end 86 87 if !(title = page.data.page_title).blank? 88 title = title 89 .downcase 90 .gsub('"', '') 91 .gsub(/[^\w]+/, '-') 92 .gsub(/_+/, '-') 93 .squeeze('-') 94 .squeeze(' ') 95 classes << "page-#{title}" 96 end 97 98 return classes.join(" ") 99 end 100 end