diff --git a/docusaurus.config.js b/docusaurus.config.js index 8f22933..6b59636 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -73,10 +73,25 @@ module.exports = { dropdownActiveClassDisabled: true }, // { - // type:'html', - // position:"right", - // value:"
22221114444
" + // type: 'localeDropdown', + // position: 'right', // }, + { + position: 'right', + component:'./src/components/LanguageSwitcher', + // label:"language", + to:"#" + // items: [ + // { + // label: 'English', + // onClick: () => handleLocaleChange('en') + // }, + // { + // label: '简体中文', + // onClick: () => handleLocaleChange('zh-Hans') + // } + // ] + } // { // href: 'https://github.com/boxyhq', // position: 'right', @@ -191,8 +206,14 @@ module.exports = { defaultLocale: 'zh-cn', locales: ['zh-cn','en'], localeConfigs: { - en: { label: 'English' }, - 'zh-cn': { label: '简体中文' }, + en: { + label: 'English', + htmlLang: 'en', + }, + 'zh-cn': { + label: '简体中文', + htmlLang: 'zh-CN', + }, }, }, }; diff --git a/src/components/LanguageSwitcher.js b/src/components/LanguageSwitcher.js new file mode 100644 index 0000000..0f4d50a --- /dev/null +++ b/src/components/LanguageSwitcher.js @@ -0,0 +1,38 @@ +// src/components/LanguageSwitcher.js +import React from 'react'; +import { useDocusaurusContext } from '@docusaurus/useDocusaurusContext'; + +export default function LanguageSwitcher() { + const { i18n } = useDocusaurusContext(); + + const locales = [ + { code: 'en', label: 'English' }, + { code: 'zh-Hans', label: '简体中文' } + ]; + + return ( +
+ +
+ ); +} \ No newline at end of file