From 36746913371a40c316b0c0ee19f37230ce639d2e Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Thu, 16 May 2024 18:50:26 -0400 Subject: [PATCH] Add RTL support using BSv5 (#2002) --- layouts/_default/baseof.html | 5 ++++- layouts/blog/baseof.html | 5 ++++- layouts/blog/baseof.print.html | 5 ++++- layouts/docs/baseof.html | 5 ++++- layouts/docs/baseof.print.html | 5 ++++- layouts/partials/head-css.html | 34 +++++++++++++++++++++++++--------- layouts/partials/head.html | 2 +- layouts/swagger/baseof.html | 5 ++++- 8 files changed, 50 insertions(+), 16 deletions(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 29ad5768d7..e390629146 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,5 +1,8 @@ - + {{ partial "head.html" . }} diff --git a/layouts/blog/baseof.html b/layouts/blog/baseof.html index b378805af6..97f5951ae7 100644 --- a/layouts/blog/baseof.html +++ b/layouts/blog/baseof.html @@ -1,5 +1,8 @@ - + {{ partial "head.html" . }} diff --git a/layouts/blog/baseof.print.html b/layouts/blog/baseof.print.html index 99e3c1c4d1..21e63c5f79 100644 --- a/layouts/blog/baseof.print.html +++ b/layouts/blog/baseof.print.html @@ -1,5 +1,8 @@ - + {{ partial "head.html" . }} diff --git a/layouts/docs/baseof.html b/layouts/docs/baseof.html index 210b6af52a..2a640c3a31 100644 --- a/layouts/docs/baseof.html +++ b/layouts/docs/baseof.html @@ -1,5 +1,8 @@ - + {{ partial "head.html" . }} diff --git a/layouts/docs/baseof.print.html b/layouts/docs/baseof.print.html index 41e0659b3e..e839aa946c 100644 --- a/layouts/docs/baseof.print.html +++ b/layouts/docs/baseof.print.html @@ -1,5 +1,8 @@ - + {{ partial "head.html" . }} diff --git a/layouts/partials/head-css.html b/layouts/partials/head-css.html index d2178317d4..484efe79bc 100644 --- a/layouts/partials/head-css.html +++ b/layouts/partials/head-css.html @@ -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 -}} + +{{- 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) }} -{{ else }} -{{ $css := resources.Get $scssMain | toCSS (dict "enableSourceMap" false) | postCSS | minify | fingerprint }} - - -{{ end }} + +{{ with $rtlCSS -}} + +{{ end -}} + +{{- /**/ -}} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index e4a6012a98..4f1b654b2d 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -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" }}