Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/chipzoller/hugo-clarity.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorweru <fromweru@gmail.com>2022-05-13 20:17:48 +0300
committerweru <16350351+onweru@users.noreply.github.com>2022-05-17 02:38:18 +0300
commit9a8f1fc38d3fe696c28b5adfe0b59088269c210d (patch)
tree39180768df7c775437a1a92dc3399d0f9ba06dc8
parentb27858a816768058787e74d954afb71889762d36 (diff)
isolate main js & css script construction
Signed-off-by: weru <fromweru@gmail.com>
-rw-r--r--layouts/_default/baseof.html32
-rw-r--r--layouts/partials/func/getJavascriptBundle.html26
-rw-r--r--layouts/partials/func/getStylesBundle.html6
3 files changed, 35 insertions, 29 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 1bda34d..8cd0002 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -4,36 +4,9 @@
<html lang="{{ .Lang }}" data-figures="{{ $p.figurePositionShow }}"{{ if .IsPage }} class="page"{{ end }}{{ if .IsHome }} class="home"{{ end }}{{ with $s.enforceLightMode }} data-mode="lit"{{ end }}{{ with $s.enforceDarkMode }} data-mode="dim"{{ end }}>
<head>
{{- partial "head" . }}
- <!-- styles definition-->
- {{- $options := (dict "targetPath" "css/styles.css" "outputStyle" "compressed" "enableSourceMap" "true") -}}
- {{ $mainSassFile := "sass/main.sass" }}
- {{- $styles := resources.Get $mainSassFile | resources.ExecuteAsTemplate $mainSassFile . | resources.ToCSS $options | resources.Fingerprint "sha512" }}
-
- <!-- scripts definition -->
- {{- $highlightPath := "js/highlight.js" }}
- {{- $highlight := resources.Get $highlightPath | resources.ExecuteAsTemplate $highlightPath . }}
-
- {{- $variablesScriptPath := "js/variables.js" }}
- {{- $variables := resources.Get $variablesScriptPath | resources.ExecuteAsTemplate (printf "%s/js/variables.js" .Lang) . }}
-
- {{- $functionsScriptPath := "js/functions.js" }}
- {{- $functions := resources.Get $functionsScriptPath | resources.ExecuteAsTemplate $functionsScriptPath . }}
-
- {{- $codeScriptPath := "js/code.js" }}
- {{- $code := resources.Get $codeScriptPath | resources.ExecuteAsTemplate $codeScriptPath . }}
-
- {{- $customScriptPath := "js/custom.js" }}
- {{ if (fileExists "../../assets/js/custom.js") }}
- {{ $customScriptPath := "../../assets/js/custom.js" }}
- {{ end }}
- {{- $custom := resources.Get $customScriptPath | resources.ExecuteAsTemplate $customScriptPath . }}
-
- {{- $mainScriptPath := "js/index.js" }}
- {{- $main := resources.Get $mainScriptPath | resources.ExecuteAsTemplate $mainScriptPath . }}
-
- {{- $bundlePath := (printf "%s/js/bundle.js" .Lang ) }}
- {{- $bundle := slice $highlight $variables $functions $code $main $custom | resources.Concat $bundlePath | resources.Fingerprint "sha512" -}}
+ {{ $styles := partialCached "func/getStylesBundle" . }}
+ {{ $bundle := partialCached "func/getJavascriptBundle" . }}
<!-- preload assets declaration -->
<link rel="preload" href="{{ $styles.Permalink }}" integrity = "{{ $styles.Data.Integrity }}" as="style" crossorigin="anonymous">
<link rel="preload" href="{{ $bundle.Permalink }}" as="script" integrity=
@@ -73,6 +46,7 @@
</main>
{{- partialCached "icons" . }}
{{- partialCached "footer" . }}
+ {{ $bundle := partialCached "func/getJavascriptBundle" . }}
<script type="text/javascript" src="{{ $bundle.Permalink }}" integrity="{{ $bundle.Data.Integrity }}" crossorigin="anonymous"></script>
{{- partial "search/scripts" . }}
{{- with $s.customJS }}
diff --git a/layouts/partials/func/getJavascriptBundle.html b/layouts/partials/func/getJavascriptBundle.html
new file mode 100644
index 0000000..2a06e24
--- /dev/null
+++ b/layouts/partials/func/getJavascriptBundle.html
@@ -0,0 +1,26 @@
+<!-- scripts definition -->
+{{ $highlightPath := "js/highlight.js" }}
+{{ $highlight := resources.Get $highlightPath | resources.ExecuteAsTemplate $highlightPath . }}
+
+{{ $variablesScriptPath := "js/variables.js" }}
+{{ $variables := resources.Get $variablesScriptPath | resources.ExecuteAsTemplate (printf "%s/js/variables.js" .Lang) . }}
+
+{{ $functionsScriptPath := "js/functions.js" }}
+{{ $functions := resources.Get $functionsScriptPath | resources.ExecuteAsTemplate $functionsScriptPath . }}
+
+{{ $codeScriptPath := "js/code.js" }}
+{{ $code := resources.Get $codeScriptPath | resources.ExecuteAsTemplate $codeScriptPath . }}
+
+{{ $customScriptPath := "js/custom.js" }}
+{{ if (fileExists "../../assets/js/custom.js") }}
+ {{ $customScriptPath := "../../assets/js/custom.js" }}
+{{ end }}
+{{ $custom := resources.Get $customScriptPath | resources.ExecuteAsTemplate $customScriptPath . }}
+
+{{ $mainScriptPath := "js/index.js" }}
+{{ $main := resources.Get $mainScriptPath | resources.ExecuteAsTemplate $mainScriptPath . }}
+
+{{ $bundlePath := (printf "%s/js/bundle.js" .Lang ) }}
+{{ $bundle := slice $highlight $variables $functions $code $main $custom | resources.Concat $bundlePath | resources.Fingerprint "sha512" }}
+
+{{ return $bundle }} \ No newline at end of file
diff --git a/layouts/partials/func/getStylesBundle.html b/layouts/partials/func/getStylesBundle.html
new file mode 100644
index 0000000..e35c4a5
--- /dev/null
+++ b/layouts/partials/func/getStylesBundle.html
@@ -0,0 +1,6 @@
+<!-- styles definition-->
+{{ $options := (dict "targetPath" "css/styles.css" "outputStyle" "compressed" "enableSourceMap" "true") }}
+{{ $mainSassFile := "sass/main.sass" }}
+{{ $styles := resources.Get $mainSassFile | resources.ExecuteAsTemplate $mainSassFile . | resources.ToCSS $options | resources.Fingerprint "sha512" }}
+
+{{ return $styles }} \ No newline at end of file