summaryrefslogtreecommitdiffstats
path: root/layouts/partials/styles.html
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-05-05 08:39:57 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-05-05 08:39:57 +0200
commite21a3141ca659bf6140dc1350b4552b6ddddf357 (patch)
tree4761c2a3d3741730d950672fda35ad4caefe207d /layouts/partials/styles.html
parent1529a435c59cdc689572f76a1db52ba89918269a (diff)
downloadgohugo-theme-ed-e21a3141ca659bf6140dc1350b4552b6ddddf357.tar.gz
Add Highlight.js support
Diffstat (limited to 'layouts/partials/styles.html')
-rw-r--r--layouts/partials/styles.html27
1 files changed, 20 insertions, 7 deletions
diff --git a/layouts/partials/styles.html b/layouts/partials/styles.html
index f50dad5..af7c709 100644
--- a/layouts/partials/styles.html
+++ b/layouts/partials/styles.html
@@ -1,8 +1,21 @@
-{{- $sass := resources.Get "sass/style.scss" -}}
+{{- /* Styles */}}
+{{- $theme := resources.Get "sass/style.scss" | resources.ToCSS }}
+
+{{- /* include hljs' css if hljs is on */}}
+{{- $isHLJSdisabled := (site.Params.assets.disable_highlight_js | default false) }}
+{{- $hljs := (cond ($isHLJSdisabled) (" " | resources.FromString "assets/css/hljs-blank.css") (resources.Get "css/hljs/hljs-default.min.css")) }}
+
+{{- /* order is important */}}
+{{- $core := (slice $theme $hljs) | resources.Concat "assets/css/core.css" }}
+{{- $extended := (resources.Match "css/extended/*.css") | resources.Concat "assets/css/extended.css" }}
+
+{{- /* bundle all required css */}}
+{{- /* Add extended css after theme style */ -}}
+{{- $stylesheet := (slice $core $extended) | resources.Concat "assets/css/stylesheet.css" | minify }}
+
{{- if not site.Params.assets.disable_fingerprinting -}}
-{{- $style := $sass | resources.ToCSS | minify | fingerprint -}}
-<link rel="stylesheet" href="{{ $style.RelPermalink }}">
-{{- else -}}
-{{- $style := $sass | resources.ToCSS | minify -}}
-<link rel="stylesheet" href="{{ $style.RelPermalink }}">
-{{- end -}}
+ {{- $stylesheet := $stylesheet | fingerprint }}
+ {{ printf `<link crossorigin="anonymous" href="%s" integrity="%s" rel="preload stylesheet" as="style">` $stylesheet.RelPermalink $stylesheet.Data.Integrity | safeHTML }}
+{{- else }}
+ <link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" rel="preload stylesheet" as="style">
+{{- end }}