mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-08 05:42:34 +02:00
fix(v2): fix navigation from homepage (#4136)
This commit is contained in:
parent
30c8e26a31
commit
39edfe35aa
1 changed files with 1 additions and 15 deletions
|
@ -5,7 +5,7 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, {useLayoutEffect} from 'react';
|
import React from 'react';
|
||||||
import {useLocation} from 'react-router-dom';
|
import {useLocation} from 'react-router-dom';
|
||||||
|
|
||||||
import Head from '../exports/Head';
|
import Head from '../exports/Head';
|
||||||
|
@ -63,19 +63,6 @@ document.addEventListener('DOMContentLoaded', renderBanner);
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normally if the baseUrl is correct, the banner will already be hidden by the critical CSS
|
|
||||||
// But we can still remove it totally from the DOM if it's not useful anymore
|
|
||||||
// This is kind of a "double security"
|
|
||||||
// It can also prevent the banner to appear if the CSS fails to load due to some network error
|
|
||||||
function useBannerRemover() {
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
const banner = document.getElementById(BannerContainerId);
|
|
||||||
if (banner) {
|
|
||||||
banner.remove();
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
}
|
|
||||||
|
|
||||||
function BaseUrlIssueBannerEnabled() {
|
function BaseUrlIssueBannerEnabled() {
|
||||||
const {
|
const {
|
||||||
siteConfig: {baseUrl},
|
siteConfig: {baseUrl},
|
||||||
|
@ -100,7 +87,6 @@ export default function BaseUrlIssueBanner(): JSX.Element | null {
|
||||||
siteConfig: {baseUrl, baseUrlIssueBanner},
|
siteConfig: {baseUrl, baseUrlIssueBanner},
|
||||||
} = useDocusaurusContext();
|
} = useDocusaurusContext();
|
||||||
const {pathname} = useLocation();
|
const {pathname} = useLocation();
|
||||||
useBannerRemover();
|
|
||||||
|
|
||||||
// returns true for the homepage during SRR
|
// returns true for the homepage during SRR
|
||||||
const isHomePage = pathname === baseUrl;
|
const isHomePage = pathname === baseUrl;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue