{{ if isset $.Site.Params "adsensepublisher" }}

{{ with .Params }}
    {{ with .sticky }}<amp-sticky-ad layout="nodisplay">{{ end }}
    <amp-ad type="adsense"
            {{ with .width }}width="{{ . }}"{{ end }}
    {{ with .height }}height="{{ . }}"{{ end }}
    {{ with .layout }}layout="{{ . }}"{{ end }}
    data-ad-client="{{ $.Site.Params.adsensePublisher }}"
    {{ with .slot }}data-ad-slot="{{ . }}"{{ end }}>
    </amp-ad>
    {{ with .sticky }}</amp-sticky-ad>{{ end }}
{{ end }}

{{ else }}
{{ if isset . "context" }}
{{ $publisher := .context.Site.Params.adsensePublisher }}
{{ with .sticky }}<amp-sticky-ad layout="nodisplay">{{ end }}
    <amp-ad type="adsense"
            {{ with .width }}width="{{ . }}"{{ end }}
    {{ with .height }}height="{{ . }}"{{ end }}
    {{ with .layout }}layout="{{ . }}"{{ end }}
    data-ad-client="{{ $publisher }}"
    {{ with .slot }}data-ad-slot="{{ . }}"{{ end }}>
    </amp-ad>
    {{ with .sticky }}</amp-sticky-ad>{{ end }}
{{ end }}

{{ end }}
