docs: upgrade vitepress-i18n package

This commit is contained in:
leejooy96 committed 2024-10-24 15:15:08 +09:00
1 parent 5f5789cb0c
commit a7a8420cf1
3 files changed
+58 -62

No files matched your search

+5 -4
View File
@@ -10,7 +10,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"vitepress": "^1.4.1", "vitepress": "^1.4.1",
"vitepress-i18n": "^1.0.6", "vitepress-i18n": "^1.3.0",
"vitepress-sidebar": "^1.27.1", "vitepress-sidebar": "^1.27.1",
"vue": "^3.5.12" "vue": "^3.5.12"
}, },
@@ -2781,9 +2781,10 @@
} }
}, },
"node_modules/vitepress-i18n": { "node_modules/vitepress-i18n": {
"version": "1.0.6", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/vitepress-i18n/-/vitepress-i18n-1.0.6.tgz", "resolved": "https://registry.npmjs.org/vitepress-i18n/-/vitepress-i18n-1.3.0.tgz",
"integrity": "sha512-SNiOrA+mLFMyL9+Fkrqp7iGM+M+Gzg3fsT1nY7li3JlrFkRu4sal/rKXtKDZrqQGFd7blIdTurYGBe27bMxs7g==", "integrity": "sha512-9GNglkvXCvFIVSYjQ4gjZSnhVCilzfHLlntr0TA6PTaqBvYhE5fdxVCqycQdVTXeLRHBDoZfxztzqSRgkQqoxQ==",
"license": "MIT",
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"
} }
+1 -1
View File
@@ -14,7 +14,7 @@
}, },
"dependencies": { "dependencies": {
"vitepress": "^1.4.1", "vitepress": "^1.4.1",
"vitepress-i18n": "^1.0.6", "vitepress-i18n": "^1.3.0",
"vitepress-sidebar": "^1.27.1", "vitepress-sidebar": "^1.27.1",
"vue": "^3.5.12" "vue": "^3.5.12"
} }
+52 -57
View File
@@ -1,67 +1,15 @@
import { generateSidebar } from 'vitepress-sidebar' import { generateSidebar } from 'vitepress-sidebar'
import { name, repository, homepage } from '../../../package.json' import { name, repository, homepage } from '../../../package.json'
import { defineConfig } from 'vitepress' 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 capitalizeFirst = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1)
const defaultLocale: string = 'en' const defaultLocale: string = 'en'
const editLinkPattern = 'https://github.com/jooy2/vutron/edit/master/docs/src/:path'
const defineSupportLocales = [ const vitePressI18nConfigs = {
{ label: defaultLocale, translateLocale: defaultLocale }, locales: [defaultLocale, 'ko'],
{ label: 'ko', translateLocale: 'ko' }
]
export default defineConfig({
title: capitalizeFirst(name),
lastUpdated: true,
outDir: '../dist',
head: [
['link', { rel: 'icon', href: '/logo.png' }],
['link', { rel: 'shortcut icon', href: '/favicon.ico' }]
],
cleanUrls: true,
metaChunk: true,
rewrites: {
'en/:rest*': ':rest*'
},
sitemap: {
hostname: homepage
},
themeConfig: {
logo: { src: '/icon.png', width: 24, height: 24 },
search: generateI18nSearch({
defineLocales: defineSupportLocales,
rootLocale: defaultLocale, rootLocale: defaultLocale,
provider: 'local' searchProvider: 'local',
}),
sidebar: generateSidebar([
...[defaultLocale, 'ko'].map((lang) => {
return {
collapsed: false,
useTitleFromFileHeading: true,
useTitleFromFrontmatter: true,
useFolderTitleFromIndexFile: true,
sortMenusByFrontmatterOrder: true,
hyphenToSpace: true,
capitalizeEachWords: true,
manualSortFileNameByPriority: [
'installation-and-build',
'project-structures',
'electron-how-to'
],
documentRootPath: `/src/${lang}`,
resolvePath: defaultLocale === lang ? '/' : `/${lang}/`,
...(defaultLocale === lang ? {} : { basePath: `/${lang}/` })
}
})
]),
socialLinks: [{ icon: 'github', link: repository.url.replace('.git', '') }]
},
locales: generateI18nLocale({
defineLocales: defineSupportLocales,
rootLocale: defaultLocale,
editLinkPattern: editLinkPattern,
description: { 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.', 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을 사용하며 적은 노력으로 빠른 개발 환경을 구축할 수 있습니다.' ko: 'Vutron은 Electron 크로스 플랫폼 데스크톱 앱 개발을 위해 미리 구성된 템플릿입니다. Vue 3을 사용하며 적은 노력으로 빠른 개발 환경을 구축할 수 있습니다.'
@@ -84,5 +32,52 @@ export default defineConfig({
] ]
} }
} }
}
const vitePressConfigs = {
title: capitalizeFirst(name),
lastUpdated: true,
outDir: '../dist',
head: [
['link', { rel: 'icon', href: '/logo.png' }],
['link', { rel: 'shortcut icon', href: '/favicon.ico' }]
],
cleanUrls: true,
metaChunk: true,
rewrites: {
'en/:rest*': ':rest*'
},
sitemap: {
hostname: homepage
},
themeConfig: {
logo: { src: '/icon.png', width: 24, height: 24 },
editLink: {
pattern: 'https://github.com/jooy2/vutron/edit/master/docs/src/:path'
},
sidebar: generateSidebar([
...[defaultLocale, 'ko'].map((lang) => {
return {
collapsed: false,
useTitleFromFileHeading: true,
useTitleFromFrontmatter: true,
useFolderTitleFromIndexFile: true,
sortMenusByFrontmatterOrder: true,
hyphenToSpace: true,
capitalizeEachWords: true,
manualSortFileNameByPriority: [
'installation-and-build',
'project-structures',
'electron-how-to'
],
documentRootPath: `/src/${lang}`,
resolvePath: defaultLocale === lang ? '/' : `/${lang}/`,
...(defaultLocale === lang ? {} : { basePath: `/${lang}/` })
}
}) })
}) ]),
socialLinks: [{ icon: 'github', link: repository.url.replace('.git', '') }]
}
}
export default defineConfig(withI18n(vitePressConfigs, vitePressI18nConfigs))