1
0
mirror of https://github.com/alanorth/hugo-theme-bootstrap4-blog.git synced 2024-12-19 00:52:19 +01:00

Add right-to-left version of CSS

This uses rtlcss to make a right-to-left version of the CSS and then
utilizes Hugo's Language variable to conditionally include it. Also,
we set the "dir" attribute on the HTML tag if the currently rendered
language is Arabic.
This commit is contained in:
Alan Orth 2019-04-18 22:19:42 +03:00
parent 974203f6eb
commit 6a3bdc53fd
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
5 changed files with 6683 additions and 3 deletions

View File

@ -1,5 +1,6 @@
{ {
"style": "static/css/style.css", "style": "static/css/style.css",
"stylertl": "static/css/style.rtl.css",
"cookieconsentcss": "static/css/cookieconsent.min.css", "cookieconsentcss": "static/css/cookieconsent.min.css",
"cookieconsentjs": "static/js/cookieconsent.min.js" "cookieconsentjs": "static/js/cookieconsent.min.js"
} }

View File

@ -1,3 +1,4 @@
style = "sha384-G5B34w7DFTumWTswxYzTX7NWfbvQEg1HbFFEg6ItN03uTAAoS2qkPS/fu3LhuuSA" style = "sha384-G5B34w7DFTumWTswxYzTX7NWfbvQEg1HbFFEg6ItN03uTAAoS2qkPS/fu3LhuuSA"
stylertl = "sha384-dagnrD/kTFcYqySe+3RarQ5X+ctARiVi8uLCNhk2FEbh6YrAPkiP+1hMM9pKx7FU"
cookieconsentcss = "sha384-6iYDyQZuuNT7DcPJGXx241czdv2+GDGUcXRiqw1iXrjgYMTorSetxFP3JCMQMwnR" cookieconsentcss = "sha384-6iYDyQZuuNT7DcPJGXx241czdv2+GDGUcXRiqw1iXrjgYMTorSetxFP3JCMQMwnR"
cookieconsentjs = "sha384-PDjg2ZdS3khPzd53i18+7tzB32JVQfFMrTXYo21RqPgUmEVAPwIhxOUF/8sP79CS" cookieconsentjs = "sha384-PDjg2ZdS3khPzd53i18+7tzB32JVQfFMrTXYo21RqPgUmEVAPwIhxOUF/8sP79CS"

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ .Lang }}"> <html lang="{{ .Lang }}" {{ if eq .Lang "ar" }}dir="rtl"{{ end }}>
<head> <head>
{{ partial "head-meta.html" . }} {{ partial "head-meta.html" . }}
@ -12,8 +12,13 @@
<title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title> <title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
{{ if eq .Lang "ar" }}
{{ "<!-- ar -->" | safeHTML }}
<link href="{{ .Site.BaseURL }}css/style.rtl.css" rel="stylesheet"{{ if not .Site.Params.disable_sri }} integrity="{{ .Site.Data.sri.styleltr}}" crossorigin="anonymous"{{ end }}>
{{ else }}
{{ "<!-- combined, minified CSS -->" | safeHTML }} {{ "<!-- combined, minified CSS -->" | safeHTML }}
<link href="{{ .Site.BaseURL }}css/style.css" rel="stylesheet"{{ if not .Site.Params.disable_sri }} integrity="{{ .Site.Data.sri.style}}" crossorigin="anonymous"{{ end }}> <link href="{{ .Site.BaseURL }}css/style.css" rel="stylesheet"{{ if not .Site.Params.disable_sri }} integrity="{{ .Site.Data.sri.style}}" crossorigin="anonymous"{{ end }}>
{{ end }}
{{ "<!-- RSS 2.0 feed -->" | safeHTML }} {{ "<!-- RSS 2.0 feed -->" | safeHTML }}
{{ with .OutputFormats.Get "rss" -}} {{ with .OutputFormats.Get "rss" -}}

View File

@ -8,11 +8,12 @@
}, },
"scripts": { "scripts": {
"build:css": "node-sass --output-style expanded --precision 6 source/scss/style.scss static/css/style.css.tmp && cleancss --level 1 static/css/style.css.tmp -o static/css/style.css", "build:css": "node-sass --output-style expanded --precision 6 source/scss/style.scss static/css/style.css.tmp && cleancss --level 1 static/css/style.css.tmp -o static/css/style.css",
"build:ltrcss": "rtlcss -s static/css/style.css.tmp static/css/style.rtl.css.tmp && cleancss --level 1 static/css/style.rtl.css.tmp -o static/css/style.rtl.css",
"build:fonts": "cp node_modules/font-awesome/fonts/* static/fonts", "build:fonts": "cp node_modules/font-awesome/fonts/* static/fonts",
"build:cookieconsent": "cp node_modules/cookieconsent/build/cookieconsent.min.css static/css && cp node_modules/cookieconsent/build/cookieconsent.min.js static/js", "build:cookieconsent": "cp node_modules/cookieconsent/build/cookieconsent.min.css static/css && cp node_modules/cookieconsent/build/cookieconsent.min.js static/js",
"build:generatesri": "node build/sri.js > data/sri.toml", "build:generatesri": "node build/sri.js > data/sri.toml",
"build": "npm run build:css && npm run build:fonts && npm run build:cookieconsent && npm run build:generatesri && npm run clean", "build": "npm run build:css && npm run build:ltrcss && npm run build:fonts && npm run build:cookieconsent && npm run build:generatesri && npm run clean",
"clean": "rm static/css/style.css.tmp" "clean": "rm static/css/style.css.tmp static/css/style.rtl.css.tmp"
}, },
"keywords": "hugo", "keywords": "hugo",
"author": "Alan Orth", "author": "Alan Orth",

6672
static/css/style.rtl.css Normal file

File diff suppressed because it is too large Load Diff