Skip to content

Commit ad430e4

Browse files
Improved head template. (#305)
1 parent 85d66e4 commit ad430e4

File tree

3 files changed

+26
-47
lines changed

3 files changed

+26
-47
lines changed

www/layouts/partials/head.html

+26-2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,29 @@
1919
<meta http-equiv="refresh" content="0; url={{ .Params.redirect_to }}">
2020
{{ end }}
2121

22-
{{ partial "head/js.html" . }}
23-
{{ partial "head/css.html" . }}
22+
{{ $opts := dict "format" "cjs" }}
23+
{{ if hugo.IsProduction }}
24+
{{ $opts = merge $opts (dict "minify" true) }}
25+
{{ end }}
26+
27+
{{ template "InsertJs" (dict "opts" $opts "collection" .Params.JsScripts "type" "text/javascript") }}
28+
{{ template "InsertJs" (dict "opts" $opts "collection" .Params.JsModules "type" "module") }}
29+
30+
{{ define "InsertJs" }}
31+
{{ $opts := .opts }}
32+
{{ $type := .type }}
33+
{{ range .collection }}
34+
{{- with resources.Get . }}
35+
{{- with . | js.Build (merge $opts (dict "targetPath" .RelPermalink)) }}
36+
<script src="{{ .RelPermalink }}" type="{{ $type }}"></script>
37+
{{- end }}
38+
{{- end }}
39+
{{ end }}
40+
{{ end }}
41+
42+
{{ range (.Params.cssSheets | append "css/theme.css") }}
43+
{{ with resources.Get . | minify }}
44+
<link rel="stylesheet" href="{{ .RelPermalink }}">
45+
{{ end }}
46+
{{ end }}
47+

www/layouts/partials/head/css.html

-22
This file was deleted.

www/layouts/partials/head/js.html

-23
This file was deleted.

0 commit comments

Comments
 (0)