From 9cc2bce7614cb67c999f5372f1172b7d67d9ab21 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 28 Mar 2018 00:18:38 -0700 Subject: [PATCH] Make edit links GitHub aware (#5038) * Make edit links GitHub aware * Fix repo url * don't mutate existing string * Move comment * Fix url --- plugins/environment_variables.rb | 17 +++++++++++++++++ source/_includes/edit_github.html | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 plugins/environment_variables.rb diff --git a/plugins/environment_variables.rb b/plugins/environment_variables.rb new file mode 100644 index 00000000000..7d9203f1643 --- /dev/null +++ b/plugins/environment_variables.rb @@ -0,0 +1,17 @@ +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 diff --git a/source/_includes/edit_github.html b/source/_includes/edit_github.html index f599869c811..b5fa2329b84 100644 --- a/source/_includes/edit_github.html +++ b/source/_includes/edit_github.html @@ -1,4 +1,4 @@ {% assign url_parts = page.url | split: '/' %} {% if page.hide_github_edit != true %} -
Edit this page on GitHub
+
Edit this page on GitHub
{% endif %}