|
1 | 1 | import React, { JSX, useState, useEffect } from 'react'; |
2 | 2 | import Link from '@docusaurus/Link'; |
3 | | -import { useLocation } from '@docusaurus/router'; |
4 | 3 | import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; |
5 | | -import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem'; |
6 | | -import { getLocalePrefix, isDocsNextPath, isReleasesPath, normalizePathname } from '@site/src/utils/locale'; |
| 4 | +import { getLocalePrefix } from '@site/src/utils/locale'; |
7 | 5 | import { STAR_COUNT } from '@site/src/constant/github.data'; |
8 | 6 | import './NavbarNext.scss'; |
9 | 7 |
|
@@ -109,33 +107,15 @@ function MenuIcon({ open }: { open: boolean }): JSX.Element { |
109 | 107 |
|
110 | 108 | export function NavbarNext(): JSX.Element { |
111 | 109 | const { |
112 | | - i18n: { currentLocale, defaultLocale, localeConfigs }, |
| 110 | + i18n: { currentLocale, defaultLocale }, |
113 | 111 | } = useDocusaurusContext(); |
114 | | - const { pathname, search, hash } = useLocation(); |
115 | 112 | const [mobileOpen, setMobileOpen] = useState(false); |
116 | 113 | const localePrefix = getLocalePrefix(currentLocale, defaultLocale); |
117 | 114 | const docsHref = `${localePrefix}/docs-next/dev/getting-started/what-is-apache-doris`; |
118 | 115 | const releasesHref = `${localePrefix}/releases/all-release`; |
119 | 116 | const navItems = buildNavItems(docsHref, releasesHref); |
120 | 117 | const [expandedMobileItem, setExpandedMobileItem] = useState(navItems[0]?.label ?? ''); |
121 | | - const isDocsNextPage = isDocsNextPath(pathname, [defaultLocale, 'zh-CN']); |
122 | | - const isReleasesPage = isReleasesPath(pathname, [defaultLocale, 'zh-CN']); |
123 | | - const showLocaleSwitcher = isDocsNextPage || isReleasesPage; |
124 | 118 | const homeHref = `${getLocalePrefix(currentLocale, defaultLocale)}/`; |
125 | | - const localeSwitchLabel = currentLocale === 'zh-CN' ? localeConfigs[defaultLocale]?.label ?? 'English' : '中文'; |
126 | | - const currentLocalizedPath = normalizePathname(pathname, [defaultLocale, 'zh-CN']); |
127 | | - const buildLocaleHref = (locale: string) => |
128 | | - `pathname://${locale === defaultLocale ? '' : `/${locale}`}${currentLocalizedPath}${search}${hash}`; |
129 | | - const localeItems = [defaultLocale, 'zh-CN'] |
130 | | - .filter((locale, index, arr) => arr.indexOf(locale) === index) |
131 | | - .map(locale => ({ |
132 | | - label: localeConfigs[locale]?.label ?? locale, |
133 | | - lang: localeConfigs[locale]?.htmlLang, |
134 | | - to: buildLocaleHref(locale), |
135 | | - target: '_self', |
136 | | - autoAddBaseUrl: false, |
137 | | - className: locale === currentLocale ? 'dropdown__link--active' : '', |
138 | | - })); |
139 | 119 |
|
140 | 120 | useEffect(() => { |
141 | 121 | if (!mobileOpen) return undefined; |
@@ -186,33 +166,6 @@ export function NavbarNext(): JSX.Element { |
186 | 166 | </div> |
187 | 167 |
|
188 | 168 | <div className="navbar-next__actions"> |
189 | | - {showLocaleSwitcher && ( |
190 | | - <DropdownNavbarItem |
191 | | - mobile={false} |
192 | | - label={ |
193 | | - <> |
194 | | - <svg |
195 | | - className="icon-language navbar-next__locale-icon" |
196 | | - xmlns="http://www.w3.org/2000/svg" |
197 | | - width="16" |
198 | | - height="16" |
199 | | - viewBox="0 0 16 16" |
200 | | - fill="none" |
201 | | - aria-hidden="true" |
202 | | - > |
203 | | - <path |
204 | | - d="M7.75756 14.3L10.5816 6.91667H11.8759L14.7 14.3H13.4057L12.7501 12.4167H9.74113L9.06873 14.3H7.75756ZM10.1109 11.35H12.3467L11.254 8.3H11.2036L10.1109 11.35ZM2.84908 12.45L1.97498 11.5833L5.11841 8.48333C4.72618 8.05 4.38439 7.60267 4.09302 7.14133C3.80165 6.68044 3.54389 6.19444 3.31976 5.68333H4.61412C4.80463 6.06111 5.00635 6.39711 5.21927 6.69133C5.43219 6.986 5.68434 7.29444 5.97571 7.61667C6.43519 7.12778 6.81621 6.62511 7.11879 6.10867C7.42137 5.59178 7.67352 5.03889 7.87523 4.45H1V3.23333H5.33694V2H6.58087V3.23333H10.9178V4.45H9.11916C8.89503 5.18333 8.59805 5.89155 8.22824 6.57467C7.85842 7.25822 7.39895 7.90555 6.84983 8.51667L8.3459 10.0167L7.87523 11.2833L5.95891 9.38333L2.84908 12.45Z" |
205 | | - fill="currentColor" |
206 | | - /> |
207 | | - </svg> |
208 | | - </> |
209 | | - } |
210 | | - items={localeItems} |
211 | | - position="right" |
212 | | - className="navbar-next__locale-dropdown" |
213 | | - aria-label={localeSwitchLabel} |
214 | | - /> |
215 | | - )} |
216 | 169 | <a |
217 | 170 | href={`https://github.com/${GITHUB_REPO}`} |
218 | 171 | target="_blank" |
@@ -281,33 +234,6 @@ export function NavbarNext(): JSX.Element { |
281 | 234 | </div> |
282 | 235 |
|
283 | 236 | <div className="navbar-next__mobile-actions"> |
284 | | - {showLocaleSwitcher && ( |
285 | | - <DropdownNavbarItem |
286 | | - mobile={false} |
287 | | - label={ |
288 | | - <> |
289 | | - <svg |
290 | | - className="icon-language navbar-next__locale-icon" |
291 | | - xmlns="http://www.w3.org/2000/svg" |
292 | | - width="16" |
293 | | - height="16" |
294 | | - viewBox="0 0 16 16" |
295 | | - fill="none" |
296 | | - aria-hidden="true" |
297 | | - > |
298 | | - <path |
299 | | - d="M7.75756 14.3L10.5816 6.91667H11.8759L14.7 14.3H13.4057L12.7501 12.4167H9.74113L9.06873 14.3H7.75756ZM10.1109 11.35H12.3467L11.254 8.3H11.2036L10.1109 11.35ZM2.84908 12.45L1.97498 11.5833L5.11841 8.48333C4.72618 8.05 4.38439 7.60267 4.09302 7.14133C3.80165 6.68044 3.54389 6.19444 3.31976 5.68333H4.61412C4.80463 6.06111 5.00635 6.39711 5.21927 6.69133C5.43219 6.986 5.68434 7.29444 5.97571 7.61667C6.43519 7.12778 6.81621 6.62511 7.11879 6.10867C7.42137 5.59178 7.67352 5.03889 7.87523 4.45H1V3.23333H5.33694V2H6.58087V3.23333H10.9178V4.45H9.11916C8.89503 5.18333 8.59805 5.89155 8.22824 6.57467C7.85842 7.25822 7.39895 7.90555 6.84983 8.51667L8.3459 10.0167L7.87523 11.2833L5.95891 9.38333L2.84908 12.45Z" |
300 | | - fill="currentColor" |
301 | | - /> |
302 | | - </svg> |
303 | | - </> |
304 | | - } |
305 | | - items={localeItems} |
306 | | - position="right" |
307 | | - className="navbar-next__locale-dropdown" |
308 | | - aria-label={localeSwitchLabel} |
309 | | - /> |
310 | | - )} |
311 | 237 | <a |
312 | 238 | href={`https://github.com/${GITHUB_REPO}`} |
313 | 239 | target="_blank" |
|
0 commit comments