🌐 Add RTL language support

pull/100/head
James Panther 2022-01-11 16:17:49 +11:00
parent 1b9b660abe
commit cdf56a1e11
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
15 changed files with 161 additions and 36 deletions

View File

@ -9,11 +9,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added ### Added
- Multilingual support - Multilingual support
- Right-to-left (RTL) language support
### Changed ### Changed
- Upgrade to Tailwind v3.0.12 - Upgrade to Tailwind v3.0.12
- Author images are now Hugo assets - Author images are now Hugo assets
- Required Hugo version is now 0.87.0 or later
## [1.6.2] - 2022-01-07 ## [1.6.2] - 2022-01-07

View File

@ -11,13 +11,13 @@ Congo is designed to be a simple, lightweight theme for [Hugo](https://gohugo.io
## Features ## Features
- Built with Tailwind CSS JIT for minified stylesheets without any excess code - Fully responsive layout built with Tailwind CSS v3
- Fully responsive layout
- Multiple colour schemes (or fully customise your own) - Multiple colour schemes (or fully customise your own)
- Dark mode (forced on/off or auto-switching with user toggle) - Dark mode (forced on/off or auto-switching with user toggle)
- Highly customisable configuration - Highly customisable configuration
- Multiple homepage layouts - Multiple homepage layouts
- Flexible with any content types, taxonomies and menus - Flexible with any content types, taxonomies and menus
- Multilingual content support inlcuding support for RTL languages
- Ability to link to posts on third-party websites - Ability to link to posts on third-party websites
- Diagrams and visualisations using Mermaid - Diagrams and visualisations using Mermaid
- Charts using Chart.js - Charts using Chart.js

View File

@ -573,6 +573,7 @@ Ensure the default browser behavior of the `hidden` attribute.
margin-top: 1.6em; margin-top: 1.6em;
margin-bottom: 1.6em; margin-bottom: 1.6em;
padding-left: 1em; padding-left: 1em;
border-right-color: var(--color-primary-200);
} }
.prose :where(blockquote p:first-of-type):not(:where([class~="not-prose"] *))::before { .prose :where(blockquote p:first-of-type):not(:where([class~="not-prose"] *))::before {
@ -970,6 +971,33 @@ body a, body button {
color: var(--color-primary-400); color: var(--color-primary-400);
} }
/* RTL support */
[dir="rtl"] .prose blockquote {
border-left-width: 0px;
border-right-width: 4px;
padding-right: 1rem;
}
[dir="rtl"] .prose ul > li, [dir="rtl"] .prose ol > li {
margin-right: 1.75rem;
padding-left: 0px;
padding-right: 0.5rem;
}
[dir="rtl"] .prose ol > li:before, [dir="rtl"] .prose ul > li:before {
left: auto;
right: 0.25rem;
}
[dir="rtl"] .prose thead td:first-child, [dir="rtl"] .prose thead th:first-child {
padding-right: 0px;
}
[dir="rtl"] .prose thead td:last-child, [dir="rtl"] .prose thead th:last-child {
padding-left: 0px;
}
/* -- Chroma Highlight -- */ /* -- Chroma Highlight -- */
/* Background */ /* Background */
@ -1830,22 +1858,18 @@ body a, body button {
margin-top: -0.5rem; margin-top: -0.5rem;
} }
.ml-2 {
margin-left: 0.5rem;
}
.mr-3 { .mr-3 {
margin-right: 0.75rem; margin-right: 0.75rem;
} }
.mt-\[0\.1rem\] {
margin-top: 0.1rem;
}
.ml-3 { .ml-3 {
margin-left: 0.75rem; margin-left: 0.75rem;
} }
.mt-\[0\.1rem\] {
margin-top: 0.1rem;
}
.\!mt-0 { .\!mt-0 {
margin-top: 0px !important; margin-top: 0px !important;
} }
@ -1854,14 +1878,6 @@ body a, body button {
margin-bottom: 0px !important; margin-bottom: 0px !important;
} }
.mr-4 {
margin-right: 1rem;
}
.ml-1 {
margin-left: 0.25rem;
}
.mb-1 { .mb-1 {
margin-bottom: 0.25rem; margin-bottom: 0.25rem;
} }
@ -2103,16 +2119,16 @@ body a, body button {
padding-right: 0.5rem; padding-right: 0.5rem;
} }
.px-1 {
padding-left: 0.25rem;
padding-right: 0.25rem;
}
.py-1 { .py-1 {
padding-top: 0.25rem; padding-top: 0.25rem;
padding-bottom: 0.25rem; padding-bottom: 0.25rem;
} }
.px-1 {
padding-left: 0.25rem;
padding-right: 0.25rem;
}
.py-\[1px\] { .py-\[1px\] {
padding-top: 1px; padding-top: 1px;
padding-bottom: 1px; padding-bottom: 1px;
@ -2163,10 +2179,6 @@ body a, body button {
padding-top: 1rem; padding-top: 1rem;
} }
.pr-3 {
padding-right: 0.75rem;
}
.text-center { .text-center {
text-align: center; text-align: center;
} }
@ -2363,6 +2375,62 @@ body a, body button {
text-underline-offset: 2px; text-underline-offset: 2px;
} }
[dir="ltr"] .ltr\:ml-2 {
margin-left: 0.5rem;
}
[dir="ltr"] .ltr\:mr-4 {
margin-right: 1rem;
}
[dir="ltr"] .ltr\:ml-1 {
margin-left: 0.25rem;
}
[dir="ltr"] .ltr\:inline {
display: inline;
}
[dir="ltr"] .ltr\:hidden {
display: none;
}
[dir="ltr"] .ltr\:pr-3 {
padding-right: 0.75rem;
}
[dir="ltr"] .ltr\:text-right {
text-align: right;
}
[dir="rtl"] .rtl\:mr-2 {
margin-right: 0.5rem;
}
[dir="rtl"] .rtl\:ml-4 {
margin-left: 1rem;
}
[dir="rtl"] .rtl\:mr-1 {
margin-right: 0.25rem;
}
[dir="rtl"] .rtl\:inline {
display: inline;
}
[dir="rtl"] .rtl\:hidden {
display: none;
}
[dir="rtl"] .rtl\:pl-3 {
padding-left: 0.75rem;
}
[dir="rtl"] .rtl\:text-left {
text-align: left;
}
.dark .dark\:prose-light { .dark .dark\:prose-light {
color: var(--color-neutral-300); color: var(--color-neutral-300);
} }
@ -2397,6 +2465,7 @@ body a, body button {
.dark .dark\:prose-light :where(blockquote):not(:where([class~="not-prose"] *)) { .dark .dark\:prose-light :where(blockquote):not(:where([class~="not-prose"] *)) {
color: var(--color-neutral-200); color: var(--color-neutral-200);
border-left-color: var(--color-primary-900); border-left-color: var(--color-primary-900);
border-right-color: var(--color-primary-900);
} }
.dark .dark\:prose-light :where(h1):not(:where([class~="not-prose"] *)) { .dark .dark\:prose-light :where(h1):not(:where([class~="not-prose"] *)) {
@ -2576,6 +2645,22 @@ body a, body button {
.sm\:last\:mr-0:last-child { .sm\:last\:mr-0:last-child {
margin-right: 0px; margin-right: 0px;
} }
[dir="ltr"] .ltr\:sm\:mr-7 {
margin-right: 1.75rem;
}
[dir="ltr"] .ltr\:sm\:last\:mr-0:last-child {
margin-right: 0px;
}
[dir="rtl"] .rtl\:sm\:ml-7 {
margin-left: 1.75rem;
}
[dir="rtl"] .rtl\:sm\:last\:ml-0:last-child {
margin-left: 0px;
}
} }
@media (min-width: 768px) { @media (min-width: 768px) {

View File

@ -40,6 +40,31 @@ body button {
@apply text-primary-700 dark:text-primary-400; @apply text-primary-700 dark:text-primary-400;
} }
/* RTL support */
[dir="rtl"] .prose blockquote {
@apply pr-4 border-l-0 border-r-4;
}
[dir="rtl"] .prose ul > li,
[dir="rtl"] .prose ol > li {
@apply pl-0 pr-2 mr-7;
}
[dir="rtl"] .prose ol > li:before,
[dir="rtl"] .prose ul > li:before {
@apply left-auto right-1;
}
[dir="rtl"] .prose thead td:first-child,
[dir="rtl"] .prose thead th:first-child {
@apply pr-0;
}
[dir="rtl"] .prose thead td:last-child,
[dir="rtl"] .prose thead th:last-child {
@apply pl-0;
}
/* -- Chroma Highlight -- */ /* -- Chroma Highlight -- */
/* Background */ /* Background */
.prose .chroma { .prose .chroma {

View File

@ -3,6 +3,7 @@ languageName = "English"
displayName = "EN" displayName = "EN"
htmlCode = "en" htmlCode = "en"
weight = 1 weight = 1
rtl = false
title = "Congo" title = "Congo"
# copyright = "Copy, _right?_ :thinking_face:" # copyright = "Copy, _right?_ :thinking_face:"

View File

@ -3,6 +3,7 @@ languageName = "English (Australia)"
displayName = ":flag-au:" displayName = ":flag-au:"
htmlCode = "en-AU" htmlCode = "en-AU"
weight = 1 weight = 1
rtl = false
title = "Congo" title = "Congo"
# copyright = "Copy, _right?_ :thinking_face:" # copyright = "Copy, _right?_ :thinking_face:"

View File

@ -3,6 +3,11 @@
lang="{{ with .Site.Language.Params.htmlCode | default (.Site.LanguageCode | default "en") }} lang="{{ with .Site.Language.Params.htmlCode | default (.Site.LanguageCode | default "en") }}
{{- . -}} {{- . -}}
{{ end }}" {{ end }}"
dir="{{ if .Site.Language.Params.rtl | default false -}}
rtl
{{- else -}}
ltr
{{- end }}"
{{ if .Site.Params.darkMode | default false }}class="dark"{{ end }} {{ if .Site.Params.darkMode | default false }}class="dark"{{ end }}
> >
{{- partial "head.html" . -}} {{- partial "head.html" . -}}

View File

@ -3,15 +3,15 @@
<section class="flex flex-wrap -mx-2 overflow-hidden"> <section class="flex flex-wrap -mx-2 overflow-hidden">
{{ range .Data.Terms }} {{ range .Data.Terms }}
<article class="w-full px-2 my-3 overflow-hidden sm:w-1/2 md:w-1/3 lg:w-1/4 xl:w-1/5"> <article class="w-full px-2 my-3 overflow-hidden sm:w-1/2 md:w-1/3 lg:w-1/4 xl:w-1/5">
<h2> <h2 class="flex items-center">
<a <a
class="text-xl font-medium hover:underline hover:decoration-primary-500 hover:underline-offset-2" class="text-xl font-medium hover:underline hover:decoration-primary-500 hover:underline-offset-2"
href="{{ .Page.RelPermalink }}" href="{{ .Page.RelPermalink }}"
>{{ .Page.Title }}</a >{{ .Page.Title }}</a
> >
{{ if $.Site.Params.taxonomy.showTermCount | default true }} {{ if $.Site.Params.taxonomy.showTermCount | default true }}
<span class="px-2 text-base text-primary-500">&middot;</span>
<span class="text-base text-neutral-400"> <span class="text-base text-neutral-400">
<span class="px-1 text-primary-500">&middot;</span>
{{ .Count }} {{ .Count }}
</span> </span>
{{ end }} {{ end }}

View File

@ -22,7 +22,7 @@
> >
{{ end }} {{ end }}
{{ if and .Draft .Site.Params.article.showDraftLabel }} {{ if and .Draft .Site.Params.article.showDraftLabel }}
<div class="ml-2"> <div class="ltr:ml-2 rtl:mr-2">
{{ partial "badge.html" (i18n "article.draft" | emojify) }} {{ partial "badge.html" (i18n "article.draft" | emojify) }}
</div> </div>
{{ end }} {{ end }}

View File

@ -6,7 +6,8 @@
<span> <span>
{{ if .NextInSection }} {{ if .NextInSection }}
<a class="flex" href="{{ .NextInSection.RelPermalink }}"> <a class="flex" href="{{ .NextInSection.RelPermalink }}">
<span class="mr-3 article-pagination-direction">&larr;</span> <span class="mr-3 ltr:inline rtl:hidden article-pagination-direction">&larr;</span>
<span class="ml-3 ltr:hidden rtl:inline article-pagination-direction">&rarr;</span>
<span class="flex flex-col"> <span class="flex flex-col">
<span class="article-pagination-title mt-[0.1rem] leading-6" <span class="article-pagination-title mt-[0.1rem] leading-6"
>{{ .NextInSection.Title | emojify }}</span >{{ .NextInSection.Title | emojify }}</span
@ -33,7 +34,8 @@
{{ end }} {{ end }}
</span> </span>
</span> </span>
<span class="ml-3 article-pagination-direction">&rarr;</span> <span class="ml-3 ltr:inline rtl:hidden article-pagination-direction">&rarr;</span>
<span class="mr-3 ltr:hidden rtl:inline article-pagination-direction">&larr;</span>
</a> </a>
{{ end }} {{ end }}
</span> </span>

View File

@ -5,7 +5,7 @@
{{ if $authorImage }} {{ if $authorImage }}
{{ $authorImage := $authorImage.Fill "192x192" }} {{ $authorImage := $authorImage.Fill "192x192" }}
<img <img
class="w-24 h-24 !mt-0 !mb-0 mr-4 rounded-full" class="w-24 h-24 !mt-0 !mb-0 ltr:mr-4 rtl:ml-4 rounded-full"
width="96" width="96"
height="96" height="96"
alt="Author" alt="Author"

View File

@ -1,6 +1,6 @@
<span class="flex"> <span class="flex">
<span <span
class="ml-1 px-1 py-[1px] text-xs font-normal border rounded-md text-primary-700 dark:text-primary-400 border-primary-400 dark:border-primary-600" class="ltr:ml-1 rtl:mr-1 px-1 py-[1px] text-xs font-normal border rounded-md text-primary-700 dark:text-primary-400 border-primary-400 dark:border-primary-600"
> >
{{ . }} {{ . }}
</span> </span>

View File

@ -31,7 +31,9 @@
<nav> <nav>
<ul class="flex flex-col list-none sm:flex-row"> <ul class="flex flex-col list-none sm:flex-row">
{{ range .Site.Menus.main }} {{ range .Site.Menus.main }}
<li class="mb-1 text-right sm:mb-0 sm:mr-7 sm:last:mr-0"> <li
class="mb-1 ltr:text-right rtl:text-left sm:mb-0 ltr:sm:mr-7 ltr:sm:last:mr-0 rtl:sm:ml-7 rtl:sm:last:ml-0"
>
<a <a
class="hover:underline hover:decoration-primary-500 hover:decoration-2 hover:underline-offset-2" class="hover:underline hover:decoration-primary-500 hover:decoration-2 hover:underline-offset-2"
href="{{ .URL }}" href="{{ .URL }}"

View File

@ -1,5 +1,5 @@
<div class="flex px-4 py-3 rounded-md bg-primary-100 dark:bg-primary-900"> <div class="flex px-4 py-3 rounded-md bg-primary-100 dark:bg-primary-900">
<span class="pr-3 text-primary-400"> <span class="ltr:pr-3 rtl:pl-3 text-primary-400">
{{ partial "icon.html" "exclamation-triangle" }} {{ partial "icon.html" "exclamation-triangle" }}
</span> </span>
<span class="not-prose dark:text-neutral-300"> <span class="not-prose dark:text-neutral-300">

View File

@ -82,6 +82,7 @@ module.exports = {
blockquote: { blockquote: {
color: theme("colors.neutral.800"), color: theme("colors.neutral.800"),
borderLeftColor: theme("colors.primary.200"), borderLeftColor: theme("colors.primary.200"),
borderRightColor: theme("colors.primary.200"),
}, },
h1: { h1: {
color: theme("colors.neutral.900"), color: theme("colors.neutral.900"),
@ -166,6 +167,7 @@ module.exports = {
blockquote: { blockquote: {
color: theme("colors.neutral.200"), color: theme("colors.neutral.200"),
borderLeftColor: theme("colors.primary.900"), borderLeftColor: theme("colors.primary.900"),
borderRightColor: theme("colors.primary.900"),
}, },
h1: { h1: {
color: theme("colors.neutral.DEFAULT"), color: theme("colors.neutral.DEFAULT"),