hugolib: Add shortcode for Instagram

This commit is contained in:
Victor Kropp
2016-11-14 00:04:28 +01:00
committed by Bjørn Erik Pedersen
parent 001e2bbe8a
commit dbb0c1cfc9
3 changed files with 64 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ func (t *GoHTMLTemplate) EmbedShortcodes() {
{{ end }}`)
t.AddInternalShortcode("gist.html", `<script src="//gist.github.com/{{ index .Params 0 }}/{{ index .Params 1 }}.js{{if len .Params | eq 3 }}?file={{ index .Params 2 }}{{end}}"></script>`)
t.AddInternalShortcode("tweet.html", `{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }}`)
t.AddInternalShortcode("instagram.html", `{{ if len .Params | eq 2 }}{{ if eq (.Get 1) "hidecaption" }}{{ (getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=1").html | safeHTML }}{{ end }}{{ else }}{{ (getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=0").html | safeHTML }}{{ end }}`)
}
func (t *GoHTMLTemplate) EmbedTemplates() {