{{- $pc := site.Config.Privacy.Instagram -}} {{- if not $pc.Disable -}} {{ $accessToken := site.Config.Services.Instagram.AccessToken }} {{- if not $accessToken -}} {{- 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 (|) otherwise the request will fail." -}} {{- else -}} {{- if $pc.Simple -}} {{ template "_internal/shortcodes/instagram_simple.html" . }} {{- else -}} {{ $id := .Get 0 }} {{ $hideCaption := cond (eq (.Get 1) "hidecaption") "1" "0" }} {{ $headers := dict "Authorization" (printf "Bearer %s" $accessToken) }} {{ with getJSON "https://graph.facebook.com/v8.0/instagram_oembed/?url=https://instagram.com/p/" $id "/&hidecaption=" $hideCaption $headers }} {{ .html | safeHTML }} {{ end }} {{- end -}} {{- end -}} {{- end -}}