open-nomad/website/config.rb

111 lines
2.4 KiB
Ruby
Raw Normal View History

set :base_url, "https://www.nomadproject.io/"
2015-09-12 00:01:02 +00:00
activate :hashicorp do |h|
2015-10-26 14:40:47 +00:00
h.name = "nomad"
2019-06-12 18:56:18 +00:00
h.version = "0.9.3"
2015-10-26 14:40:47 +00:00
h.github_slug = "hashicorp/nomad"
2015-09-12 00:01:02 +00:00
end
helpers do
2018-03-08 20:31:17 +00:00
# Returns a segment tracking ID such that local development is not
# tracked to production systems.
def segmentId()
if (ENV['ENV'] == 'production')
'qW11yxgipKMsKFKQUCpTVgQUYftYsJj0'
else
'0EXTgkNx0Ydje2PGXVbRhpKKoe5wtzcE'
end
end
2017-04-06 22:37:36 +00:00
# Returns the FQDN of the image URL.
#
# @param [String] path
#
# @return [String]
def image_url(path)
File.join(base_url, image_path(path))
end
# Get the title for the page.
#
# @param [Middleman::Page] page
#
# @return [String]
def title_for(page)
if page && page.data.page_title
return "#{page.data.page_title} - Nomad by HashiCorp"
end
"Nomad by HashiCorp"
2017-03-28 03:37:59 +00:00
end
# Get the description for the page
#
# @param [Middleman::Page] page
#
# @return [String]
def description_for(page)
2017-03-28 03:37:59 +00:00
description = (page.data.description || "")
.gsub('"', '')
.gsub(/\n+/, ' ')
.squeeze(' ')
return escape_html(description)
end
# This helps by setting the "active" class for sidebar nav elements
# if the YAML frontmatter matches the expected value.
def sidebar_current(expected)
current = current_page.data.sidebar_current || ""
if current.start_with?(expected)
return " class=\"active\""
else
return ""
end
end
# Returns the id for this page.
# @return [String]
def body_id_for(page)
2017-03-28 03:37:59 +00:00
if !(name = page.data.sidebar_current).blank?
return "page-#{name.strip}"
end
2017-03-28 03:37:59 +00:00
if page.url == "/" || page.url == "/index.html"
return "page-home"
end
if !(title = page.data.page_title).blank?
return title
.downcase
.gsub('"', '')
.gsub(/[^\w]+/, '-')
.gsub(/_+/, '-')
.squeeze('-')
.squeeze(' ')
end
return ""
end
# Returns the list of classes for this page.
# @return [String]
def body_classes_for(page)
classes = []
2017-03-28 03:37:59 +00:00
if !(layout = page.data.layout).blank?
classes << "layout-#{page.data.layout}"
end
2017-03-28 03:37:59 +00:00
if !(title = page.data.page_title).blank?
title = title
.downcase
.gsub('"', '')
.gsub(/[^\w]+/, '-')
.gsub(/_+/, '-')
.squeeze('-')
.squeeze(' ')
classes << "page-#{title}"
end
return classes.join(" ")
end
end