mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-21 02:02:26 +00:00
hugolib: Add shortcode for Instagram
This commit is contained in:
parent
001e2bbe8a
commit
dbb0c1cfc9
3 changed files with 64 additions and 0 deletions
|
@ -225,6 +225,19 @@ Extract the value from the field `data-id` and pass it to the shortcode:
|
||||||
|
|
||||||
{{</* speakerdeck 4e8126e72d853c0060001f97 */>}}
|
{{</* speakerdeck 4e8126e72d853c0060001f97 */>}}
|
||||||
|
|
||||||
|
### Instagram
|
||||||
|
|
||||||
|
If you'd like to embed photo from [Instagram](https://www.instagram.com/), all you need is photo ID from the URL, e. g.:
|
||||||
|
|
||||||
|
* https://www.instagram.com/p/BMokmydjG-M/
|
||||||
|
|
||||||
|
Pass it to the shortcode:
|
||||||
|
|
||||||
|
{{</* instagram BMokmydjG-M */>}}
|
||||||
|
|
||||||
|
Optionally, hide caption:
|
||||||
|
|
||||||
|
{{</* instagram BMokmydjG-M hidecaption */>}}
|
||||||
|
|
||||||
## Creating your own shortcodes
|
## Creating your own shortcodes
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -60,6 +60,7 @@ func (t *GoHTMLTemplate) EmbedShortcodes() {
|
||||||
{{ end }}`)
|
{{ 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("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("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() {
|
func (t *GoHTMLTemplate) EmbedTemplates() {
|
||||||
|
|
Loading…
Reference in a new issue