home-assistant.io/plugins/environment_variables.rb
Paulus Schoutsen 9cc2bce761 Make edit links GitHub aware (#5038)
* Make edit links GitHub aware

* Fix repo url

* don't mutate existing string

* Move comment

* Fix url
2018-03-28 09:18:38 +02:00

18 lines
661 B
Ruby

module Jekyll
class EnvironmentVariablesGenerator < Generator
def generate(site)
# https://www.netlify.com/docs/continuous-deployment/#build-environment-variables
repo_url = ENV['REPOSITORY_URL'] || 'https://github.com/home-assistant/home-assistant.github.io'
# Rewrite urls if repo url is the ssh format.
if repo_url.start_with? 'git@github.com:'
repo_url = repo_url.sub 'git@github.com:', 'https://github.com/'
end
# These values will be available as {{ site.NLY_REPOSITORY_URL }}
site.config['NLY_REPOSITORY_URL'] = repo_url
site.config['NLY_HEAD'] = ENV['HEAD'] || 'current'
end
end
end