Skip to content

Commit

Permalink
feat(plugin-rtl): add rtl plugin (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope authored Feb 1, 2024
1 parent 7389d32 commit 4a50404
Show file tree
Hide file tree
Showing 17 changed files with 300 additions and 32 deletions.
1 change: 1 addition & 0 deletions docs/.vuepress/configs/navbar/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const navbarEn: NavbarConfig = [
'/plugins/active-header-links',
'/plugins/git',
'/plugins/palette',
'/plugins/rtl',
'/plugins/theme-data',
'/plugins/toc',
],
Expand Down
1 change: 1 addition & 0 deletions docs/.vuepress/configs/navbar/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const navbarZh: NavbarConfig = [
'/zh/plugins/active-header-links',
'/zh/plugins/git',
'/zh/plugins/palette',
'/zh/plugins/rtl',
'/zh/plugins/theme-data',
'/zh/plugins/toc',
],
Expand Down
1 change: 1 addition & 0 deletions docs/.vuepress/configs/sidebar/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const sidebarEn: SidebarConfig = {
'/plugins/active-header-links',
'/plugins/git',
'/plugins/palette',
'/plugins/rtl',
'/plugins/theme-data',
'/plugins/toc',
],
Expand Down
1 change: 1 addition & 0 deletions docs/.vuepress/configs/sidebar/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const sidebarZh: SidebarConfig = {
'/zh/plugins/active-header-links',
'/zh/plugins/git',
'/zh/plugins/palette',
'/zh/plugins/rtl',
'/zh/plugins/theme-data',
'/zh/plugins/toc',
],
Expand Down
53 changes: 53 additions & 0 deletions docs/plugins/rtl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# rtl

<NpmBadge package="@vuepress/plugin-rtl" />

This plugin will set direction to rtl on configured locales.

## Usage

```bash
npm i -D @vuepress/plugin-rtl@next
```

```ts
import { rtlPlugin } from '@vuepress/plugin-rtl'

export default {
plugins: [
rtlPlugin({
// options
locales: ['/ar/'],
}),
],
}
```

## Options

### locales

- Type: `string[]`
- Default: `['/']`
- Details:
Locale path to enable rtl.

### selector

- Type: `SelectorOptions`

```ts
interface SelectorOptions {
[element: string]: {
[attrs: string]: string
}
}
```

- Default: `{ 'html': { dir: 'rtl' } }`

- Details:

Selector to enable rtl.

The default settings mean that the `dir` attribute of the `html` element will be set to `rtl` in rtl locales.
20 changes: 10 additions & 10 deletions docs/zh/plugins/copy-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,32 @@ export default {

### selector

- 类型: `string | string[]`
- 默认值: `'.theme-default-content div[class*="language-"] pre'`
- 类型`string | string[]`
- 默认值`'.theme-default-content div[class*="language-"] pre'`
- 详情:

代码块选择器

### showInMobile

- 类型: `boolean`
- 默认值: `false`
- 类型`boolean`
- 默认值`false`
- 详情:

是否展示在移动端

### duration

- 类型: `number`
- 默认值: `2000`
- 类型`number`
- 默认值`2000`
- 详情:

提示消息显示时间,设置为 `0` 会禁用提示。

### delay

- 类型: `number`
- 默认值: `800`
- 类型`number`
- 默认值`800`
- 详情:

注册复制按钮的延时,单位 ms。
Expand All @@ -62,7 +62,7 @@ export default {

### locales

- 类型: `CopyCodeLocaleConfig`
- 类型`CopyCodeLocaleConfig`

```ts
interface CopyCodeLocaleData {
Expand All @@ -82,7 +82,7 @@ export default {
}
```

- 必填:
- 必填
- 详情:

复制按钮插件的国际化配置。
Expand Down
34 changes: 17 additions & 17 deletions docs/zh/plugins/feed/channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@

## channel.title

- 类型: `string`
- 默认值: `SiteConfig.title`
- 类型`string`
- 默认值`SiteConfig.title`

频道的标题

## channel.link

- 类型: `string`
- 默认值: 部署的网址 (通过 `options.hostname``context.base` 生成)
- 类型`string`
- 默认值部署的网址 (通过 `options.hostname``context.base` 生成)

频道地址

## channel.description

- 类型: `string`
- 默认值: `SiteConfig.description`
- 类型`string`
- 默认值`SiteConfig.description`

频道描述信息

## channel.language

- 类型: `string`
- 类型`string`
- 默认值:
- `siteConfig.locales['/'].locales`
- 如果上述未提供,回退到 `"en-US"`
Expand All @@ -34,7 +34,7 @@

## channel.copyright

- 类型: `string`
- 类型`string`
- 默认值:
- 尝试读取 channel 选项中的 `author.name` 生成 `Copyright by $author`
- 建议自行设置: ****
Expand All @@ -43,43 +43,43 @@

## channel.pubDate

- 类型: `string` (需是合法的 Date ISOString)
- 默认值: 每次插件构建时刻
- 类型`string` (需是合法的 Date ISOString)
- 默认值每次插件构建时刻
- 建议自行设置: ****

频道内容的发布时间

## channel.lastUpdated

- 类型: `string` (需是合法的 Date ISOString)
- 默认值: 每次插件构建时刻
- 类型`string` (需是合法的 Date ISOString)
- 默认值每次插件构建时刻

频道内容的上次更新时间

## channel.ttl

- 类型: `number`
- 类型`number`
- 建议自行设置: ****

内容有效时间,即获取后保持缓存而不进行新获取的时间

## channel.image

- 类型: `string`
- 类型`string`
- 建议自行设置: ****

这是一个会在频道中使用的图片,建议设置正方形图片、尺寸最好不小于 512×512。

## channel.icon

- 类型: `string`
- 类型`string`
- 建议自行设置: ****

一个代表频道的图标,建议设置正方形图片、尺寸最好不小于 128×128,背景色透明。

## channel.author

- 类型: `FeedAuthor`
- 类型`FeedAuthor`
- 建议自行设置: ****

频道的作者。
Expand Down Expand Up @@ -107,7 +107,7 @@ interface FeedAuthor {

## channel.hub

- 类型: `string`
- 类型`string`

Websub 的链接。Websub 需要服务器后端,与 VuePress 主旨不符,如无特殊需要忽略即可。

Expand Down
53 changes: 53 additions & 0 deletions docs/zh/plugins/rtl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# rtl

<NpmBadge package="@vuepress/plugin-rtl" />

此插件会在配置的语言上设置 rtl 方向。

## 使用方法

```bash
npm i -D @vuepress/plugin-rtl@next
```

```ts
import { rtlPlugin } from '@vuepress/plugin-rtl'

export default {
plugins: [
rtlPlugin({
// 配置项
locales: ['/ar/'],
}),
],
}
```

## 选项

### locales

- 类型:`string[]`
- 默认值:`['/']`
- 详情:
开启 RTL 布局的多语言路径。

### selector

- 类型:`SelectorOptions`

```ts
interface SelectorOptions {
[element: string]: {
[attrs: string]: string
}
}
```

- 默认值:`{ 'html': { dir: 'rtl' } }`

- 详情:

开启 RTL 的选择器。

默认设置意味着在 RTL 多语言中,`html` 元素的 `dir` 属性将被设置为 `rtl`
8 changes: 4 additions & 4 deletions docs/zh/plugins/seo/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
- 类型:`boolean`
- 默认值: `true`
- 默认值`true`
- 详情:
Expand Down Expand Up @@ -91,7 +91,7 @@
## ogp
- 类型:
- 类型
```ts
function ogp(
Expand All @@ -112,7 +112,7 @@

## jsonLd

- 类型:
- 类型

```ts
function jsonLd(
Expand All @@ -133,7 +133,7 @@

## customHead

- 类型:
- 类型

```ts
function customHead(
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/plugins/sitemap/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## hostname

- 类型:`string`
- 必填:
- 必填
- 详情:

当前网站部署到的域名,插件需要此选项才能工作。
Expand Down
Loading

0 comments on commit 4a50404

Please sign in to comment.