jekyll: automatic issue url generation for remote resources

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2022-06-01 10:04:42 +02:00
parent 050078c5f8
commit c2ee94c1b8
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
2 changed files with 16 additions and 4 deletions

View File

@ -4,6 +4,11 @@
{%- assign edit_url = page.edit_url -%}
{%- else -%}
{%- assign edit_url = "https://github.com/docker/docker.github.io/edit/master/" | append: page.path -%}
{%- endif -%}
{%- if page.issue_url -%}
{%- assign issue_url = page.issue_url -%}
{%- else -%}
{%- assign issue_url = "https://github.com/docker/docker.github.io/issues/new?body=File: [" | append: page.path | append: "](https://docs.docker.com" | append: page.url | append: ")" -%}
{%- endif -%} -->
<html lang="en">
{%- include head.html -%}
@ -63,7 +68,9 @@
{%- if edit_url != "" -%}
<li><a href="{{ edit_url }}"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit this page</a></li>
{%- endif -%}
<li><a href="https://github.com/docker/docker.github.io/issues/new?body=File: [{{ page.path }}](https://docs.docker.com{{ page.url }})" class="nomunge"><i class="fa fa-check" aria-hidden="true"></i> Request docs changes</a></li>
{%- if issue_url != "" -%}
<li><a href="{{ issue_url }}" class="nomunge"><i class="fa fa-check" aria-hidden="true"></i> Request docs changes</a></li>
{%- endif -%}
<li>{%- include theme-switch.html -%}</li>
</ul>
</div>

View File

@ -70,12 +70,17 @@ module Jekyll
ent.copy destent.path
next unless File.file?(ent.path) && File.extname(ent.path) == ".md"
# set edit url for markdown files in site config defaults
# set edit and issue url and remote info for markdown files in site config defaults
edit_url = "#{entry['repo']}/edit/#{entry['default_branch']}/#{file_clean}"
puts " edit_url: #{edit_url}"
issue_url = "#{entry['repo']}/issues/new?body=File: [#{file_clean}](https://docs.docker.com/#{destent.path.sub(/#{File.extname(destent.path)}$/, '')}/)"
puts " edit_url: #{edit_url}"
puts " issue_url: #{issue_url}"
site.config['defaults'] << {
"scope" => { "path" => destent.path },
"values" => { "edit_url" => edit_url },
"values" => {
"edit_url" => edit_url,
"issue_url" => issue_url
},
}
end, proc do |_| end)
end