From 30fe922a0c0deec5f3b1a1b313dcbd860d689d72 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Fri, 16 Jun 2023 16:41:20 +0800 Subject: [PATCH] docs: add i18n config --- docs/.vuepress/config.ts | 55 +++++++++++++++++-- docs/.vuepress/notes.ts | 15 ++++- docs/en/1.FE/1.Node/english_blog.md | 6 ++ docs/en/README.md | 17 ++++++ .../notes/vuepress-plugin/caniuse/README.md | 8 +++ 5 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 docs/en/1.FE/1.Node/english_blog.md create mode 100644 docs/en/README.md create mode 100644 docs/en/notes/vuepress-plugin/caniuse/README.md diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index df9c3f63..def1b756 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -3,7 +3,7 @@ import { viteBundler } from '@vuepress/bundler-vite' import { webpackBundler } from '@vuepress/bundler-webpack' import { defineUserConfig } from '@vuepress/cli' import themePlume from '@vuepress-plume/vuepress-theme-plume' -import notes from './notes.js' +import { enNotes, zhNotes } from './notes.js' export default defineUserConfig({ base: '/', @@ -12,6 +12,18 @@ export default defineUserConfig({ description: '', source: path.resolve(__dirname, '../'), public: path.resolve(__dirname, 'public'), + locales: { + '/': { + title: 'Plume主题', + description: '', + lang: 'zh', + }, + '/en/': { + title: 'Plume Theme', + description: '', + lang: 'en', + }, + }, bundler: process.env.DOCS_BUNDLER === 'webpack' ? webpackBundler() : viteBundler(), @@ -26,11 +38,11 @@ export default defineUserConfig({ description: 'The Theme for Vuepress 2.0', }, social: [{ icon: 'github', link: 'https://github.com/pengzhanbo' }], - notes, + notes: zhNotes, navbar: [ - { text: 'Home', link: '/', icon: 'material-symbols:home-outline' }, + { text: '首页', link: '/', icon: 'material-symbols:home-outline' }, { - text: 'Blog', + text: '博客', link: '/blog/', icon: 'material-symbols:article-outline', }, @@ -44,7 +56,7 @@ export default defineUserConfig({ icon: 'icon-park-outline:theme', }, { - text: 'Plugin', + text: '插件', icon: 'mingcute:plugin-2-line', items: [ { @@ -74,5 +86,38 @@ export default defineUserConfig({ }, }, }, + locales: { + '/': { selectLanguageName: '简体中文', selectLanguageText: '选择语言' }, + '/en/': { + selectLanguageName: 'English', + selectLanguageText: 'Language', + notes: enNotes, + navbar: [ + { text: 'Home', link: '/en/', icon: 'material-symbols:home-outline' }, + { + text: 'Blog', + link: '/en/blog/', + icon: 'material-symbols:article-outline', + }, + { + text: 'VuePress', + icon: 'vscode-icons:file-type-vue', + items: [ + { + text: 'Plugin', + icon: 'mingcute:plugin-2-line', + items: [ + { + text: 'caniuse', + link: '/en/note/vuepress-plugin/caniuse/', + icon: 'tabler:brand-css3', + }, + ], + }, + ], + }, + ], + }, + }, }), }) diff --git a/docs/.vuepress/notes.ts b/docs/.vuepress/notes.ts index 2986ca7a..038468be 100644 --- a/docs/.vuepress/notes.ts +++ b/docs/.vuepress/notes.ts @@ -1,6 +1,6 @@ import { definePlumeNotesConfig } from '@vuepress-plume/vuepress-theme-plume' -export default definePlumeNotesConfig({ +export const zhNotes = definePlumeNotesConfig({ dir: 'notes', link: '/note', notes: [ @@ -48,3 +48,16 @@ export default definePlumeNotesConfig({ }, ], }) + +export const enNotes = definePlumeNotesConfig({ + dir: 'notes', + link: '/note', + notes: [ + { + dir: 'vuepress-plugin', + text: '', + link: '/vuepress-plugin/', + sidebar: ['caniuse/README'], + }, + ], +}) diff --git a/docs/en/1.FE/1.Node/english_blog.md b/docs/en/1.FE/1.Node/english_blog.md new file mode 100644 index 00000000..4d83c007 --- /dev/null +++ b/docs/en/1.FE/1.Node/english_blog.md @@ -0,0 +1,6 @@ +--- +title: english_blog +author: Plume Theme +createTime: 2023/06/15 08:51:31 +permalink: /en/article/xw0awouo/ +--- diff --git a/docs/en/README.md b/docs/en/README.md new file mode 100644 index 00000000..653c0c25 --- /dev/null +++ b/docs/en/README.md @@ -0,0 +1,17 @@ +--- +home: true +banner: /images/bg-home.jpg +hero: + name: pengzhanbo + tagline: Front-End Developer + text: 简单介绍专业技能信息相关的描述 + actions: + - + theme: brand + text: Blog + link: /en/blog/ + - + theme: alt + text: Github + link: / +--- diff --git a/docs/en/notes/vuepress-plugin/caniuse/README.md b/docs/en/notes/vuepress-plugin/caniuse/README.md new file mode 100644 index 00000000..59370030 --- /dev/null +++ b/docs/en/notes/vuepress-plugin/caniuse/README.md @@ -0,0 +1,8 @@ +--- +title: plugin-caniuse +author: Plume Theme +createTime: 2023/06/15 09:33:00 +permalink: /en/note/vuepress-plugin/caniuse +--- + +## Can I Use