From c2ee94c1b80bee1f0f368042a3c56a283f429012 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 1 Jun 2022 10:04:42 +0200 Subject: [PATCH] jekyll: automatic issue url generation for remote resources Signed-off-by: CrazyMax --- _layouts/docs.html | 9 ++++++++- _plugins/fetch_remote.rb | 11 ++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/_layouts/docs.html b/_layouts/docs.html index f7446e6956..17bc31b751 100644 --- a/_layouts/docs.html +++ b/_layouts/docs.html @@ -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 -%} --> {%- include head.html -%} @@ -63,7 +68,9 @@ {%- if edit_url != "" -%}
  • Edit this page
  • {%- endif -%} -
  • Request docs changes
  • + {%- if issue_url != "" -%} +
  • Request docs changes
  • + {%- endif -%}
  • {%- include theme-switch.html -%}
  • diff --git a/_plugins/fetch_remote.rb b/_plugins/fetch_remote.rb index baffb7fc5c..35c284ee99 100644 --- a/_plugins/fetch_remote.rb +++ b/_plugins/fetch_remote.rb @@ -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