|
| 1 | +# RTL Support for Jekyll Theme Chirpy |
| 2 | + |
| 3 | +This document describes how the Right-to-Left (RTL) support works in the Chirpy theme. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Overview](#overview) |
| 8 | +- [Configuration](#configuration) |
| 9 | +- [How It Works](#how-it-works) |
| 10 | +- [Creating RTL Content](#creating-rtl-content) |
| 11 | +- [Language-Specific Fonts](#language-specific-fonts) |
| 12 | +- [Customization](#customization) |
| 13 | +- [Known Limitations](#known-limitations) |
| 14 | + |
| 15 | +## Overview |
| 16 | + |
| 17 | +The Chirpy theme provides support for Right-to-Left (RTL) languages such as Arabic, Hebrew, Persian, Urdu, and more. This support is implemented with minimal changes to the theme's core functionality and ensures a seamless experience for users reading content in RTL languages. |
| 18 | + |
| 19 | +## Configuration |
| 20 | + |
| 21 | +RTL support can be configured in your `_config.yml` file: |
| 22 | + |
| 23 | +```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.) |
| 27 | +rtl_support: false |
| 28 | + |
| 29 | +# RTL Languages array - add more languages if needed |
| 30 | +rtl_languages: |
| 31 | + - ar |
| 32 | + - fa-IR |
| 33 | + - he |
| 34 | + - ku-IQ |
| 35 | + - ur-PK |
| 36 | + - ps-AF |
| 37 | + - dv-MV |
| 38 | +``` |
| 39 | +
|
| 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. |
| 42 | + |
| 43 | +## How It Works |
| 44 | + |
| 45 | +The RTL support works by: |
| 46 | + |
| 47 | +1. Detecting the page language using the `lang` attribute in the front matter or the site's default language. |
| 48 | +2. Checking if the language is in the RTL languages list (or if `rtl_support` is set to `true`). |
| 49 | +3. Setting the `dir="rtl"` attribute on the HTML tag when appropriate. |
| 50 | +4. Applying RTL-specific styles that override the default LTR styles. |
| 51 | +5. Loading language-specific fonts for the detected RTL language. |
| 52 | + |
| 53 | +## Creating RTL Content |
| 54 | + |
| 55 | +To create content in an RTL language: |
| 56 | + |
| 57 | +1. Add the appropriate `lang` attribute in the front matter of your post or page: |
| 58 | + |
| 59 | +```yaml |
| 60 | +--- |
| 61 | +title: عنوان المقال |
| 62 | +author: اسم الكاتب |
| 63 | +date: 2023-01-01 |
| 64 | +lang: ar |
| 65 | +# other front matter... |
| 66 | +--- |
| 67 | +
|
| 68 | +محتوى المقال هنا... |
| 69 | +``` |
| 70 | + |
| 71 | +2. The theme will automatically detect the language and apply RTL styling and appropriate fonts. |
| 72 | + |
| 73 | +3. When using RTL languages, the whole page will be displayed in RTL mode, including navigation, sidebar, and other UI elements. |
| 74 | + |
| 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. |
| 76 | + |
| 77 | +## Language-Specific Fonts |
| 78 | + |
| 79 | +The theme includes built-in support for several RTL language fonts: |
| 80 | + |
| 81 | +- **Arabic**: Noto Sans Arabic |
| 82 | +- **Persian (Farsi)**: Vazirmatn |
| 83 | +- **Hebrew**: Noto Sans Hebrew |
| 84 | +- **Urdu**: Noto Nastaliq Urdu |
| 85 | + |
| 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. |
| 87 | + |
| 88 | +## Customization |
| 89 | + |
| 90 | +If you need to customize the RTL styles: |
| 91 | + |
| 92 | +1. The main RTL styles are in `_sass/rtl.scss`. |
| 93 | +2. Language-specific font definitions are in `_sass/rtl-fonts.scss`. |
| 94 | +3. You can add additional styles to these files or create your own custom styles in your theme. |
| 95 | + |
| 96 | +To change or add RTL fonts: |
| 97 | + |
| 98 | +1. Modify the `rtl-fonts.scss` file to include your preferred fonts. |
| 99 | +2. Update the font assignments for specific language codes. |
| 100 | + |
| 101 | +## Known Limitations |
| 102 | + |
| 103 | +- Code blocks are always displayed left-to-right (LTR) for better readability of code. |
| 104 | +- Some third-party components or embedded content might not respect RTL layout. |
| 105 | +- RTL mode is applied on a per-page basis based on the language attribute. If you want consistent RTL layout across your entire site, set `rtl_support: true` in your configuration. |
| 106 | +- When switching between RTL and LTR pages, there might be a brief moment before fonts are fully loaded. |
0 commit comments