Skip to content

Commit 3674691

Browse files
authored
Add RTL support using BSv5 (#2002)
1 parent 102892d commit 3674691

File tree

8 files changed

+50
-16
lines changed

8 files changed

+50
-16
lines changed

layouts/_default/baseof.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<!doctype html>
2-
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
2+
<html itemscope itemtype="http://schema.org/WebPage"
3+
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
4+
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
5+
class="no-js">
36
<head>
47
{{ partial "head.html" . }}
58
</head>

layouts/blog/baseof.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<!doctype html>
2-
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
2+
<html itemscope itemtype="http://schema.org/WebPage"
3+
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
4+
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
5+
class="no-js">
36
<head>
47
{{ partial "head.html" . }}
58
</head>

layouts/blog/baseof.print.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<!doctype html>
2-
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
2+
<html itemscope itemtype="http://schema.org/WebPage"
3+
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
4+
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
5+
class="no-js">
36
<head>
47
{{ partial "head.html" . }}
58
</head>

layouts/docs/baseof.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<!doctype html>
2-
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
2+
<html itemscope itemtype="http://schema.org/WebPage"
3+
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
4+
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
5+
class="no-js">
36
<head>
47
{{ partial "head.html" . }}
58
</head>

layouts/docs/baseof.print.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<!doctype html>
2-
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
2+
<html itemscope itemtype="http://schema.org/WebPage"
3+
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
4+
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
5+
class="no-js">
36
<head>
47
{{ partial "head.html" . }}
58
</head>

layouts/partials/head-css.html

+25-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1+
{{ $scssMain := "scss/main.scss" -}}
2+
{{ $css := resources.Get $scssMain
3+
| toCSS (dict "enableSourceMap" (not hugo.IsProduction)) -}}
4+
{{ $rtlCSS :=
5+
cond (eq .Site.Language.LanguageDirection "rtl")
6+
(resources.Get "vendor/bootstrap/dist/css/bootstrap.rtl.css")
7+
nil -}}
8+
9+
{{ if hugo.IsProduction -}}
10+
{{ with $rtlCSS -}}
11+
{{ $rtlCSS = . | postCSS | minify | fingerprint -}}
12+
{{ end -}}
13+
{{ $css = $css | postCSS | minify | fingerprint -}}
14+
<link rel="preload" href="{{ $css.RelPermalink }}" as="style">
15+
{{- end -}}
16+
17+
{{/* NOTE: when not in production, we don't apply `postCSS`. This makes it
18+
snappier to develop in Chrome, but makes it look sub-optimal in other browsers.
19+
*/ -}}
120

2-
{{ $scssMain := "scss/main.scss"}}
3-
{{ if not hugo.IsProduction }}
4-
{{/* Note the missing postCSS. This makes it snappier to develop in Chrome, but makes it look sub-optimal in other browsers. */}}
5-
{{ $css := resources.Get $scssMain | toCSS (dict "enableSourceMap" true) }}
621
<link href="{{ $css.RelPermalink }}" rel="stylesheet">
7-
{{ else }}
8-
{{ $css := resources.Get $scssMain | toCSS (dict "enableSourceMap" false) | postCSS | minify | fingerprint }}
9-
<link rel="preload" href="{{ $css.RelPermalink }}" as="style">
10-
<link href="{{ $css.RelPermalink }}" rel="stylesheet" integrity="{{ $css.Data.integrity }}">
11-
{{ end }}
22+
23+
{{ with $rtlCSS -}}
24+
<link href="{{ $rtlCSS.RelPermalink }}" rel="stylesheet">
25+
{{ end -}}
26+
27+
{{- /**/ -}}

layouts/partials/head.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{{ template "_internal/opengraph.html" . -}}
2525
{{ template "_internal/schema.html" . -}}
2626
{{ template "_internal/twitter_cards.html" . -}}
27-
{{ partialCached "head-css.html" . "asdf" -}}
27+
{{ partialCached "head-css.html" . "head-css-cache-key" }}
2828
<script
2929
src="https://code.jquery.com/jquery-3.7.1.min.js"
3030
integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="

layouts/swagger/baseof.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<!doctype html>
2-
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
2+
<html itemscope itemtype="http://schema.org/WebPage"
3+
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
4+
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
5+
class="no-js">
36
<head>
47
{{ partial "head.html" . }}
58
<title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} | {{ end }}{{ .Site.Title }}{{ end }}</title>

0 commit comments

Comments
 (0)