Merge pull request #1413 from slumbering/bump-docusaurus-beta.14

[Docs] Update docusaurus to beta-14
This commit is contained in:
Jffarge 2022-01-13 16:15:27 +01:00 committed by GitHub
commit 5bfb27a98c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1462 additions and 600 deletions

View File

@ -70,10 +70,6 @@ module.exports = {
lightIcon: "img/Icon_Day-mode.svg", lightIcon: "img/Icon_Day-mode.svg",
}, },
}, },
gtag: {
trackingID: "G-RDXG80F635",
anonymizeIP: true,
},
}, },
presets: [ presets: [
[ [
@ -82,10 +78,14 @@ module.exports = {
docs: { docs: {
path: "../docs", path: "../docs",
sidebarPath: require.resolve("./sidebars.js"), sidebarPath: require.resolve("./sidebars.js"),
editUrl: "https://github.com/dagger/dagger/blob/main", editUrl: "https://github.com/dagger/dagger/edit/main/website",
routeBasePath: "/", routeBasePath: "/",
remarkPlugins: [remarkCodeImport], remarkPlugins: [remarkCodeImport],
}, },
gtag: {
trackingID: "G-RDXG80F635",
anonymizeIP: true,
},
theme: { theme: {
customCss: require.resolve("./src/css/custom.scss"), customCss: require.resolve("./src/css/custom.scss"),
}, },

View File

@ -18,8 +18,8 @@
"ci": "start-server-and-test 'yarn start-server' '3000|3001' 'yarn run cypress run'" "ci": "start-server-and-test 'yarn start-server' '3000|3001' 'yarn run cypress run'"
}, },
"dependencies": { "dependencies": {
"@docusaurus/core": "^2.0.0-beta.9", "@docusaurus/core": "^2.0.0-beta.14",
"@docusaurus/preset-classic": "^2.0.0-beta.9", "@docusaurus/preset-classic": "^2.0.0-beta.14",
"@mdx-js/react": "^1.6.21", "@mdx-js/react": "^1.6.21",
"@svgr/webpack": "^5.5.0", "@svgr/webpack": "^5.5.0",
"amplitude-js": "^8.15.0", "amplitude-js": "^8.15.0",

View File

@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
import React, {useState, useCallback, useEffect} from 'react'; import React, {useState, useEffect, useCallback} from 'react';
import {MDXProvider} from '@mdx-js/react'; import {MDXProvider} from '@mdx-js/react';
import renderRoutes from '@docusaurus/renderRoutes'; import renderRoutes from '@docusaurus/renderRoutes';
import Layout from '@theme/Layout'; import Layout from '@theme/Layout';
@ -17,16 +17,25 @@ import {matchPath} from '@docusaurus/router';
import {translate} from '@docusaurus/Translate'; import {translate} from '@docusaurus/Translate';
import clsx from 'clsx'; import clsx from 'clsx';
import styles from './styles.module.css'; import styles from './styles.module.css';
import {ThemeClassNames, docVersionSearchTag} from '@docusaurus/theme-common'; import {
ThemeClassNames,
docVersionSearchTag,
DocsSidebarProvider,
useDocsSidebar,
DocsVersionProvider,
} from '@docusaurus/theme-common';
import Head from '@docusaurus/Head';
import DocPageCustom from "../../components/DocPageCustom" import DocPageCustom from "../../components/DocPageCustom"
import amplitude from 'amplitude-js'; import amplitude from 'amplitude-js';
function DocPageContent({currentDocRoute, versionMetadata, children}) { function DocPageContent({
currentDocRoute,
versionMetadata,
children,
sidebarName,
}) {
const sidebar = useDocsSidebar();
const {pluginId, version} = versionMetadata; const {pluginId, version} = versionMetadata;
const sidebarName = currentDocRoute.sidebar;
const sidebar = sidebarName
? versionMetadata.docsSidebars[sidebarName]
: undefined;
const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false); const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
const [hiddenSidebar, setHiddenSidebar] = useState(false); const [hiddenSidebar, setHiddenSidebar] = useState(false);
const toggleSidebar = useCallback(() => { const toggleSidebar = useCallback(() => {
@ -34,13 +43,13 @@ function DocPageContent({currentDocRoute, versionMetadata, children}) {
setHiddenSidebar(false); setHiddenSidebar(false);
} }
setHiddenSidebarContainer(!hiddenSidebarContainer); setHiddenSidebarContainer((value) => !value);
}, [hiddenSidebar]); }, [hiddenSidebar]);
return ( return (
<Layout <Layout
wrapperClassName={ThemeClassNames.wrapper.docPages} wrapperClassName={ThemeClassNames.wrapper.docsPages}
pageClassName={ThemeClassNames.page.docsDocPage} pageClassName={ThemeClassNames.page.docsDocPage}
searchMetadatas={{ searchMetadata={{
version, version,
tag: docVersionSearchTag(pluginId, version), tag: docVersionSearchTag(pluginId, version),
}}> }}>
@ -130,7 +139,7 @@ function DocPage(props) {
matchPath(location.pathname, docRoute), matchPath(location.pathname, docRoute),
); );
// DocPage Swizzle // DocPage Swizzle
const [userAccessStatus, setUserAccessStatus] = useState( const [userAccessStatus, setUserAccessStatus] = useState(
(() => { (() => {
if (typeof window !== 'undefined') if (typeof window !== 'undefined')
@ -157,19 +166,34 @@ function DocPage(props) {
// End DocPageSwizzle // End DocPageSwizzle
if (!currentDocRoute) { if (!currentDocRoute) {
return <NotFound {...props} />; return <NotFound />;
} } // For now, the sidebarName is added as route config: not ideal!
const sidebarName = currentDocRoute.sidebar;
const sidebar = sidebarName
? versionMetadata.docsSidebars[sidebarName]
: null;
return ( return (
<DocPageContent <>
currentDocRoute={currentDocRoute} <Head>
versionMetadata={versionMetadata}> {/* TODO we should add a core addRoute({htmlClassName}) generic plugin option */}
<div data-cy="cy-doc-content"> <html className={versionMetadata.className} />
{renderRoutes(docRoutes, { </Head>
versionMetadata, <DocsVersionProvider version={versionMetadata}>
})} <DocsSidebarProvider sidebar={sidebar}>
</div> <DocPageContent
</DocPageContent> currentDocRoute={currentDocRoute}
versionMetadata={versionMetadata}
sidebarName={sidebarName}>
<div data-cy="cy-doc-content">
{renderRoutes(docRoutes, {
versionMetadata,
})}
</div>
</DocPageContent>
</DocsSidebarProvider>
</DocsVersionProvider>
</>
); );
} }

File diff suppressed because it is too large Load Diff