mirror of
https://github.com/antd-tiny-vue/antd-tiny-vue.git
synced 2025-07-03 10:33:11 +08:00
feat: add locale
This commit is contained in:
42
.vitepress/config.ts
Normal file
42
.vitepress/config.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import { fileURLToPath } from 'url'
|
||||
import { resolve } from 'path'
|
||||
import { defineConfig } from 'vitepress'
|
||||
import vueJsxPlugin from '@vitejs/plugin-vue-jsx'
|
||||
import VitePluginVitepressDemo from 'vite-plugin-vitepress-demo'
|
||||
import getEnUSConfig from './config/en-US'
|
||||
import getZhCNConfig from './config/zh-CN'
|
||||
import { getRewrites } from './config/rewrites'
|
||||
const baseSrc = fileURLToPath(new URL('./', import.meta.url))
|
||||
|
||||
export default defineConfig({
|
||||
rewrites: getRewrites(),
|
||||
mpa: true,
|
||||
lang: 'en-US',
|
||||
locales: {
|
||||
'zh-CN': {
|
||||
lang: 'zh-CN',
|
||||
title: 'vue3组件库站点',
|
||||
label: '简体中文',
|
||||
description: 'vue3组件库站点',
|
||||
themeConfig: getZhCNConfig()
|
||||
},
|
||||
root: {
|
||||
lang: 'en-US',
|
||||
title: 'vue3 component library site',
|
||||
label: 'English',
|
||||
description: 'vue3 component library site',
|
||||
themeConfig: getEnUSConfig()
|
||||
}
|
||||
},
|
||||
vite: {
|
||||
plugins: [vueJsxPlugin(), VitePluginVitepressDemo()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'antd-tiny-vue': resolve(baseSrc, '../components')
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 1199
|
||||
}
|
||||
}
|
||||
})
|
9
.vitepress/config/en-US/index.ts
Normal file
9
.vitepress/config/en-US/index.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import type { DefaultTheme } from 'vitepress'
|
||||
import { getNav } from './nav'
|
||||
import { getSidebar } from './sidebar'
|
||||
|
||||
export default (): DefaultTheme.Config => ({
|
||||
nav: getNav(),
|
||||
sidebar: getSidebar(),
|
||||
i18nRouting: true
|
||||
})
|
10
.vitepress/config/en-US/nav.ts
Normal file
10
.vitepress/config/en-US/nav.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import type { DefaultTheme } from 'vitepress'
|
||||
|
||||
export const getNav = (): DefaultTheme.NavItem[] => {
|
||||
return [
|
||||
{
|
||||
text: 'Components',
|
||||
link: '/components/'
|
||||
}
|
||||
]
|
||||
}
|
18
.vitepress/config/en-US/sidebar.ts
Normal file
18
.vitepress/config/en-US/sidebar.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import type { DefaultTheme } from 'vitepress'
|
||||
|
||||
const componentsDir = `/components/`
|
||||
|
||||
export const getSidebar = (): DefaultTheme.Sidebar => {
|
||||
return {
|
||||
'/components/': [
|
||||
{
|
||||
text: 'Button',
|
||||
link: `${componentsDir}button/`
|
||||
},
|
||||
{
|
||||
text: 'ConfigProvider',
|
||||
link: `${componentsDir}config-provider/`
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
9
.vitepress/config/rewrites.ts
Normal file
9
.vitepress/config/rewrites.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export const getRewrites = (): Record<string, string> => {
|
||||
return {
|
||||
'site/index.md': 'index.md',
|
||||
'site/index.zh-CN.md': 'zh-CN/index.md',
|
||||
'site/components/index.md': 'components/index.md',
|
||||
'site/components/index.zh-CN.md': 'zh-CN/components/index.md',
|
||||
'components/:btn/index.zh-CN.md': 'zh-CN/components/:btn/index.md'
|
||||
}
|
||||
}
|
9
.vitepress/config/zh-CN/index.ts
Normal file
9
.vitepress/config/zh-CN/index.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import type { DefaultTheme } from 'vitepress'
|
||||
import { getNav } from './nav'
|
||||
import { getSidebar } from './sidebar'
|
||||
|
||||
export default (): DefaultTheme.Config => ({
|
||||
nav: getNav(),
|
||||
sidebar: getSidebar(),
|
||||
i18nRouting: true
|
||||
})
|
10
.vitepress/config/zh-CN/nav.ts
Normal file
10
.vitepress/config/zh-CN/nav.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import type { DefaultTheme } from 'vitepress'
|
||||
|
||||
export const getNav = (): DefaultTheme.NavItem[] => {
|
||||
return [
|
||||
{
|
||||
text: '组件',
|
||||
link: '/zh-CN/components/'
|
||||
}
|
||||
]
|
||||
}
|
17
.vitepress/config/zh-CN/sidebar.ts
Normal file
17
.vitepress/config/zh-CN/sidebar.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import type { DefaultTheme } from 'vitepress'
|
||||
const componentsDir = `/zh-CN/components/`
|
||||
|
||||
export const getSidebar = (): DefaultTheme.Sidebar => {
|
||||
return {
|
||||
'/zh-CN/components/': [
|
||||
{
|
||||
text: 'Button 按钮',
|
||||
link: `${componentsDir}button/`
|
||||
},
|
||||
{
|
||||
text: 'ConfigProvider',
|
||||
link: `${componentsDir}config-provider/`
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
15
.vitepress/theme/index.ts
Normal file
15
.vitepress/theme/index.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import type { Theme } from 'vitepress'
|
||||
// eslint-disable-next-line import/no-named-as-default
|
||||
import DefaultTheme from 'vitepress/theme'
|
||||
import { AntdTheme } from 'vite-plugin-vitepress-demo/theme'
|
||||
// @ts-expect-error this is a local module
|
||||
import Antd from 'antd-tiny-vue'
|
||||
|
||||
export default {
|
||||
...DefaultTheme,
|
||||
enhanceApp(ctx) {
|
||||
DefaultTheme.enhanceApp?.(ctx)
|
||||
ctx.app.component('Demo', AntdTheme)
|
||||
ctx.app.use(Antd)
|
||||
}
|
||||
} as Theme
|
Reference in New Issue
Block a user