Skip to content

Commit 001b093

Browse files
committed
fix: improve formatting of RTL content creation instructions in documentation
fix: swap float directions for images in Persian RTL content fix: remove duplicated font source and unicode-range for RTL fonts fix: update font weights for RTL language stylesheets fix: add spaces to read time unit and prompt for better formatting fix: reorder RTL font loader inclusion for rendering after googlefonts fix: update RTL language configuration to use 'fa' instead of 'fa-IR' for better compatibility fix: add transform to sidebar for better responsiveness in RTL layout fix: add RTL Support feature to README fix: update RTL support comments for clarity fix: enhance RTL support documentation for clarity and usability fix: correct meta format in fa.yml for clarity Signed-off-by: Zakaria Fatahi <[email protected]> fix: improve sidebar transform handling for RTL layout in mobile
1 parent 0032ae3 commit 001b093

File tree

9 files changed

+102
-80
lines changed

9 files changed

+102
-80
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
- PWA
3939
- Web Analytics
4040
- SEO & Performance Optimization
41+
- RTL Support
4142

4243
## Documentation
4344

_config.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33
# Import the theme
44
theme: jekyll-theme-chirpy
55

6-
# RTL Support Configuration
7-
# Set this to true to enable RTL support for all languages
8-
# If false, RTL will only be applied to RTL languages (ar, he, fa, etc.)
6+
# Force RTL mode for the entire website
7+
# When set to true, all pages will be rendered right-to-left, regardless of language
8+
# Useful if your entire site is in an RTL language
9+
# If enabled, also set one of the RTL languages in rtl_languages list as your site.lang value
910
rtl_support: false
1011

11-
# RTL Languages array - add more languages if needed
12+
# RTL Languages array
13+
# If you want to have your entire website in an RTL language, and you set rtl_support: true,
14+
# then set one of these languages for lang: in the _config.yml and your entire website locale will change too.
15+
# But if rtl_support is false and you just want specific pages in RTL with RTL locale,
16+
# add 'lang: fa' (or another code from this list) to the front matter of those specific pages.
17+
# The page will then be displayed in RTL mode with the appropriate font and locale
1218
rtl_languages:
1319
- ar
14-
- fa-IR
20+
- fa
1521
- ku-IQ
1622
- ur-PK
1723
- ps-AF

_data/locales/fa-IR.yml renamed to _data/locales/fa.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ copyright:
4040
به‌جز مواردی که خلاف آن ذکر شده باشد، محتوای پست‌های این وبلاگ
4141
تحت مجوز Creative Commons Attribution 4.0 International (CC BY 4.0) توسط نویسنده منتشر شده‌اند.
4242
43-
meta: با استفاده از :PLATFORM قالب :THEME
43+
meta: با استفاده از قالب :THEME برای :PLATFORM
4444

4545
not_found:
4646
statement: متأسفیم، لینک زیر معتبر نیست یا به صفحه‌ای که وجود ندارد اشاره می‌کند.
@@ -58,8 +58,8 @@ post:
5858
words: کلمه
5959
pageview_measure: بازدید
6060
read_time:
61-
unit: دقیقه
62-
prompt: زمان مطالعه
61+
unit: "دقیقه "
62+
prompt: " زمان مطالعه"
6363
relate_posts: بیشتر بخوانید
6464
share: اشتراک‌گذاری
6565
button:

_includes/head.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@
5757
{{ site.title }}
5858
</title>
5959

60-
<!-- This ensures the RTL fonts are loaded early in the page rendering process -->
61-
{% include rtl-font-loader.html %}
62-
6360
{% include_cached favicons.html %}
6461

6562
<!-- Resource Hints -->
@@ -71,6 +68,9 @@
7168
{% endfor %}
7269
{% endunless %}
7370

71+
<!-- This ensures the RTL fonts are loaded early in the page rendering process -->
72+
{% include rtl-font-loader.html %}
73+
7474
<!-- Bootstrap -->
7575
{% unless jekyll.environment == 'production' %}
7676
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">

_includes/rtl-font-loader.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
{% include lang.html %}
66

77
{% if dir == 'rtl' %}
8-
{% if lang == 'fa-IR' %}
8+
{% if lang == 'fa' %}
99
<link rel="preconnect" href="https://fonts.googleapis.com">
1010
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
11-
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;700&display=swap" rel="stylesheet">
11+
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100..900&display=swap" rel="stylesheet">
1212
{% elsif lang == 'ur-PK' %}
1313
<link rel="preconnect" href="https://fonts.googleapis.com">
1414
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
15-
<link href="https://fonts.googleapis.com/css2?family=Noto+Nastaliq+Urdu&display=swap" rel="stylesheet">
15+
<link href="https://fonts.googleapis.com/css2?family=Noto+Nastaliq+Urdu:[email protected]&display=swap" rel="stylesheet">
1616
{% else %} <!-- for Arabic and other rtl languages -->
1717
<link rel="preconnect" href="https://fonts.googleapis.com">
1818
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
19-
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;700&display=swap" rel="stylesheet">
19+
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@100..900&display=swap" rel="stylesheet">
2020
{% endif %}
2121
{% endif %}

_posts/2025-04-20-rtl-test-persian.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ image:
1111
path: /commons/devices-mockup.png
1212
lqip: data:image/webp;base64,UklGRpoAAABXRUJQVlA4WAoAAAAQAAAADwAABwAAQUxQSDIAAAARL0AmbZurmr57yyIiqE8oiG0bejIYEQTgqiDA9vqnsUSI6H+oAERp2HZ65qP/VIAWAFZQOCBCAAAA8AEAnQEqEAAIAAVAfCWkAALp8sF8rgRgAP7o9FDvMCkMde9PK7euH5M1m6VWoDXf2FkP3BqV0ZYbO6NA/VFIAAAA
1313
alt: نمایش واکنش‌گرای قالب Chirpy روی دستگاه‌های مختلف.
14-
lang: fa-IR
14+
lang: fa
1515
---
1616

1717
## سرتیترها
@@ -173,17 +173,17 @@ _عرض کامل صفحه و تراز وسط_
173173

174174
![نمای دسکتاپ](/posts/20190808/mockup.png){: width="972" height="589" .w-75 .normal}
175175

176-
### شناور به سمت چپ
176+
### شناور به سمت راست
177177

178-
![نمای دسکتاپ](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .left}
178+
![نمای دسکتاپ](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .right}
179179

180-
لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ، و با استفاده از طراحان گرافیک است، چاپگرها و متون بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است، و برای شرایط فعلی تکنولوژی مورد نیاز، و کاربردهای متنوع با هدف بهبود ابزارهای کاربردی می باشد.
180+
لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ، و با استفاده از طراحان گرافیک است، چاپگرها و متون بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است، و برای شرایط فعلی تکنولوژی مورد نیاز، و کاربردهای متنوع با هدف بهبود ابزارهای کاربردی می باشد. لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ، و با استفاده از طراحان گرافیک است، چاپگرها و متون بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است، و برای شرایط فعلی تکنولوژی مورد نیاز، و کاربردهای متنوع با هدف بهبود ابزارهای کاربردی می باشد.
181181

182-
### شناور به سمت راست
182+
### شناور به سمت چپ
183183

184-
![نمای دسکتاپ](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .right}
184+
![نمای دسکتاپ](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .left}
185185

186-
لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ، و با استفاده از طراحان گرافیک است، چاپگرها و متون بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است، و برای شرایط فعلی تکنولوژی مورد نیاز، و کاربردهای متنوع با هدف بهبود ابزارهای کاربردی می باشد.
186+
لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ، و با استفاده از طراحان گرافیک است، چاپگرها و متون بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است، و برای شرایط فعلی تکنولوژی مورد نیاز، و کاربردهای متنوع با هدف بهبود ابزارهای کاربردی می باشد. لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ، و با استفاده از طراحان گرافیک است، چاپگرها و متون بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است، و برای شرایط فعلی تکنولوژی مورد نیاز، و کاربردهای متنوع با هدف بهبود ابزارهای کاربردی می باشد.
187187

188188
### حالت روشن/تاریک و سایه
189189

_sass/rtl-fonts.scss

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,13 @@
88
font-style: normal;
99
font-weight: 400;
1010
font-display: swap;
11-
src: url('https://fonts.gstatic.com/s/notosansarabic/v18/nwpCtLGrOAZMl5nJ_wfgRg3DrWFZWsnVBJ_sS6tlqHHFlj4wv4o.woff2')
12-
format('woff2');
13-
unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41,
14-
U+FB50-FDFF, U+FE80-FEFC;
1511
}
1612

1713
@font-face {
1814
font-family: 'Noto Sans Arabic';
1915
font-style: normal;
2016
font-weight: 700;
2117
font-display: swap;
22-
src: url('https://fonts.gstatic.com/s/notosansarabic/v18/nwpCtLGrOAZMl5nJ_wfgRg3DrWFZWsnVBJ_sS6tlqHHFlj4wv4o.woff2')
23-
format('woff2');
24-
unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41,
25-
U+FB50-FDFF, U+FE80-FEFC;
2618
}
2719

2820
/* Persian (Farsi) Font */
@@ -31,21 +23,13 @@
3123
font-style: normal;
3224
font-weight: 400;
3325
font-display: swap;
34-
src: url('https://fonts.gstatic.com/s/vazirmatn/v13/Dxx78j6PP2D_kU2muijlEcI_MZP9UkS9x6EgRoIqYbU.woff2')
35-
format('woff2');
36-
unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41,
37-
U+FB50-FDFF, U+FE80-FEFC;
3826
}
3927

4028
@font-face {
4129
font-family: 'Vazirmatn';
4230
font-style: normal;
4331
font-weight: 700;
4432
font-display: swap;
45-
src: url('https://fonts.gstatic.com/s/vazirmatn/v13/Dxx78j6PP2D_kU2muijlEcI_MZP9UkS9x6EgRoIqYbU.woff2')
46-
format('woff2');
47-
unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41,
48-
U+FB50-FDFF, U+FE80-FEFC;
4933
}
5034

5135
/* Urdu Font */
@@ -54,11 +38,6 @@
5438
font-style: normal;
5539
font-weight: 400;
5640
font-display: swap;
57-
src: url('https://fonts.gstatic.com/s/notonastaliqurdu/v14/LhW4MUPbN-oZdNFcBy1-DJYsEoTq5pudQ9L940.woff2')
58-
format('woff2');
59-
unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41,
60-
U+FB50-FDFF, U+FE80-FEFC, U+0660-0669, U+0951-0952, U+1EE00-1EEF9,
61-
U+0900-097F;
6241
}
6342

6443
/* RTL font-family mapping based on lang attribute */
@@ -81,7 +60,7 @@ html[lang^='ar-'] {
8160
}
8261
}
8362

84-
html[lang='fa-IR'] {
63+
html[lang='fa'] {
8564
&,
8665
body {
8766
font-family: 'Vazirmatn', v.$font-family-base;
@@ -118,7 +97,7 @@ html[lang='ur-PK'] {
11897
}
11998

12099
/* Default RTL font for other RTL languages */
121-
html[dir='rtl']:not([lang='ar']):not([lang^='ar-']):not([lang='fa-IR']):not(
100+
html[dir='rtl']:not([lang='ar']):not([lang^='ar-']):not([lang='fa']):not(
122101
[lang='ur-PK']
123102
) {
124103
&,

_sass/rtl.scss

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
@use 'rtl-fonts';
1010

1111
html[dir='rtl'] {
12+
$sidebar-display: 'sidebar-display'; /* the attribute for sidebar display */
13+
1214
/* Basic text direction */
1315
direction: rtl;
1416
text-align: right;
@@ -17,9 +19,15 @@ html[dir='rtl'] {
1719
#sidebar {
1820
left: auto;
1921
right: 0;
22+
2023
border-right: none;
2124
border-left: 1px solid var(--sidebar-border-color);
2225

26+
@include bp.lt(bp.get(lg)) {
27+
transform: translateX(#{v.$sidebar-width});
28+
-webkit-transform: translateX(#{v.$sidebar-width});
29+
}
30+
2331
.profile-wrapper {
2432
padding-left: 1.25rem;
2533
padding-right: 2.5rem;
@@ -30,17 +38,7 @@ html[dir='rtl'] {
3038
}
3139
}
3240

33-
.site-title {
34-
text-align: right;
35-
}
36-
3741
ul li.nav-item {
38-
@include mx.pl-pr(1.5rem);
39-
40-
@include bp.xxxl {
41-
@include mx.pl-pr(2.75rem);
42-
}
43-
4442
a.nav-link i {
4543
margin-right: 0;
4644
margin-left: 1.5rem;
@@ -68,6 +66,21 @@ html[dir='rtl'] {
6866
}
6967
}
7068

69+
[#{$sidebar-display}] #sidebar {
70+
@include bp.lt(bp.get(lg)) {
71+
transform: translateX(0);
72+
-webkit-transform: translateX(0);
73+
}
74+
}
75+
76+
[#{$sidebar-display}] {
77+
#main-wrapper {
78+
@include bp.lt(bp.get(lg)) {
79+
transform: translateX(-#{v.$sidebar-width});
80+
}
81+
}
82+
}
83+
7184
/* Main wrapper */
7285
#main-wrapper {
7386
@include bp.lg {

docs/RTL-SUPPORT.md

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,32 @@ The Chirpy theme provides support for Right-to-Left (RTL) languages such as Arab
2121
RTL support can be configured in your `_config.yml` file:
2222

2323
```yaml
24-
# RTL Support Configuration
25-
# Set this to true to enable RTL support for all languages
26-
# If false, RTL will only be applied to RTL languages (ar, he, fa, etc.)
24+
# Force RTL mode for the entire website
25+
# When set to true, all pages will be rendered right-to-left, regardless of language
26+
# Useful if your entire site is in an RTL language
27+
# If enabled, also set one of the RTL languages in rtl_languages list as your site.lang value
2728
rtl_support: false
2829

29-
# RTL Languages array - add more languages if needed
30+
# RTL Languages array
31+
# If you want to have your entire website in an RTL language, and you set rtl_support: true,
32+
# then set one of these languages for lang: in the _config.yml and your entire website locale will change too.
33+
# But if rtl_support is false and you just want specific pages in RTL with RTL locale,
34+
# add 'lang: fa' (or another code from this list) to the front matter of those specific pages.
35+
# The page will then be displayed in RTL mode with the appropriate font and locale
3036
rtl_languages:
3137
- ar
32-
- fa-IR
33-
- he
38+
- fa
3439
- ku-IQ
3540
- ur-PK
3641
- ps-AF
3742
- dv-MV
3843
```
3944
40-
- `rtl_support`: If set to `true`, all pages will be rendered in RTL mode regardless of language. If `false` (default), only pages with languages listed in `rtl_languages` will be in RTL mode.
41-
- `rtl_languages`: An array of language codes that should be rendered in RTL mode. Add your RTL language code to this list if needed.
45+
- `rtl_support`: When set to `true`, forces RTL mode for the entire website, regardless of language. If enabled, you should also set one of the RTL languages as your main site language (e.g., `lang: fa` in `_config.yml`) to apply the appropriate locale.
46+
47+
- `rtl_languages`: A list of language codes that trigger RTL mode. These can be used in two ways:
48+
1. If `rtl_support: true`, set one of these as your site's main language in `_config.yml`
49+
2. If `rtl_support: false`, add `lang: fa` (or another code from this list) to the front matter of specific pages you want displayed in RTL mode
4250

4351
## How It Works
4452

@@ -52,27 +60,42 @@ The RTL support works by:
5260

5361
## Creating RTL Content
5462

55-
To create content in an RTL language:
63+
You have two options for creating RTL content:
5664

57-
1. Add the appropriate `lang` attribute in the front matter of your post or page:
65+
### 1. Individual RTL Pages
5866

59-
```yaml
60-
---
61-
title: عنوان المقال
62-
author: اسم الكاتب
63-
date: 2023-01-01
64-
lang: ar
65-
# other front matter...
66-
---
67-
68-
محتوى المقال هنا...
69-
```
67+
To make a specific page or post display in RTL mode:
68+
69+
- Add the appropriate `lang` attribute in the front matter, using one of the languages defined in `rtl_languages`:
70+
71+
```yaml
72+
---
73+
title: عنوان المقال
74+
author: اسم الكاتب
75+
date: 2023-01-01
76+
lang: ar
77+
# other front matter...
78+
---
79+
80+
محتوى المقال هنا...
81+
```
82+
83+
- The theme will automatically:
84+
- Display only this specific page in RTL mode
85+
- Use the appropriate font for the language
86+
- Apply the corresponding locale file if available (e.g., `_data/locales/ar.yml`)
87+
- The rest of your site will remain in LTR mode
88+
89+
This approach is ideal for multilingual sites where only some content is in RTL languages.
90+
91+
### 2. Entire Site in RTL
7092

71-
2. The theme will automatically detect the language and apply RTL styling and appropriate fonts.
93+
If your entire site is in an RTL language:
7294

73-
3. When using RTL languages, the whole page will be displayed in RTL mode, including navigation, sidebar, and other UI elements.
95+
1. Set `rtl_support: true` in your `_config.yml`
96+
2. All pages will be displayed in RTL mode regardless of their language setting
7497

75-
4. If you've provided a localization file for the language (e.g., `_data/locales/ar.yml`), the theme will use it for UI text.
98+
This approach is simpler if you don't need to mix RTL and LTR content.
7699

77100
## Language-Specific Fonts
78101

@@ -83,7 +106,7 @@ The theme includes built-in support for several RTL language fonts:
83106
- **Hebrew**: Noto Sans Hebrew
84107
- **Urdu**: Noto Nastaliq Urdu
85108

86-
These fonts are automatically applied based on the page's language attribute. For example, if your page has `lang: fa-IR`, the Vazirmatn font will be used.
109+
These fonts are automatically applied based on the page's language attribute. For example, if your page has `lang: fa`, the Vazirmatn font will be used.
87110

88111
## Customization
89112

0 commit comments

Comments
 (0)