instagram.html (1154B)
1 {{- $pc := site.Config.Privacy.Instagram -}} 2 {{- if not $pc.Disable -}} 3 {{ $accessToken := site.Config.Services.Instagram.AccessToken }} 4 {{- if not $accessToken -}} 5 {{- erroridf "error-missing-instagram-accesstoken" "instagram shortcode: Missing config value for services.instagram.accessToken. This can be set in config.toml, but it is recommended to configure this via the HUGO_SERVICES_INSTAGRAM_ACCESSTOKEN OS environment variable. If you are using a Client Access Token, remember that you must combine it with your App ID using a pipe symbol (<APPID>|<CLIENTTOKEN>) otherwise the request will fail." -}} 6 {{- else -}} 7 {{- if $pc.Simple -}} 8 {{ template "_internal/shortcodes/instagram_simple.html" . }} 9 {{- else -}} 10 {{ $id := .Get 0 }} 11 {{ $hideCaption := cond (eq (.Get 1) "hidecaption") "1" "0" }} 12 {{ $headers := dict "Authorization" (printf "Bearer %s" $accessToken) }} 13 {{ with getJSON "https://graph.facebook.com/v8.0/instagram_oembed/?url=https://instagram.com/p/" $id "/&hidecaption=" $hideCaption $headers }} 14 {{ .html | safeHTML }} 15 {{ end }} 16 {{- end -}} 17 {{- end -}} 18 {{- end -}}