Skip to content
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

Support RTL mode switching from site.config #465

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

.settings a:last-of-type,
.social a:last-of-type {
margin-right: 0;
margin-right: 1;
}

.settings a:hover,
Expand Down
4 changes: 3 additions & 1 deletion lib/site-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ export interface SiteConfig {
newsletter?: string
youtube?: string
zhihu?: string
mastodon?: string;
mastodon?: string

defaultPageIcon?: string | null
defaultPageCover?: string | null
defaultPageCoverPosition?: number | null

RTL: boolean

isPreviewImageSupportEnabled?: boolean
isTweetEmbedSupportEnabled?: boolean
isRedisEnabled?: boolean
Expand Down
3 changes: 2 additions & 1 deletion pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react'
import Document, { Head, Html, Main, NextScript } from 'next/document'

import { IconContext } from '@react-icons/all-files'
import siteConfig from 'site.config'

export default class MyDocument extends Document {
render() {
Expand All @@ -20,7 +21,7 @@ export default class MyDocument extends Document {
<link rel='manifest' href='/manifest.json' />
</Head>

<body>
<body dir={siteConfig.RTL ? 'rtl' : 'ltr'}>
<script
dangerouslySetInnerHTML={{
__html: `
Expand Down
3 changes: 3 additions & 0 deletions site.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export default siteConfig({
defaultPageCover: null,
defaultPageCoverPosition: 0.5,

// if you want to switch the display direction to right-to-left (e.g. in case you have Arabic content)
RTL: false,

// whether or not to enable support for LQIP preview images (optional)
isPreviewImageSupportEnabled: true,

Expand Down
5 changes: 5 additions & 0 deletions styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ body {
color: var(--fg-color);
caret-color: var(--fg-color);
}

/* add a space between the icon and the site title after setting the theme direction to RTL */
.breadcrumb .title {
margin-right: 7px;
}