Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RTL support using BSv5 #2002

Merged
merged 3 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<!doctype html>
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
<html itemscope itemtype="http://schema.org/WebPage"
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
class="no-js">
<head>
{{ partial "head.html" . }}
</head>
Expand Down
5 changes: 4 additions & 1 deletion layouts/blog/baseof.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<!doctype html>
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
<html itemscope itemtype="http://schema.org/WebPage"
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
class="no-js">
<head>
{{ partial "head.html" . }}
</head>
Expand Down
5 changes: 4 additions & 1 deletion layouts/blog/baseof.print.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<!doctype html>
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
<html itemscope itemtype="http://schema.org/WebPage"
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
class="no-js">
<head>
{{ partial "head.html" . }}
</head>
Expand Down
5 changes: 4 additions & 1 deletion layouts/docs/baseof.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<!doctype html>
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
<html itemscope itemtype="http://schema.org/WebPage"
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
class="no-js">
<head>
{{ partial "head.html" . }}
</head>
Expand Down
5 changes: 4 additions & 1 deletion layouts/docs/baseof.print.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<!doctype html>
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
<html itemscope itemtype="http://schema.org/WebPage"
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
class="no-js">
<head>
{{ partial "head.html" . }}
</head>
Expand Down
34 changes: 25 additions & 9 deletions layouts/partials/head-css.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
{{ $scssMain := "scss/main.scss" -}}
{{ $css := resources.Get $scssMain
| toCSS (dict "enableSourceMap" (not hugo.IsProduction)) -}}
{{ $rtlCSS :=
cond (eq .Site.Language.LanguageDirection "rtl")
(resources.Get "vendor/bootstrap/dist/css/bootstrap.rtl.css")
nil -}}

{{ if hugo.IsProduction -}}
{{ with $rtlCSS -}}
{{ $rtlCSS = . | postCSS | minify | fingerprint -}}
{{ end -}}
{{ $css = $css | postCSS | minify | fingerprint -}}
<link rel="preload" href="{{ $css.RelPermalink }}" as="style">
{{- end -}}

{{/* NOTE: when not in production, we don't apply `postCSS`. This makes it
snappier to develop in Chrome, but makes it look sub-optimal in other browsers.
*/ -}}

{{ $scssMain := "scss/main.scss"}}
{{ if not hugo.IsProduction }}
{{/* Note the missing postCSS. This makes it snappier to develop in Chrome, but makes it look sub-optimal in other browsers. */}}
{{ $css := resources.Get $scssMain | toCSS (dict "enableSourceMap" true) }}
<link href="{{ $css.RelPermalink }}" rel="stylesheet">
{{ else }}
{{ $css := resources.Get $scssMain | toCSS (dict "enableSourceMap" false) | postCSS | minify | fingerprint }}
<link rel="preload" href="{{ $css.RelPermalink }}" as="style">
<link href="{{ $css.RelPermalink }}" rel="stylesheet" integrity="{{ $css.Data.integrity }}">
{{ end }}

{{ with $rtlCSS -}}
<link href="{{ $rtlCSS.RelPermalink }}" rel="stylesheet">
{{ end -}}

{{- /**/ -}}
2 changes: 1 addition & 1 deletion layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{{ template "_internal/opengraph.html" . -}}
{{ template "_internal/schema.html" . -}}
{{ template "_internal/twitter_cards.html" . -}}
{{ partialCached "head-css.html" . "asdf" -}}
{{ partialCached "head-css.html" . "head-css-cache-key" }}
<script
src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="
Expand Down
5 changes: 4 additions & 1 deletion layouts/swagger/baseof.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<!doctype html>
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js">
<html itemscope itemtype="http://schema.org/WebPage"
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
{{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
class="no-js">
<head>
{{ partial "head.html" . }}
<title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} | {{ end }}{{ .Site.Title }}{{ end }}</title>
Expand Down