<!-- Prematurely connect to the servers to save some milliseconds -->
<!-- <link rel="preload"> is only in recent browser versions, so we keep "dns-prefetch" and "preconnect" -->
<!-- <link rel="prefetch" loads content the user may request *after* the page loads -->

{{- with $.Site.Params.thumbnail -}}
<meta name="thumbnail" content="{{ partial "make_link" (dict "URL" . "Root" $) }}" />
{{- end -}}

{{ partial "fontawesome/head.html" . }}

{{ partial "matomo/head.html" . }}

<!-- {{ partial "styles" (dict "Asset" "css/foundation.css" "Root" $) }} -->



<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.6.3/css/foundation.min.css" integrity="sha256-ogmFxjqiTMnZhxCqVmcqTvjfe1Y/ec4WaRj/aQPvn+I=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.8/lunr.min.js" integrity="sha256-34Si1Y6llMBKM3G0jQILVeoQKEwuxjbk4zGWXXMT4ps=" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.6.3/js/foundation.min.js" integrity="sha256-pRF3zifJRA9jXGv++b06qwtSqX1byFQOLjqa2PTEb2o=" crossorigin="anonymous"></script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fork-awesome/1.1.7/css/fork-awesome.min.css" integrity="sha256-gsmEoJAws/Kd3CjuOQzLie5Q3yshhvmo7YNtBG7aaEY=" crossorigin="anonymous" />



{{- $assets := slice -}}

{{- .Scratch.Set "sitevar" $.Site -}}
{{- partial "css/color/parse_color" .Scratch -}}
{{- .Scratch.Set "label" "alt_bg" -}}
{{- partial "css/color/detect_light_or_dark" .Scratch -}}

{{- if ($.Scratch.Get "alt_bg_is_dark") -}}
    {{- if or $.Site.Params.http2 (getenv "HUGO_HTTP2") -}}
        {{- partial "styles" (dict "Asset" "css/dark.css" "Root" $) -}}
    {{- else -}}
        {{- .Scratch.Set "code_css" "css/dark.css" -}}
    {{- end -}}
{{- else -}}
    {{- if or $.Site.Params.http2 (getenv "HUGO_HTTP2") -}}
        {{- partial "styles" (dict "Asset" "css/light.css" "Root" $) -}}
    {{- else -}}
        {{- .Scratch.Set "code_css" "css/light.css" -}}
    {{- end -}}
{{- end -}}

{{ partial "styles" (dict "Src" "/styles.css" "Root" $) }}

{{- if or $.Site.Params.http2 (getenv "HUGO_HTTP2") -}}
    {{ $files := slice "reset" "fonts" "classes" "pagination" "page" "widgets" }}
    {{ range $f := $files }}
        {{- partial "styles" (dict "Asset" (printf "css/%s.css" $f) "Root" $ ) -}}
    {{- end -}}
{{ end }}

{{- if not (or $.Site.Params.http2 (getenv "HUGO_HTTP2")) -}}
    {{- $reset := resources.Get "css/reset.css" -}}
    {{- $codecss := resources.Get (.Scratch.Get "code_css") -}}
    {{- $fonts := resources.Get "css/fonts.css" -}}
    {{- $classes := resources.Get "css/classes.css" -}}
    {{- $pagination := resources.Get "css/pagination.css" -}}
    {{- $page := resources.Get "css/page.css" -}}
    {{- $widgets := resources.Get "css/widgets.css" -}}
    {{- $css := slice $reset $codecss $fonts $classes $pagination $page $widgets | resources.Concat "css/bundle.css" | fingerprint -}}
    {{- partial "styles" (dict "Src" $css.RelPermalink "Integrity" $css.Data.Integrity "Root" $ ) -}}
{{- end -}}

{{ if eq .Kind "page" }}
    {{ partial "styles" (dict "Asset" "css/single.css" "Root" $) }}
{{ else }}
    {{ partial "styles" (dict "Asset" "css/list.css" "Root" $) }}
{{ end }}

{{ if .Content -}}
    {{ $figures := findRE "<figure" .Content -}}
    {{ $forms := findRE "<input" .Content -}}
    {{ $tables := findRE "<table" .Content -}}
    
    {{ if gt (len $figures) 0 }}
        {{ partial "styles" (dict "Asset" "css/figure.css" "Root" $) }}
    {{ end }}
    
    {{ if or (gt (len $forms) 0) $.Site.Params.comments.provider }}
        {{ partial "styles" (dict "Asset" "css/forms.css" "Root" $) }}
    {{ end }}
    
    {{ if gt (len $tables) 0 }}
        {{ partial "styles" (dict "Asset" "css/table.css" "Root" $) }}
    {{ end }}
{{ end -}}

{{ if $.Site.Params.iubenda.id }}
    {{ partial "styles" (dict "Asset" "css/iubenda.css" "Root" $) }}
{{ end }}

{{- $url := "" -}}
{{- $integrity := "" -}}
{{- if $.Site.Params.no_minify -}}
    {{- $res := resources.Get "css/print.css" | fingerprint -}}
    {{- $url = $res.RelPermalink -}}
    {{- $integrity = $res.Data.Integrity -}}
{{- else -}}
    {{- $res := resources.Get "css/print.css" | minify | fingerprint -}}
    {{- $url = $res.RelPermalink -}}
    {{- $integrity = $res.Data.Integrity -}}
{{- end -}}
<link rel="preload" media="print" type="text/css" href="{{ partial "make_link" (dict "URL" $url "Root" $) }}" integrity="{{ $integrity }}" as="style">

{{- partial "shortcodes/partial.html" (dict "Prop" "head" "Root" $) -}}

{{- partial "sidebar/partial.html" (dict "Prop" "head" "Root" $) -}}

{{- partial "comments/partial.html" (dict "Prop" "head" "Root" $) -}}

{{- partial "plugins/partial.html" (dict "Prop" "head" "Root" $) -}}

{{ partial "matomo/head2.html" . }}

{{- partial "favicons.html" . -}}
