From c49009b823de58ec21e4038eec91329cb538f8d2 Mon Sep 17 00:00:00 2001
From: Regis Philibert <login@regisphilibert.com>
Date: Thu, 21 Apr 2022 18:23:44 +0000
Subject: [PATCH] Only add html[dir] attr if languageDirection is explicitly set
---
layouts/_default/baseof.html | 2 +-
/dev/null | 3 ---
layouts/partials/func/GetLanguageDirection.html | 7 +++++++
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 3ef1373..dbda687 100755
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="{{ $.Site.LanguageCode | default "en" }}" {{ partial "language-direction.html" . | safeHTMLAttr }}>
+<html lang="{{ site.LanguageCode | default "en" }}" {{- with partialCached "func/GetLanguageDirection" "GetLanguageDirection" }} dir="{{ . }}" {{- end }}>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
diff --git a/layouts/partials/func/GetLanguageDirection.html b/layouts/partials/func/GetLanguageDirection.html
new file mode 100644
index 0000000..e42a423
--- /dev/null
+++ b/layouts/partials/func/GetLanguageDirection.html
@@ -0,0 +1,7 @@
+{{ $dir := "" }}
+{{ if ge hugo.Version "0.67.1" }}
+ {{ with site.Language.LanguageDirection }}
+ {{ $dir = . }}
+ {{ end }}
+{{ end }}
+{{ return $dir }}
diff --git a/layouts/partials/language-direction.html b/layouts/partials/language-direction.html
deleted file mode 100644
index 31fa90c..0000000
--- a/layouts/partials/language-direction.html
+++ /dev/null
@@ -1,3 +0,0 @@
-{{- if ge hugo.Version "0.67.1" -}}
- dir="{{ $.Site.Language.LanguageDirection | default "ltr" }}"
-{{- end -}}
--
Gitblit v1.10.0