docsify
docsify copied to clipboard
feat: Add Right-to-Left (RTL) layout support
Summary
This commit introduces a new feature enabling Right-to-Left (RTL) layout for docsify sites.
Related issue, if any:
Close #2511
What kind of change does this PR introduce?
- Configuration: Added a new boolean option
rtl(default:false) towindow.$docsifyconfiguration insrc/core/config.js. Setting this totrueenables RTL mode. - Styling:
- Created
src/themes/shared/_rtl.csswith specific styles for RTL layout, including adjustments for text direction, sidebar positioning, and content margins. - Imported
_rtl.cssintosrc/themes/shared/__index.css.
- Created
- Behavior: Modified
src/core/Docsify.jsto add artlclass to the<body>element whenconfig.rtlis true. This class activates the RTL-specific CSS rules. - Testing: Added a new end-to-end test suite in
test/e2e/rtl.test.jsto verify:- The
rtlclass is applied to the body. - The sidebar is positioned on the right.
- Content margins are adjusted for the right-hand sidebar.
- The
- Documentation: Updated
docs/configuration.mdto document the newrtloption, its type, default value, and usage.
For any code change,
- [x] Related documentation has been updated, if needed
- [x] Related tests have been added or updated, if needed
Does this PR introduce a breaking change?
No
Tested in the following browsers:
- [x] Chrome
- [ ] Firefox
- [ ] Safari
- [x] Edge
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| docsify-preview | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 27, 2025 4:49am |
Thanks for your contribution.
I added some screenshots. There are some issues, such as search shortcut key prompts, etc.
Check screenshots