2014-10-20 13:57:22 -04:00
|
|
|
set :base_url, "https://www.packer.io/"
|
|
|
|
|
2014-10-06 20:35:19 -04:00
|
|
|
activate :hashicorp do |h|
|
2017-03-25 18:13:52 -04:00
|
|
|
h.name = "packer"
|
2017-10-13 21:23:58 -04:00
|
|
|
h.version = "1.1.1"
|
2017-04-18 21:03:26 -04:00
|
|
|
h.github_slug = "hashicorp/packer"
|
2017-03-25 18:13:52 -04:00
|
|
|
h.website_root = "website"
|
|
|
|
end
|
|
|
|
|
|
|
|
helpers do
|
2017-04-06 18:16:02 -04: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
|
|
|
|
|
2017-03-25 18:13:52 -04:00
|
|
|
# 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} - Packer by HashiCorp"
|
|
|
|
end
|
|
|
|
|
2017-09-12 18:06:54 -04:00
|
|
|
"Packer by HashiCorp"
|
|
|
|
end
|
2017-03-25 18:13:52 -04:00
|
|
|
|
|
|
|
# Get the description for the page
|
|
|
|
#
|
|
|
|
# @param [Middleman::Page] page
|
|
|
|
#
|
|
|
|
# @return [String]
|
|
|
|
def description_for(page)
|
|
|
|
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)
|
|
|
|
if !(name = page.data.sidebar_current).blank?
|
|
|
|
return "page-#{name.strip}"
|
|
|
|
end
|
|
|
|
if page.url == "/" || page.url == "/index.html"
|
|
|
|
return "page-home"
|
|
|
|
end
|
2017-03-28 16:21:43 -04:00
|
|
|
if !(title = page.data.page_title).blank?
|
|
|
|
return title
|
|
|
|
.downcase
|
|
|
|
.gsub('"', '')
|
|
|
|
.gsub(/[^\w]+/, '-')
|
|
|
|
.gsub(/_+/, '-')
|
|
|
|
.squeeze('-')
|
|
|
|
.squeeze(' ')
|
|
|
|
end
|
2017-03-25 18:13:52 -04:00
|
|
|
return ""
|
|
|
|
end
|
|
|
|
|
|
|
|
# Returns the list of classes for this page.
|
|
|
|
# @return [String]
|
|
|
|
def body_classes_for(page)
|
|
|
|
classes = []
|
|
|
|
|
2017-09-12 18:06:54 -04:00
|
|
|
if !(page.data.layout).blank?
|
2017-03-25 18:13:52 -04:00
|
|
|
classes << "layout-#{page.data.layout}"
|
|
|
|
end
|
|
|
|
|
2017-03-28 16:21:43 -04:00
|
|
|
if !(title = page.data.page_title).blank?
|
|
|
|
title = title
|
|
|
|
.downcase
|
|
|
|
.gsub('"', '')
|
|
|
|
.gsub(/[^\w]+/, '-')
|
|
|
|
.gsub(/_+/, '-')
|
|
|
|
.squeeze('-')
|
|
|
|
.squeeze(' ')
|
|
|
|
classes << "page-#{title}"
|
|
|
|
end
|
|
|
|
|
2017-03-25 18:13:52 -04:00
|
|
|
return classes.join(" ")
|
|
|
|
end
|
2013-06-24 19:25:42 -04:00
|
|
|
end
|