Skip to content

Add RTL Support #2367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
{% endunless %}

{% if dir and dir contains 'rtl' %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.rtl.min.css" integrity="sha384-MdqCcafa5BLgxBDJ3d/4D292geNL64JyRtSGjEszRUQX9rhL1QkcnId+OT7Yw+D+" crossorigin="anonymous">
{% endif %}

<!-- Theme style -->
<link rel="stylesheet" href="{{ '/assets/css/:THEME.css' | replace: ':THEME', site.theme | relative_url }}">

Expand Down
12 changes: 10 additions & 2 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@
{% capture prefer_mode %}data-mode="{{ site.theme_mode }}"{% endcapture %}
{% endif %}

<!-- `site.alt_lang` can specify a language different from the UI -->
<html lang="{{ page.lang | default: site.alt_lang | default: site.lang }}" {{ prefer_mode }}>
{% assign _lang_code = lang | split: '-' | first %}

{%- capture dir -%}
{%- if 'ar,fa,he,iw,ps,ug,ur,yi,ku' contains _lang_code -%}
dir="rtl"
{%- endif -%}
{%- endcapture -%}

<!-- `lang` attribute is set in _includes/lang.html -->
<html lang="{{ lang }}" {{ dir }} {{ prefer_mode }}>
{% include head.html %}

<body>
Expand Down
1 change: 1 addition & 0 deletions _sass/base/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
@forward 'base';
@forward 'typography';
@forward 'syntax';
@forward 'rtl';
Loading