diff options
author | weru <fromweru@gmail.com> | 2022-05-13 20:48:48 +0300 |
---|---|---|
committer | weru <16350351+onweru@users.noreply.github.com> | 2022-05-17 02:38:18 +0300 |
commit | 5e8b164ec9f762daea440a886ac954752c92d21f (patch) | |
tree | 723124277205a029f524fb84cf6d4ae6e53223ad | |
parent | 3ceec26c66cb05bb6c585c72e5de6df31abcf4df (diff) |
isolate codeblock settings definition
Signed-off-by: weru <fromweru@gmail.com>
-rw-r--r-- | layouts/_default/baseof.html | 23 | ||||
-rw-r--r-- | layouts/partials/func/getCodeBlockSettings.html | 25 | ||||
-rw-r--r-- | layouts/partials/head.html | 2 |
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 --> |