Skip to content

Commit

Permalink
feat(rtl): html tag direction
Browse files Browse the repository at this point in the history
  • Loading branch information
martyanovandrey authored and 3y3 committed Mar 5, 2024
1 parent 6a7b357 commit f4ee1b0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ export enum Lang {
EN = 'en',
}

export const RTL_LANGS = [
'ar',
'arc',
'ckb',
'dv',
'fa',
'ha',
'he',
'khw',
'ks',
'ps',
'sd',
'ur',
'uz_AF',
'yi',
];

export enum Platforms {
WINDOWS = 'win32',
MAC = 'darwin',
Expand Down
6 changes: 4 additions & 2 deletions src/utils/markup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {join} from 'path';
import {platform} from 'process';

import {CUSTOM_STYLE, Platforms} from '../constants';
import {CUSTOM_STYLE, Platforms, RTL_LANGS} from '../constants';
import {LeadingPage, Resources, SinglePageResult, TextItems, VarsMetadata} from '../models';
import {ArgvService, PluginService} from '../services';
import {preprocessPageHtmlForSinglePage} from './singlePage';
Expand Down Expand Up @@ -42,10 +42,11 @@ export function generateStaticMarkup(
const {staticContent} = ArgvService.getConfig();

const html = staticContent ? render(props) : '';
const isRTL = RTL_LANGS.includes(props.lang);

return `
<!DOCTYPE html>
<html lang="${props.lang}">
<html lang="${props.lang}" dir="${isRTL ? 'rtl' : 'ltr'}">
<head>
<meta charset="utf-8">
${getMetadata(metadata, restYamlConfigMeta)}
Expand All @@ -57,6 +58,7 @@ export function generateStaticMarkup(
}
</style>
${manifest.css
.filter((file) => isRTL === file.includes('.rtl.css'))
.map(dst(pathToBundle))
.map((src: string) => `<link type="text/css" rel="stylesheet" href="${src}" />`)
.join('\n')}
Expand Down

0 comments on commit f4ee1b0

Please sign in to comment.