Merge pull request #755 from slumbering/docsearch-crawler

disable authentication for algolia docsearch crawler
This commit is contained in:
Andrea Luzzardi 2021-06-30 11:44:46 +02:00 committed by GitHub
commit f24aed1dd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,6 +26,7 @@ import { GithubLoginButton } from 'react-social-login-buttons';
import Spinner from '../../components/Spinner';
import DocPageAuthentication from '../../components/DocPageAuthentication';
import DocPageRedirect from '../../components/DocPageRedirect';
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
function DocPageContent({ currentDocRoute, versionMetadata, children }) {
const { siteConfig, isClient } = useDocusaurusContext();
@ -138,9 +139,10 @@ function DocPage(props) {
const currentDocRoute = docRoutes.find((docRoute) =>
matchPath(location.pathname, docRoute),
);
const userAgent = ExecutionEnvironment.canUseDOM ? navigator.userAgent : null;
// CUSTOM DOCPAGE
if (process.env.OAUTH_ENABLE == 'true') {
if (process.env.OAUTH_ENABLE == 'true' && userAgent !== 'Algolia DocSearch Crawler') {
const [isLoading, setIsLoading] = useState(true)
const [redirectState, setRedirectState] = useState()
const authQuery = qs.parse(location.search);