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:48:48 +0300
committerweru <16350351+onweru@users.noreply.github.com>2022-05-17 02:38:18 +0300
commit5e8b164ec9f762daea440a886ac954752c92d21f (patch)
tree723124277205a029f524fb84cf6d4ae6e53223ad
parent3ceec26c66cb05bb6c585c72e5de6df31abcf4df (diff)
isolate codeblock settings definition
Signed-off-by: weru <fromweru@gmail.com>
-rw-r--r--layouts/_default/baseof.html23
-rw-r--r--layouts/partials/func/getCodeBlockSettings.html25
-rw-r--r--layouts/partials/head.html2
3 files changed, 29 insertions, 21 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 1d555da..d5bd6c4 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -1,4 +1,4 @@
-{{- $s := .Site.Params }}
+{{- $s := site.Params }}
{{- $p := .Params }}
<!DOCTYPE html>
<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 }}>
@@ -6,25 +6,8 @@
{{- partial "head" . }}
{{ partial "hooks/head-end.html" . }}
</head>
- {{- $maxCodeLines := 100 }}
- {{- with $s.codeMaxLines }}
- {{- $maxCodeLines = . }}
- {{- end }}
- {{- with $p.codeMaxLines }}
- {{- $maxCodeLines = . }}
- {{- end }}
- {{- $codeLineNumbers := false }}
- {{ with $s.codeLineNumbers }}
- {{- $codeLineNumbers = . }}
- {{ end }}
- {{ with $p.codeLineNumbers }}
- {{- $codeLineNumbers = . }}
- {{ else }}
- {{ if eq $p.codeLineNumbers false }}
- {{- $codeLineNumbers = false }}
- {{ end }}
- {{ end }}
- <body data-code="{{ $maxCodeLines }}" data-lines="{{ $codeLineNumbers }}" id="documentTop">
+ {{ $codeBlockConfig := partial "func/getCodeBlockSettings" (dict "params" .Params) }}
+ <body data-code="{{ $codeBlockConfig.max }}" data-lines="{{ $codeBlockConfig.lines }}" id="documentTop">
{{- partial "header" . }}
<main>
{{- block "main" . }}{{ end }}
diff --git a/layouts/partials/func/getCodeBlockSettings.html b/layouts/partials/func/getCodeBlockSettings.html
new file mode 100644
index 0000000..61e7079
--- /dev/null
+++ b/layouts/partials/func/getCodeBlockSettings.html
@@ -0,0 +1,25 @@
+{{- $s := site.Params }}
+{{- $p := .params }}
+{{ $maxCodeLines := 100 }}
+{{ with $s.codeMaxLines }}
+ {{ $maxCodeLines = . }}
+{{ end }}
+{{ with $p.codeMaxLines }}
+ {{ $maxCodeLines = . }}
+{{ end }}
+
+{{ $codeLineNumbers := false }}
+{{ with $s.codeLineNumbers }}
+ {{ $codeLineNumbers = . }}
+{{ end }}
+{{ with $p.codeLineNumbers }}
+ {{ $codeLineNumbers = . }}
+ {{ else }}
+ {{ if eq $p.codeLineNumbers false }}
+ {{ $codeLineNumbers = false }}
+ {{ end }}
+{{ end }}
+
+{{ $config := (dict "max" $maxCodeLines "lines" $codeLineNumbers) }}
+
+{{ return $config }}
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index ea2147a..507d2fa 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -22,7 +22,7 @@
{{- partialCached "favicon" . }}
<link rel="canonical" href="{{ .Permalink }}">
{{ range .AlternativeOutputFormats -}}
- {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
+ {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
<!-- preload assets declaration -->