Skip to content

Commit

Permalink
docs: rename api document to options, upgrade vitepress-i18n package,…
Browse files Browse the repository at this point in the history
… minor fixes
  • Loading branch information
jooy2 committed Oct 24, 2024
1 parent 8606611 commit 1f0e5d2
Show file tree
Hide file tree
Showing 17 changed files with 1,027 additions and 415 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default defineConfig({
sidebar: generateSidebar({
/*
* For detailed instructions, see the links below:
* https://vitepress-sidebar.cdget.com/guide/api
* https://vitepress-sidebar.cdget.com/guide/options
*/
// documentRootPath: '/',
// scanStartPath: null,
Expand Down Expand Up @@ -83,7 +83,7 @@ You can also request a pull to fix bugs and add frequently used features. To con

1. Clone the project.
2. Create changes (features, bugfixes) in a new branch.
3. Write a test (`test/specs/apis.spec.ts`) if a new option has been added.
3. Write a test (`test/specs/options.spec.ts`) if a new option has been added.
4. Create a documentation (`docs/`) if a new option is added.
5. Request a pull request. Include any changes or considerations in the description for a quick code review.

Expand Down
137 changes: 68 additions & 69 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { generateSidebar, VitePressSidebarOptions } from '../../dist';
import { repository, homepage } from '../../package.json';
import { defineConfig, UserConfig } from 'vitepress';
import { generateI18nLocale, generateI18nSearch } from 'vitepress-i18n';
import { withI18n } from 'vitepress-i18n';
import { VitePressI18nOptions } from 'vitepress-i18n/dist/types';

const defaultLocale: string = 'en';
const editLinkPattern = `${repository.url}/edit/master/docs/:path`;
Expand All @@ -25,6 +26,70 @@ const defineSupportLocales = [
{ label: 'zhHans', translateLocale: 'zhHans' }
];

const vitePressI18nConfig: VitePressI18nOptions = {
debugPrint: true,
defineLocales: defineSupportLocales,
rootLocale: defaultLocale,
editLinkPattern: editLinkPattern,
searchProvider: 'local',
description: {
en: 'VitePress Sidebar is a VitePress plugin that automatically generates sidebar menus with one setup and no hassle. Save time by easily creating taxonomies for tons of articles.',
ko: 'VitePress Sidebar는 번거로운 작업 없이 한번의 설정만으로 사이드바 메뉴를 자동으로 생성하는 VitePress 플러그인입니다. 수많은 문서에 대한 분류를 손쉽게 만들어 시간을 절약하세요.',
zhHans:
'VitePress Sidebar是一款VitePress插件,只需一次设置即可自动生成侧边栏菜单,无需任何麻烦。轻松为大量文章创建分类,节省时间。'
},
themeConfig: {
en: {
nav: [
{
text: 'Installation',
link: '/guide/getting-started'
},
{
text: 'Options',
link: '/guide/options'
},
{
text: 'Changelog',
link: 'changelog'
}
]
},
ko: {
nav: [
{
text: '설치',
link: '/ko/guide/getting-started'
},
{
text: '옵션',
link: '/ko/guide/options'
},
{
text: '변경사항',
link: '/ko/changelog'
}
]
},
zhHans: {
nav: [
{
text: '安装',
link: '/zhHans/guide/getting-started'
},
{
text: '选项',
link: '/zhHans/guide/options'
},
{
text: '变化',
link: '/zhHans/changelog'
}
]
}
}
};

// Ref: https://vitepress.dev/reference/site-config
const vitePressConfig: UserConfig = {
title: 'VitePress Sidebar',
Expand Down Expand Up @@ -55,11 +120,6 @@ const vitePressConfig: UserConfig = {
};
})
]),
search: generateI18nSearch({
defineLocales: defineSupportLocales,
rootLocale: defaultLocale,
provider: 'local'
}),
socialLinks: [
{ icon: 'npm', link: 'https://www.npmjs.com/package/vitepress-sidebar' },
{ icon: 'github', link: repository.url.replace('.git', '') }
Expand All @@ -68,70 +128,9 @@ const vitePressConfig: UserConfig = {
message: 'Released under the MIT License',
copyright: '© <a href="https://cdget.com">CDGet</a>'
}
},
locales: generateI18nLocale({
defineLocales: defineSupportLocales,
rootLocale: defaultLocale,
editLinkPattern: editLinkPattern,
description: {
en: 'VitePress Sidebar is a VitePress plugin that automatically generates sidebar menus with one setup and no hassle. Save time by easily creating taxonomies for tons of articles.',
ko: 'VitePress Sidebar는 번거로운 작업 없이 한번의 설정만으로 사이드바 메뉴를 자동으로 생성하는 VitePress 플러그인입니다. 수많은 문서에 대한 분류를 손쉽게 만들어 시간을 절약하세요.',
zhHans:
'VitePress Sidebar是一款VitePress插件,只需一次设置即可自动生成侧边栏菜单,无需任何麻烦。轻松为大量文章创建分类,节省时间。'
},
themeConfig: {
en: {
nav: [
{
text: 'Installation',
link: '/guide/getting-started'
},
{
text: 'API Reference',
link: '/guide/api'
},
{
text: 'Changelog',
link: 'changelog'
}
]
},
ko: {
nav: [
{
text: '설치',
link: '/ko/guide/getting-started'
},
{
text: 'API',
link: '/ko/guide/api'
},
{
text: '변경사항',
link: '/ko/changelog'
}
]
},
zhHans: {
nav: [
{
text: '安装',
link: '/zhHans/guide/getting-started'
},
{
text: 'API',
link: '/zhHans/guide/api'
},
{
text: '变化',
link: '/zhHans/changelog'
}
]
}
}
})
}
};

console.dir(vitePressConfig, { depth: null });

export default defineConfig(vitePressConfig);
export default defineConfig(withI18n(vitePressConfig, vitePressI18nConfig));
2 changes: 1 addition & 1 deletion docs/en/advanced-usage/multiple-sidebars-how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Here's an example of the output from the above setup:

The following options are available in Multiple sidebars: `scanStartPath`, `basePath`, and `resolvePath`. Each option is optional, but should be able to be used correctly depending on the situation.

Each option is described below. However, we recommend that you first refer to the descriptions of each option on the [API](/guide/api) page.
Each option is described below. However, we recommend that you first refer to the descriptions of each option on the [Options](/guide/options) page.

The descriptions below are based on the following examples:

Expand Down
4 changes: 2 additions & 2 deletions docs/en/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Use the `generateSidebar` method in the `themeConfig.sidebar` property of the `.

To test how this will output, try building VitePress with the `debugPrint` option set to `true`. You should see the output in the console.

For more information about the configuration of `generateSidebar`, see **[API](/guide/api)** section below.
For more information about the configuration of `generateSidebar`, see **[Options](/guide/options)** section below.

## Code Example

Expand All @@ -83,7 +83,7 @@ export default defineConfig({
sidebar: generateSidebar({
/*
* For detailed instructions, see the links below:
* https://vitepress-sidebar.cdget.com/guide/api
* https://vitepress-sidebar.cdget.com/guide/options
*/
// documentRootPath: '/',
// scanStartPath: null,
Expand Down
2 changes: 1 addition & 1 deletion docs/en/guide/api.md → docs/en/guide/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
order: 2
---

# API
# Sidebar Options

This page describes all the options in the VitePress Sidebar.

Expand Down
4 changes: 2 additions & 2 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ hero:
text: Getting Started
link: /guide/getting-started
- theme: alt
text: API
link: /guide/api
text: Options
link: /guide/options
- theme: alt
text: GitHub
link: https://github.com/jooy2/vitepress-sidebar
Expand Down
2 changes: 1 addition & 1 deletion docs/ko/advanced-usage/multiple-sidebars-how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ generateSidebar([

다중 사이드바에서 사용할 수 있는 옵션은 다음과 같습니다: `scanStartPath`, `basePath``resolvePath`. 각 옵션은 선택 사항이지만 상황에 따라 올바르게 사용할 수 있어야 합니다.

각 옵션은 아래에 설명되어 있습니다. 그러나 먼저 [API](/ko/guide/api) 페이지에서 각 옵션에 대한 설명을 참조하는 것이 좋습니다.
각 옵션은 아래에 설명되어 있습니다. 그러나 먼저 [옵션](/ko/guide/options) 페이지에서 각 옵션에 대한 설명을 참조하는 것이 좋습니다.

아래 설명은 다음 예시를 기반으로 합니다:

Expand Down
4 changes: 2 additions & 2 deletions docs/ko/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ VitePress의 구성 파일인 `.vitepress/config.js` 파일의 `themeConfig.side

이것이 어떻게 출력되는지 테스트하려면 `debugPrint` 옵션을 `true`로 설정하여 VitePress를 빌드해 보세요. 콘솔에 출력이 표시될 것입니다.

`generateSidebar`의 설정에 대한 자세한 내용은 아래 **[API](/ko/guide/api)** 섹션을 참조하세요.
`generateSidebar`의 설정에 대한 자세한 내용은 아래 **[옵션](/ko/guide/options)** 섹션을 참조하세요.

## 코드 예시

Expand All @@ -83,7 +83,7 @@ export default defineConfig({
sidebar: generateSidebar({
/*
* For detailed instructions, see the links below:
* https://vitepress-sidebar.cdget.com/ko/guide/api
* https://vitepress-sidebar.cdget.com/ko/guide/options
*/
// documentRootPath: '/',
// scanStartPath: null,
Expand Down
2 changes: 1 addition & 1 deletion docs/ko/guide/api.md → docs/ko/guide/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
order: 2
---

# API
# 사이드바 옵션

이 페이지에서는 VitePress Sidebar의 모든 옵션에 대해 설명합니다.

Expand Down
4 changes: 2 additions & 2 deletions docs/ko/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ hero:
text: 시작하기
link: /ko/guide/getting-started
- theme: alt
text: API
link: /ko/guide/api
text: 옵션
link: /ko/guide/options
- theme: alt
text: GitHub
link: https://github.com/jooy2/vitepress-sidebar
Expand Down
2 changes: 1 addition & 1 deletion docs/zhHans/advanced-usage/multiple-sidebars-how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ generateSidebar([

以下选项可用于多个侧边栏:`scanStartPath``basePath``resolvePath`。每个选项都是可选的,但应根据具体情况正确使用。

下文将对每个选项进行说明。但我们建议您首先参考[API](/zhHans/guide/api)页面上对每个选项的描述。
下文将对每个选项进行说明。但我们建议您首先参考[选项](/zhHans/guide/options)页面上对每个选项的描述。

以下描述基于以下示例:

Expand Down
4 changes: 2 additions & 2 deletions docs/zhHans/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default defineConfig({

要测试输出结果如何,请尝试在将 `debugPrint` 选项设置为 `true`的情况下构建 VitePress。你应该能在控制台中看到输出结果。

有关`generateSidebar`配置的更多信息,请参阅下面的 **[API](/zhHans/guide/api)** 部分。
有关`generateSidebar`配置的更多信息,请参阅下面的 **[选项](/zhHans/guide/options)** 部分。

## 代码示例

Expand All @@ -83,7 +83,7 @@ export default defineConfig({
sidebar: generateSidebar({
/*
* 有关详细说明,请参阅下面的链接:
* https://vitepress-sidebar.cdget.com/zhHans/guide/api
* https://vitepress-sidebar.cdget.com/zhHans/guide/options
*/
// documentRootPath: '/',
// scanStartPath: null,
Expand Down
2 changes: 1 addition & 1 deletion docs/zhHans/guide/api.md → docs/zhHans/guide/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
order: 2
---

# API
# 侧边栏选项

本页介绍 VitePress 侧边栏的所有选项。

Expand Down
4 changes: 2 additions & 2 deletions docs/zhHans/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ hero:
text: 入门
link: /zhHans/guide/getting-started
- theme: alt
text: API
link: /zhHans/guide/api
text: 选项
link: /zhHans/guide/options
- theme: alt
text: GitHub
link: https://github.com/jooy2/vitepress-sidebar
Expand Down
Loading

0 comments on commit 1f0e5d2

Please sign in to comment.