2024-09-08 12:35:04 +03:00
|
|
|
import { type DefaultTheme, defineConfig } from 'vitepress';
|
|
|
|
import { sortByText } from './libs/sortByText.mts';
|
|
|
|
import path from 'node:path';
|
|
|
|
import { getSidebarItems } from './libs/getSidebarItems.mts';
|
2024-09-08 11:02:19 +03:00
|
|
|
|
2024-09-08 12:35:04 +03:00
|
|
|
const docsRoot = path.resolve(import.meta.dirname, '..');
|
2024-07-12 04:08:55 +03:00
|
|
|
|
2024-08-28 17:20:13 +03:00
|
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
2024-07-12 04:08:55 +03:00
|
|
|
export const zh_hans = defineConfig({
|
2024-09-08 12:35:04 +03:00
|
|
|
lang: 'zh_hans',
|
|
|
|
description: '一款先进的高性能 JavaScript 实用库,具有小巧的包体积和强大的类型注解。',
|
2024-07-12 04:08:55 +03:00
|
|
|
|
|
|
|
themeConfig: {
|
|
|
|
nav: nav(),
|
|
|
|
|
|
|
|
sidebar: sidebar(),
|
|
|
|
|
|
|
|
editLink: {
|
2024-09-08 12:35:04 +03:00
|
|
|
pattern: 'https://github.com/toss/es-toolkit/edit/main/docs/:path',
|
|
|
|
text: '在 GitHub 上编辑此页面',
|
2024-07-12 04:08:55 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
footer: {
|
2024-09-08 12:35:04 +03:00
|
|
|
message: '采用 MIT 许可证发布。',
|
2024-07-12 04:08:55 +03:00
|
|
|
copyright: `Copyright © ${new Date().getFullYear()} Viva Republica, Inc.`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
function nav(): DefaultTheme.NavItem[] {
|
|
|
|
return [
|
2024-09-08 12:35:04 +03:00
|
|
|
{ text: '主页', link: '/zh_hans/' },
|
|
|
|
{ text: '简介', link: '/zh_hans/intro' },
|
|
|
|
{ text: '参考', link: '/zh_hans/reference/array/chunk' },
|
2024-07-12 04:08:55 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function sidebar(): DefaultTheme.Sidebar {
|
|
|
|
return [
|
|
|
|
{
|
2024-09-08 12:35:04 +03:00
|
|
|
text: '指南',
|
2024-07-12 04:08:55 +03:00
|
|
|
items: [
|
2024-09-08 12:35:04 +03:00
|
|
|
{ text: '简介', link: '/zh_hans/intro' },
|
|
|
|
{ text: '安装和使用', link: '/zh_hans/usage' },
|
|
|
|
{ text: '包体积影响', link: '/zh_hans/bundle-size' },
|
|
|
|
{ text: '性能', link: '/zh_hans/performance' },
|
|
|
|
{ text: '与 Lodash 兼容性', link: '/zh_hans/compatibility' },
|
2024-07-12 04:08:55 +03:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2024-09-08 12:35:04 +03:00
|
|
|
text: '参考',
|
2024-08-31 08:51:58 +03:00
|
|
|
items: sortByText([
|
2024-07-12 04:08:55 +03:00
|
|
|
{
|
2024-09-08 12:35:04 +03:00
|
|
|
text: '数组工具',
|
2024-07-12 04:08:55 +03:00
|
|
|
items: [
|
2024-09-08 12:35:04 +03:00
|
|
|
...getSidebarItems(docsRoot, 'zh_hans', 'reference', 'array'),
|
|
|
|
...getSidebarItems.compat('zh_hans', docsRoot, 'zh_hans', 'reference', 'compat', 'array'),
|
2024-07-12 04:08:55 +03:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2024-09-08 12:35:04 +03:00
|
|
|
text: '函数工具',
|
2024-07-12 04:08:55 +03:00
|
|
|
items: [
|
2024-09-08 12:35:04 +03:00
|
|
|
...getSidebarItems(docsRoot, 'zh_hans', 'reference', 'function'),
|
|
|
|
...getSidebarItems.compat('zh_hans', docsRoot, 'zh_hans', 'reference', 'compat', 'function'),
|
2024-07-12 04:08:55 +03:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2024-09-08 12:35:04 +03:00
|
|
|
text: '数学工具',
|
2024-07-12 04:08:55 +03:00
|
|
|
items: [
|
2024-09-08 12:35:04 +03:00
|
|
|
...getSidebarItems(docsRoot, 'zh_hans', 'reference', 'math'),
|
|
|
|
...getSidebarItems.compat('zh_hans', docsRoot, 'zh_hans', 'reference', 'compat', 'math'),
|
2024-07-12 04:08:55 +03:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2024-09-08 12:35:04 +03:00
|
|
|
text: '对象工具',
|
2024-07-12 04:08:55 +03:00
|
|
|
items: [
|
2024-09-08 12:35:04 +03:00
|
|
|
...getSidebarItems(docsRoot, 'zh_hans', 'reference', 'object'),
|
|
|
|
...getSidebarItems.compat('zh_hans', docsRoot, 'zh_hans', 'reference', 'compat', 'object'),
|
2024-07-12 04:08:55 +03:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2024-09-08 12:35:04 +03:00
|
|
|
text: '谓词',
|
2024-07-12 04:08:55 +03:00
|
|
|
items: [
|
2024-09-08 12:35:04 +03:00
|
|
|
...getSidebarItems(docsRoot, 'zh_hans', 'reference', 'predicate'),
|
|
|
|
...getSidebarItems.compat('zh_hans', docsRoot, 'zh_hans', 'reference', 'compat', 'predicate'),
|
2024-07-12 04:08:55 +03:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2024-09-08 12:35:04 +03:00
|
|
|
text: 'Promise 工具',
|
2024-07-18 18:53:17 +03:00
|
|
|
items: [
|
2024-09-08 12:35:04 +03:00
|
|
|
...getSidebarItems(docsRoot, 'zh_hans', 'reference', 'promise'),
|
|
|
|
...getSidebarItems.compat('zh_hans', docsRoot, 'zh_hans', 'reference', 'compat', 'promise'),
|
2024-07-18 18:53:17 +03:00
|
|
|
],
|
2024-07-12 04:08:55 +03:00
|
|
|
},
|
|
|
|
{
|
2024-09-08 12:35:04 +03:00
|
|
|
text: '字符串工具',
|
2024-07-16 06:31:56 +03:00
|
|
|
items: [
|
2024-09-08 12:35:04 +03:00
|
|
|
...getSidebarItems(docsRoot, 'zh_hans', 'reference', 'string'),
|
|
|
|
...getSidebarItems.compat('zh_hans', docsRoot, 'zh_hans', 'reference', 'compat', 'string'),
|
2024-07-16 06:31:56 +03:00
|
|
|
],
|
2024-07-20 05:21:19 +03:00
|
|
|
},
|
2024-08-11 15:38:32 +03:00
|
|
|
{
|
2024-09-08 12:35:04 +03:00
|
|
|
text: '错误',
|
2024-08-11 15:38:32 +03:00
|
|
|
items: [
|
2024-09-08 12:35:04 +03:00
|
|
|
...getSidebarItems(docsRoot, 'zh_hans', 'reference', 'error'),
|
|
|
|
...getSidebarItems.compat('zh_hans', docsRoot, 'zh_hans', 'reference', 'compat', 'error'),
|
2024-08-11 15:38:32 +03:00
|
|
|
],
|
|
|
|
},
|
2024-08-31 08:51:58 +03:00
|
|
|
]),
|
2024-07-12 04:08:55 +03:00
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-09-08 12:35:04 +03:00
|
|
|
export const search: DefaultTheme.LocalSearchOptions['locales'] = {
|
2024-07-12 04:08:55 +03:00
|
|
|
zh_hans: {
|
|
|
|
translations: {
|
|
|
|
button: {
|
2024-09-08 12:35:04 +03:00
|
|
|
buttonText: '搜索',
|
|
|
|
buttonAriaLabel: '搜索',
|
2024-07-12 04:08:55 +03:00
|
|
|
},
|
|
|
|
modal: {
|
2024-09-08 12:35:04 +03:00
|
|
|
backButtonTitle: '返回',
|
|
|
|
displayDetails: '显示详情',
|
2024-07-12 04:08:55 +03:00
|
|
|
footer: {
|
2024-09-08 12:35:04 +03:00
|
|
|
closeKeyAriaLabel: '关闭',
|
|
|
|
closeText: '关闭',
|
|
|
|
navigateDownKeyAriaLabel: '向下导航',
|
|
|
|
navigateText: '导航',
|
|
|
|
navigateUpKeyAriaLabel: '向上导航',
|
|
|
|
selectKeyAriaLabel: '选择',
|
|
|
|
selectText: '选择',
|
2024-07-12 04:08:55 +03:00
|
|
|
},
|
2024-09-08 12:35:04 +03:00
|
|
|
noResultsText: '未找到搜索结果。',
|
|
|
|
resetButtonTitle: '重置',
|
2024-07-12 04:08:55 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|