Add a Liquid template for Github PR links (#2380)

This commit is contained in:
Misty Stanley-Jones 2017-03-17 15:38:34 -07:00 committed by GitHub
parent 8d0c47c6c0
commit a79cdddc09
2 changed files with 25 additions and 1 deletions

12
_includes/github-pr.md Normal file
View File

@ -0,0 +1,12 @@
{% comment %}
Generates a Github PR URL from three parameters
Usage:
{% include github-pr.md org=docker repo=docker pr=12345 %}
If you omit the org or repo, they default to docker.
If you omit the pr, it defaults to NULL.
Output:
[#12345](https://github.com/docker/docker/pull/12345)
{% endcomment %}{% assign org = include.org | default: "docker" %}{% assign repo = include.repo | default: "docker" %}{% assign pr = include.pr | default: NULL %}{% assign github-url="https://github.com" %}{% capture pr-link %}[#{{ pr }}]({{ github-url }}/{{ org }}/{{ repo }}/pull/{{ pr }}){% endcapture %}{{ pr-link | strip_newlines }}

12
test.md
View File

@ -406,3 +406,15 @@ authorizedkeys:
> | Row 2 column 1 | Row 2 column 2 |
>
> And another sentence to top it all off.
## Linking
- [a normal link](https://docker.com/)
- <a href="https://docker.com/">an HTML link</a>
- A link to a Github PR in `docker/docker`: {% include github-pr.md pr=28199 %}
- A link to a Github PR in `docker/docker.github.io`: {% include github-pr.md repo=docker.github.io pr=9999 %}
(you can also specify `org=foo` to use a Github organization other than Docker).