Skip to content

Commit

Permalink
Adding RTL support (probberechts#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrad77 authored and probberechts committed Apr 15, 2018
1 parent 9fffec8 commit b017371
Show file tree
Hide file tree
Showing 18 changed files with 87 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ Otherwise, you can follow the steps below (E.g., to add a Japanese (ja) translat

**Note: Cactus does not support multi-language sites.**

### RTL support
This theme support RTL languages for Persian and Arabic language.
If you would like to use RTL layout, change `direction` attribute in `_config.yml` to `rtl`.
Note that this also will change the font to [Vazir](https://github.com/rastikerdar/vazir-font), wich is a Persian font.

```
direction: rtl
```
### RSS
Expand Down
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# page within your website.
projects_url: http://github.com/probberechts

# Set the page direction to RTL or LTR. default is LTR. (if you set it 'rtl', the 'vazir' font will be loaded.)
direction: ltr
# Configure the navigation menu.
# A pair 'Key: url' will result in a link to 'url' with the name 'Key' in the
# navigation menu. Optionally, you can add translations for the 'Key' in
Expand Down
4 changes: 4 additions & 0 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<title><%= page.title ? page.title : config.title %></title>
<!-- styles -->
<%- css('css/style') %>
<!-- persian styles -->
<% if (theme.direction) { %>
<%- css('css/rtl') %>
<% } %>
<!-- rss -->
<% if (theme.rss === '' && config.feed && config.feed.path) { %>
<% theme.rss = config.feed.path %>
Expand Down
2 changes: 1 addition & 1 deletion layout/layout.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html<%= config.language ? " lang=" + config.language.substring(0, 2) : ""%>>
<%- partial('_partial/head') %>
<body class="max-width mx-auto px3">
<body class="max-width mx-auto px3 <%- theme.direction -%>">
<% if (is_post()) { %>
<%- partial('_partial/post/actions_desktop') %>
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion source/css/_partial/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
list-style: none

.project-item
margin-bottom: 5px
margin-bottom: 5px
71 changes: 71 additions & 0 deletions source/css/rtl.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@font-face
font-family: Vazir
src: url('../lib/vazir-font/Vazir.eot')
src: url('../lib/vazir-font/Vazir.eot?#iefix') format('embedded-opentype'),
url('../lib/vazir-font/Vazir.woff2') format('woff2'),
url('../lib/vazir-font/Vazir.woff') format('woff'),
url('../lib/vazir-font/Vazir.ttf') format('truetype')
font-weight: normal

@font-face
font-family: Vazir;
src: url('../lib/vazir-font/Vazir-Bold.eot');
src: url('../lib/vazir-font/Vazir-Bold.eot?#iefix') format('embedded-opentype'),
url('../lib/vazir-font/Vazir-Bold.woff2') format('woff2'),
url('../lib/vazir-font/Vazir-Bold.woff') format('woff'),
url('../lib/vazir-font/Vazir-Bold.ttf') format('truetype')
font-weight: bold

@font-face
font-family: Vazir;
src: url('../lib/vazir-font/Vazir-Light.eot')
src: url('../lib/vazir-font/Vazir-Light.eot?#iefix') format('embedded-opentype'),
url('../lib/vazir-font/Vazir-Light.woff2') format('woff2'),
url('../lib/vazir-font/Vazir-Light.woff') format('woff'),
url('../lib/vazir-font/Vazir-Light.ttf') format('truetype')
font-weight: 300

.rtl
font-family: vazir, sans-serif
direction: rtl

#nav
li
padding-left: 15px
border-left: 1px dotted $color-accent-1
border-right: 0px
margin-right: 0px !important
border-right: none !important

li:last-child
margin-right: 15px !important;
border-left: 0 !important;

#header
#logo
float: right

#footer
li
padding-left: 15px
border-left: 1px dotted $color-border
margin-right: 0px
border-right: 0px

li:last-child
margin-right: 15px !important;
border-left: 0 !important;

#logo
float: right

article
.content
h2:before
right: -1rem;

@media (min-width: 480px)
.post-list
.post-item
.meta
text-align: right
Binary file added source/lib/vazir-font/Vazir-Bold.eot
Binary file not shown.
Binary file added source/lib/vazir-font/Vazir-Bold.ttf
Binary file not shown.
Binary file added source/lib/vazir-font/Vazir-Bold.woff
Binary file not shown.
Binary file added source/lib/vazir-font/Vazir-Bold.woff2
Binary file not shown.
Binary file added source/lib/vazir-font/Vazir-Light.eot
Binary file not shown.
Binary file added source/lib/vazir-font/Vazir-Light.ttf
Binary file not shown.
Binary file added source/lib/vazir-font/Vazir-Light.woff
Binary file not shown.
Binary file added source/lib/vazir-font/Vazir-Light.woff2
Binary file not shown.
Binary file added source/lib/vazir-font/Vazir.eot
Binary file not shown.
Binary file added source/lib/vazir-font/Vazir.ttf
Binary file not shown.
Binary file added source/lib/vazir-font/Vazir.woff
Binary file not shown.
Binary file added source/lib/vazir-font/Vazir.woff2
Binary file not shown.

0 comments on commit b017371

Please sign in to comment.