mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-18 14:56:53 +00:00
Make edit links GitHub aware (#5038)
* Make edit links GitHub aware * Fix repo url * don't mutate existing string * Move comment * Fix url
This commit is contained in:
parent
88c8cc2ff1
commit
9cc2bce761
17
plugins/environment_variables.rb
Normal file
17
plugins/environment_variables.rb
Normal file
@ -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
|
@ -1,4 +1,4 @@
|
||||
{% assign url_parts = page.url | split: '/' %}
|
||||
{% if page.hide_github_edit != true %}
|
||||
<div class='edit-github'><a href='https://github.com/home-assistant/home-assistant.github.io/tree/current/source/{{ page.path }}'>Edit this page on GitHub</a></div>
|
||||
<div class='edit-github'><a href='{{ site.NLY_REPOSITORY_URL }}/tree/{{ site.NLY_HEAD }}/source/{{ page.path }}'>Edit this page on GitHub</a></div>
|
||||
{% endif %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user