File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -385,6 +385,19 @@ export default function (eleventyConfig: any) {
385
385
}
386
386
) ;
387
387
388
+ // Renders a link to a GitHub commit or pull request, in parentheses
389
+ eleventyConfig . addShortcode ( "gh" , ( id : string ) => {
390
+ if ( / ^ # \d + $ / . test ( id ) ) {
391
+ const num = id . slice ( 1 ) ;
392
+ return `<a href="https://github.com/${ GH_ORG } /${ GH_REPO } /pull/${ num } " aria-label="pull request ${ num } ">${ id } </a>`
393
+ }
394
+ else if ( / ^ [ 0 - 9 a - f ] { 7 , } $ / . test ( id ) ) {
395
+ const sha = id . slice ( 0 , 7 ) ; // Truncate in case full SHA was passed
396
+ return `<a href="https://github.com/${ GH_ORG } /${ GH_REPO } /commit/${ sha } " aria-label="commit ${ sha } ">${ sha } </a>`
397
+ }
398
+ else throw new Error ( `Invalid SHA or PR ID passed to gh tag: ${ id } ` ) ;
399
+ } ) ;
400
+
388
401
// Renders a section box (used for About this Technique and Guideline / SC)
389
402
eleventyConfig . addPairedShortcode (
390
403
"sectionbox" ,
You can’t perform that action at this time.
0 commit comments