This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
snippets/layouts/shortcodes/github_file.html

11 lines
342 B
HTML
Raw Permalink Normal View History

2019-09-21 19:39:21 +01:00
{{ $repo := .Get "repo" }}
{{ $path := .Get "path" }}
{{ $extension := index (last 1 (split $path ".")) 0 }}
{{ $data := getJSON "https://api.github.com/repos/" $repo "/contents/" $path }}
{{ $content := $data.content | base64Decode }}
{{ highlight $content $extension "" }}
<p><a href="{{ $data.html_url }}">View {{ $data.name }}</a></p>