Skip to content

Commit

Permalink
docs: upgrade vitepress-i18n package
Browse files Browse the repository at this point in the history
  • Loading branch information
jooy2 committed Oct 24, 2024
1 parent 5f5789c commit a7a8420
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 46 deletions.
9 changes: 5 additions & 4 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"vitepress": "^1.4.1",
"vitepress-i18n": "^1.0.6",
"vitepress-i18n": "^1.3.0",
"vitepress-sidebar": "^1.27.1",
"vue": "^3.5.12"
}
Expand Down
77 changes: 36 additions & 41 deletions docs/src/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
import { generateSidebar } from 'vitepress-sidebar'
import { name, repository, homepage } from '../../../package.json'
import { defineConfig } from 'vitepress'
import { generateI18nLocale, generateI18nSearch } from 'vitepress-i18n'
import { withI18n } from 'vitepress-i18n'

const capitalizeFirst = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1)
const defaultLocale: string = 'en'
const editLinkPattern = 'https://github.com/jooy2/vutron/edit/master/docs/src/:path'

const defineSupportLocales = [
{ label: defaultLocale, translateLocale: defaultLocale },
{ label: 'ko', translateLocale: 'ko' }
]
const vitePressI18nConfigs = {
locales: [defaultLocale, 'ko'],
rootLocale: defaultLocale,
searchProvider: 'local',
description: {
en: 'Vutron is a preconfigured template for developing Electron cross-platform desktop apps. It uses Vue 3 and allows you to build a fast development environment with little effort.',
ko: 'Vutron은 Electron 크로스 플랫폼 데스크톱 앱 개발을 위해 미리 구성된 템플릿입니다. Vue 3을 사용하며 적은 노력으로 빠른 개발 환경을 구축할 수 있습니다.'
},
themeConfig: {
en: {
nav: [
{
text: 'Getting Started',
link: '/installation-and-build/getting-started'
}
]
},
ko: {
nav: [
{
text: '시작하기',
link: '/ko/installation-and-build/getting-started'
}
]
}
}
}

export default defineConfig({
const vitePressConfigs = {
title: capitalizeFirst(name),
lastUpdated: true,
outDir: '../dist',
Expand All @@ -30,11 +52,9 @@ export default defineConfig({
},
themeConfig: {
logo: { src: '/icon.png', width: 24, height: 24 },
search: generateI18nSearch({
defineLocales: defineSupportLocales,
rootLocale: defaultLocale,
provider: 'local'
}),
editLink: {
pattern: 'https://github.com/jooy2/vutron/edit/master/docs/src/:path'
},
sidebar: generateSidebar([
...[defaultLocale, 'ko'].map((lang) => {
return {
Expand All @@ -57,32 +77,7 @@ export default defineConfig({
})
]),
socialLinks: [{ icon: 'github', link: repository.url.replace('.git', '') }]
},
locales: generateI18nLocale({
defineLocales: defineSupportLocales,
rootLocale: defaultLocale,
editLinkPattern: editLinkPattern,
description: {
en: 'Vutron is a preconfigured template for developing Electron cross-platform desktop apps. It uses Vue 3 and allows you to build a fast development environment with little effort.',
ko: 'Vutron은 Electron 크로스 플랫폼 데스크톱 앱 개발을 위해 미리 구성된 템플릿입니다. Vue 3을 사용하며 적은 노력으로 빠른 개발 환경을 구축할 수 있습니다.'
},
themeConfig: {
en: {
nav: [
{
text: 'Getting Started',
link: '/installation-and-build/getting-started'
}
]
},
ko: {
nav: [
{
text: '시작하기',
link: '/ko/installation-and-build/getting-started'
}
]
}
}
})
})
}
}

export default defineConfig(withI18n(vitePressConfigs, vitePressI18nConfigs))

0 comments on commit a7a8420

Please sign in to comment.