docs: 🐛 disable authentication for algolia docsearch crawler

Signed-off-by: jffarge <jf@dagger.io>
This commit is contained in:
jffarge 2021-06-29 22:44:44 +02:00
parent 0ba7c1fb44
commit 1854cce64e

View File

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