Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/css/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ $primary: #0033ff;
opacity: 0.75;
}

.navbar__link.bi-translate {
.bi-translate {
svg {
display: none;
}
}
.navbar__link.bi::before {
.bi-translate::before {
font-size: 24px;
margin-right: 0.25rem;;
}
Expand Down
21 changes: 13 additions & 8 deletions src/theme/NavbarItem/NavbarNavLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import React, { useEffect } from 'react';
import Link from '@docusaurus/Link';
import useBaseUrl from '@docusaurus/useBaseUrl';
import isInternalUrl from '@docusaurus/isInternalUrl';
Expand Down Expand Up @@ -40,11 +40,18 @@ export default function NavbarNavLink({
const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
const isExternalLink = label && href && !isInternalUrl(href);

const clickLink = (e) => {
if (e.target?.lang) {
localStorage.setItem('_lang_user_', e.target.lang);
}
}
useEffect(() => {
const handleClick = (event) => {
if (event.target.tagName === 'A' && event.target.lang) {
localStorage.setItem('_lang_user_', event.target.lang);
}
};
document.addEventListener('click', handleClick);

return () => {
document.removeEventListener('click', handleClick);
};
}, [])

// Link content is set through html XOR label
const linkContentProps = html
Expand All @@ -68,7 +75,6 @@ export default function NavbarNavLink({
href={prependBaseUrlToHref ? normalizedHref : href}
{...props}
{...linkContentProps}
onClick={clickLink}
/>
);
}
Expand All @@ -85,7 +91,6 @@ export default function NavbarNavLink({
})}
{...props}
{...linkContentProps}
onClick={clickLink}
/>
);
}