{{ $main := resources.Get "js/main.js" }}
{{ $menu := resources.Get "js/menu.js" }}
{{ $prism := resources.Get "js/prism.js" }}
{{ $theme := resources.Get "js/theme.js" }}
{{ $secureJS := slice $main $menu $prism $theme | resources.Concat "bundle.js" | resources.Minify }}
<script type="text/javascript" src="{{ $secureJS.RelPermalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>

{{- if .Site.GoogleAnalytics }}
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id={{.Site.GoogleAnalytics}}"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag() { dataLayer.push(arguments); }
        gtag('js', new Date());

        gtag('config', '{{.Site.GoogleAnalytics}}');
    </script>
{{- end}}

{{- if .Site.Params.FathomAnalyticsDomain }}
    <!-- Fathom - simple website analytics - https://github.com/usefathom/fathom -->
    <script>
    (function(f, a, t, h, o, m){
        a[h]=a[h]||function(){
            (a[h].q=a[h].q||[]).push(arguments)
        };
        o=f.createElement('script'),
        m=f.getElementsByTagName('script')[0];
        o.async=1; o.src=t; o.id='fathom-script';
        m.parentNode.insertBefore(o,m)
    })(document, window, '//{{.Site.Params.FathomAnalyticsDomain}}/tracker.js', 'fathom');
    fathom('set', 'siteId', '{{.Site.Params.FathomAnalyticsSiteId}}');
    fathom('trackPageview');
    </script>
    <!-- / Fathom -->
{{- end }}

{{ range $val := $.Site.Params.customJS }}
	{{ if gt (len $val) 0 }}
		<script src="{{ $val }}"></script>
	{{ end }}
{{ end }}
