From eeb73f54d9092fff37c7bfeadad331559bd0c786 Mon Sep 17 00:00:00 2001
From: weru <fromweru@gmail.com>
Date: Wed, 14 Apr 2021 23:02:22 +0000
Subject: [PATCH] keep base layout simple
---
layouts/_default/baseof.html | 18 ++----------------
layouts/partials/functions/getCodeConfig.html | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 3d2af8d..9dd2c73 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -1,23 +1,9 @@
<!doctype html>
-<html lang="{{ .Site.Language.Lang }}"{{ with .Site.Params.enableDarkMode }} class="dark"{{ end }}>
+<html lang="{{ site.Language.Lang }}"{{ with site.Params.enableDarkMode }} class="dark"{{ end }}>
<head>
{{- partial "head" . }}
</head>
- {{- $s := .Site.Params }}
- {{- $p := .Params }}
- {{- $maxCodeLines := default 100 $s.codeMaxLines }}
- {{- with $p.codeMaxLines }}
- {{- $maxCodeLines = . }}
- {{- end }}
- {{- $codeLineNumbers := default false $s.codeLineNumbers }}
- {{ with $p.codeLineNumbers }}
- {{- $codeLineNumbers = . }}
- {{ else }}
- {{ if eq $p.codeLineNumbers false }}
- {{- $codeLineNumbers = false }}
- {{ end }}
- {{ end }}
-<body class="page-{{ .Kind }}" data-code="{{ $maxCodeLines }}" data-lines="{{ $codeLineNumbers }}">
+<body class="page-{{ .Kind }}">
<header class="nav_header">
{{- partial "nav" . }}
</header>
diff --git a/layouts/partials/functions/getCodeConfig.html b/layouts/partials/functions/getCodeConfig.html
new file mode 100644
index 0000000..caaae6b
--- /dev/null
+++ b/layouts/partials/functions/getCodeConfig.html
@@ -0,0 +1,16 @@
+<!-- will return an array holding 1) Whether to show line numbers or not 2) maximum number of lines per code block -->
+{{- $s := .Site.Params }}
+{{- $p := .Params }}
+{{- $maxCodeLines := default 100 $s.codeMaxLines }}
+{{- with $p.codeMaxLines }}
+ {{- $maxCodeLines = . }}
+{{- end }}
+{{- $showLineNumbers := default false $s.showLineNumbers }}
+{{ with $p.showLineNumbers }}
+ {{- $showLineNumbers = . }}
+{{ else }}
+ {{ if eq $p.showLineNumbers false }}
+ {{- $showLineNumbers = false }}
+ {{ end }}
+{{- end }}
+{{- return (jsonify (dict "show" $showLineNumbers "maximum" $maxCodeLines)) }}
\ No newline at end of file
--
Gitblit v1.10.0