Skip to content

Commit

Permalink
fix: hidden translations if not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 committed Oct 3, 2022
1 parent 20ffb49 commit 133b4d7
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/theme-default/components/Nav/index.tsx
Expand Up @@ -18,6 +18,9 @@ export function Nav() {
const hasSidebar = pageType === 'doc';
const hasAppearanceSwitch = siteData.appearance !== false;
const localeData = useLocaleSiteData(siteData.themeConfig, location.pathname);
const hasMultiLanguage =
siteData.themeConfig.locales &&
Object.keys(siteData.themeConfig.locales).length > 1;
const lang = localeData.lang || 'zh';
const menuItems = localeData.nav || [];
const socialLinks = siteData?.themeConfig?.socialLinks || [];
Expand Down Expand Up @@ -102,18 +105,20 @@ export function Nav() {
{}
</div>
<div className="menu">{renderMenuList()}</div>
<div
className="translation"
flex="~"
text="sm"
font="bold"
items-center="~"
before="menu-item-before"
>
<Link href={lang === 'zh' ? '/en/' : '/zh/'}>
{lang === 'zh' ? 'English' : '中文版'}
</Link>
</div>
{hasMultiLanguage && (
<div
className="translation"
flex="~"
text="sm"
font="bold"
items-center="~"
before="menu-item-before"
>
<Link href={lang === 'zh' ? '/en/' : '/zh/'}>
{lang === 'zh' ? 'English' : '中文版'}
</Link>
</div>
)}
{hasAppearanceSwitch && (
<div
className="appearance"
Expand Down

0 comments on commit 133b4d7

Please sign in to comment.