update docusaurus to v2.0.0-beta.5
Signed-off-by: jffarge <jf@dagger.io>
This commit is contained in:
@@ -4,54 +4,28 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import React, { useState, useCallback, useEffect } from 'react';
|
||||
import { MDXProvider } from '@mdx-js/react';
|
||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||
import React, {useState, useCallback, useEffect} from 'react';
|
||||
import {MDXProvider} from '@mdx-js/react';
|
||||
import renderRoutes from '@docusaurus/renderRoutes';
|
||||
import Layout from '@theme/Layout';
|
||||
import DocSidebar from '@theme/DocSidebar';
|
||||
import MDXComponents from '@theme/MDXComponents';
|
||||
import NotFound from '@theme/NotFound';
|
||||
import IconArrow from '@theme/IconArrow';
|
||||
import BackToTopButton from '@theme/BackToTopButton';
|
||||
import {matchPath} from '@docusaurus/router';
|
||||
import {translate} from '@docusaurus/Translate';
|
||||
import clsx from 'clsx';
|
||||
import styles from './styles.module.css';
|
||||
import {ThemeClassNames, docVersionSearchTag} from '@docusaurus/theme-common';
|
||||
import DocPageCustom from '../../components/DocPageCustom';
|
||||
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
||||
|
||||
function getSidebar({versionMetadata, currentDocRoute}) {
|
||||
function addTrailingSlash(str) {
|
||||
return str.endsWith('/') ? str : `${str}/`;
|
||||
}
|
||||
|
||||
function removeTrailingSlash(str) {
|
||||
return str.endsWith('/') ? str.slice(0, -1) : str;
|
||||
}
|
||||
|
||||
const {permalinkToSidebar, docsSidebars} = versionMetadata; // With/without trailingSlash, we should always be able to get the appropriate sidebar
|
||||
// note: docs plugin permalinks currently never have trailing slashes
|
||||
// trailingSlash is handled globally at the framework level, not plugin level
|
||||
|
||||
const sidebarName =
|
||||
permalinkToSidebar[currentDocRoute.path] ||
|
||||
permalinkToSidebar[addTrailingSlash(currentDocRoute.path)] ||
|
||||
permalinkToSidebar[removeTrailingSlash(currentDocRoute.path)];
|
||||
const sidebar = docsSidebars[sidebarName];
|
||||
return {
|
||||
sidebar,
|
||||
sidebarName,
|
||||
};
|
||||
}
|
||||
import DocPageCustom from "../../components/DocPageCustom"
|
||||
|
||||
function DocPageContent({currentDocRoute, versionMetadata, children}) {
|
||||
const {siteConfig, isClient} = useDocusaurusContext();
|
||||
const {pluginId, version} = versionMetadata;
|
||||
const {sidebarName, sidebar} = getSidebar({
|
||||
versionMetadata,
|
||||
currentDocRoute,
|
||||
});
|
||||
const sidebarName = currentDocRoute.sidebar;
|
||||
const sidebar = sidebarName
|
||||
? versionMetadata.docsSidebars[sidebarName]
|
||||
: undefined;
|
||||
const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
|
||||
const [hiddenSidebar, setHiddenSidebar] = useState(false);
|
||||
const toggleSidebar = useCallback(() => {
|
||||
@@ -63,14 +37,15 @@ function DocPageContent({currentDocRoute, versionMetadata, children}) {
|
||||
}, [hiddenSidebar]);
|
||||
return (
|
||||
<Layout
|
||||
key={isClient}
|
||||
wrapperClassName={ThemeClassNames.wrapper.docPages}
|
||||
pageClassName={ThemeClassNames.page.docPage}
|
||||
pageClassName={ThemeClassNames.page.docsDocPage}
|
||||
searchMetadatas={{
|
||||
version,
|
||||
tag: docVersionSearchTag(pluginId, version),
|
||||
}}>
|
||||
<div className={styles.docPage}>
|
||||
<BackToTopButton />
|
||||
|
||||
{sidebar && (
|
||||
<aside
|
||||
className={clsx(styles.docSidebarContainer, {
|
||||
@@ -95,9 +70,6 @@ function DocPageContent({currentDocRoute, versionMetadata, children}) {
|
||||
}
|
||||
sidebar={sidebar}
|
||||
path={currentDocRoute.path}
|
||||
sidebarCollapsible={
|
||||
siteConfig.themeConfig?.sidebarCollapsible ?? true
|
||||
}
|
||||
onCollapse={toggleSidebar}
|
||||
isHidden={hiddenSidebar}
|
||||
/>
|
||||
@@ -156,7 +128,6 @@ function DocPage(props) {
|
||||
const currentDocRoute = docRoutes.find((docRoute) =>
|
||||
matchPath(location.pathname, docRoute),
|
||||
);
|
||||
const userAgent = ExecutionEnvironment.canUseDOM ? navigator.userAgent : null;
|
||||
|
||||
// DocPage Swizzle
|
||||
const [userAccessStatus, setUserAccessStatus] = useState(
|
||||
@@ -181,7 +152,7 @@ function DocPage(props) {
|
||||
})
|
||||
}, [location.pathname, userAccessStatus])
|
||||
|
||||
if (process.env.OAUTH_ENABLE == 'true' && userAccessStatus?.permission !== true && userAgent !== 'Algolia DocSearch Crawler') {
|
||||
if (process.env.OAUTH_ENABLE == 'true' && userAccessStatus?.permission !== true) {
|
||||
return <DocPageCustom location={location} userAccessStatus={userAccessStatus} setUserAccessStatus={setUserAccessStatus} />
|
||||
}
|
||||
// End DocPageSwizzle
|
||||
|
Reference in New Issue
Block a user