Skip to content

Commit

Permalink
chore: add locales config
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 committed Oct 7, 2022
1 parent c59e98d commit d16a79e
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 34 deletions.
93 changes: 76 additions & 17 deletions docs/en/api/config-theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@ export default defineConfig({
});
```

## siteTitle

- Type: `string`
- Default: `"Island"`

The title of the site.Different from `title` in root config, this title will be used in the navbar. For example:

```js
import { defineConfig } from 'islandjs';

export default defineConfig({
themeConfig: {
siteTitle: 'my-site'
}
});
```

## nav

- Type: `Array`
Expand Down Expand Up @@ -254,3 +237,79 @@ export default defineConfig({
}
});
```

## prevPageText

- Type: `string`
- Default: `Previous Page`

The text of the previous page. for example:

```js
import { defineConfig } from 'islandjs';

export default defineConfig({
themeConfig: {
prevPageText: 'Previous Page'
}
});
```

## nextPageText

- Type: `string`
- Default: `Next Page`

Text for the next page. for example:

```js
import { defineConfig } from 'islandjs';

export default defineConfig({
themeConfig: {
nextPageText: 'Next Page'
}
});
```

## locales

- Type: `Object`
- Default: `undefined`

I18n config. This config is an object, the key is the routing prefix of the corresponding language (such as `/en`), the value is `LocaleConfig`, the type is as follows:

```ts
export interface LocaleConfig {
// language name
lang?: string;
// HTML title
title?: string;
// HTML description
description?: string;
// Display text in corresponding language
label: string;
// Navbar config, of the same type as `themeConfig.nav`
nav?: NavItem[];
// Sidebar config, of the same type as `themeConfig.sidebar`
sidebar?: Sidebar;
// Outline title
outlineTitle?: string;
lastUpdatedText?: string;
editLink?: EditLink;
prevPageText?: string;
nextPageText?: string;
}
```

As you see, there are many fields in `themeConfig` that can be also configured in `LocaleConfig`, including:

- `nav`
- `sidebar`
- `editLink`
- `lastUpdatedText`
- `outlineTitle`
- `prevPageText`
- `nextPageText`

But the `LocaleConfig` has higher priority.So it will override the corresponding field in `themeConfig`.
93 changes: 76 additions & 17 deletions docs/zh/api/config-theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@ export default defineConfig({
});
```

## siteTitle

- Type: `string`
- Default: `"Island"`

站点的标题。与根配置中的 `title` 不同,此标题将用于导航栏中。比如:

```js
import { defineConfig } from 'islandjs';

export default defineConfig({
themeConfig: {
siteTitle: '我的主页'
}
});
```

## nav

- Type: `Array`
Expand Down Expand Up @@ -246,3 +229,79 @@ export default defineConfig({
}
});
```

## prevPageText

- Type: `string`
- Default: `Previous Page`

上一页的文本。比如:

```js
import { defineConfig } from 'islandjs';

export default defineConfig({
themeConfig: {
prevPageText: 'Previous Page'
}
});
```

## nextPageText

- Type: `string`
- Default: `Next Page`

下一页的文本。比如:

```js
import { defineConfig } from 'islandjs';

export default defineConfig({
themeConfig: {
nextPageText: 'Next Page'
}
});
```

## locales

- Type: `Object`
- Default: `undefined`

国际化配置。此配置为一个对象,key 为对应语言的路由前缀(如`/en`),value 为`LocaleConfig`,类型如下:

```ts
export interface LocaleConfig {
// 语言名称
lang?: string;
// HTML 标题,优先于 `themeConfig.title`
title?: string;
// HTML 描述,优先于 `themeConfig.description`
description?: string;
// 对应语言的显示文本
label: string;
// 导航栏配置
nav?: NavItem[];
// 侧边栏配置
sidebar?: Sidebar;
// 右侧大纲标题
outlineTitle?: string;
lastUpdatedText?: string;
editLink?: EditLink;
prevPageText?: string;
nextPageText?: string;
}
```

因此你能看到,`LocaleConfig` 中包含许多与 `ThemeConfig` 中相同的配置项,包括:

- `nav`
- `sidebar`
- `editLink`
- `lastUpdatedText`
- `outlineTitle`
- `prevPageText`
- `nextPageText`

但是 `LocaleConfig` 的优先级更高。所以它会覆盖 `themeConfig` 中的相应字段。

1 comment on commit d16a79e

@vercel
Copy link

@vercel vercel bot commented on d16a79e Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.