summaryrefslogtreecommitdiff
path: root/themes/LoveIt/layouts/partials/plugin/style.html
blob: cbd89d9686a5cfc960b5a4102971d478052e53cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{{- if strings.HasPrefix .Source "<link" -}}
    {{- safeHTML .Source -}}
{{- else -}}
    {{- $href := .Source -}}
    {{- $integrity := .Integrity -}}
    {{- $resource := 0 -}}
    {{- if $href | and (not (urls.Parse $href).Host) -}}
        {{- $resource = resources.Get $href -}}
    {{- end -}}
    {{- with .Content -}}
        {{- $resource = resources.FromString $.Path . -}}
    {{- end -}}
    {{- if $resource -}}
        {{- with .Template -}}
            {{- $resource = $resource | resources.ExecuteAsTemplate . $.Context -}}
        {{- end -}}
        {{- with .ToCSS -}}
            {{- $options := . | merge (dict "outputStyle" "compressed") -}}
            {{- $resource = $resource | toCSS $options -}}
        {{- end -}}
        {{- if .Minify -}}
            {{- $resource = $resource | minify -}}
        {{- end -}}
        {{- with .Fingerprint -}}
            {{- $resource = $resource | fingerprint . -}}
            {{- $integrity = $resource.Data.Integrity -}}
        {{- end -}}
        {{- $href = $resource.RelPermalink -}}
    {{- end -}}
    {{- $attrs := printf `href="%v"` $href -}}
    {{- if .Crossorigin -}}
        {{- $attrs = ` crossorigin="anonymous"` | add $attrs -}}
    {{- end -}}
    {{- with $integrity -}}
        {{- $attrs = printf ` integrity="%v"` . | add $attrs -}}
    {{- end -}}
    {{- with .Attr -}}
        {{- $attrs = add " " . | add $attrs -}}
    {{- end -}}
    {{- if .Preload -}}
        <link rel="preload" {{ $attrs | safeHTMLAttr }} as="style" onload="this.onload=null;this.rel='stylesheet'">
        <noscript><link rel="stylesheet" {{ $attrs | safeHTMLAttr }}></noscript>
    {{- else -}}
        <link rel="stylesheet" {{ $attrs | safeHTMLAttr }}>
    {{- end -}}
{{- end -}}