From 15648e42aca986b145cc158e896292c4e94dc243 Mon Sep 17 00:00:00 2001 From: jffarge Date: Tue, 7 Sep 2021 11:34:59 +0200 Subject: [PATCH] update docusaurus to v2.0.0-beta.5 Signed-off-by: jffarge --- website/cypress/integration/docs.spec.js | 2 +- website/docsearch.config.json | 7 +- website/docusaurus.config.js | 1 - website/package.json | 4 +- website/src/css/custom.scss | 33 +- website/src/theme/DocPage/index.js | 53 +-- website/src/theme/DocPage/styles.module.css | 11 +- website/src/theme/Navbar/index.js | 246 +++++++--- website/src/theme/Navbar/styles.module.css | 7 +- website/src/theme/Toggle/index.js | 57 +-- website/src/theme/Toggle/styles.css | 100 ++++ website/src/theme/Toggle/styles.module.css | 94 ---- website/yarn.lock | 486 +++++++------------- 13 files changed, 541 insertions(+), 560 deletions(-) create mode 100644 website/src/theme/Toggle/styles.css diff --git a/website/cypress/integration/docs.spec.js b/website/cypress/integration/docs.spec.js index 8f03fdd3..3fd066bc 100644 --- a/website/cypress/integration/docs.spec.js +++ b/website/cypress/integration/docs.spec.js @@ -23,7 +23,7 @@ describe('Visit Docs website', function() { it('log to amplitude when user visit another page', function() { cy.get('[data-cy=cy-doc-content]').should('exist') - cy.get('.menu > :nth-child(2) > :nth-child(2) > .menu__link').click() + cy.get('ul.menu__list:nth-child(1) > li:nth-child(2)').click() }) }) diff --git a/website/docsearch.config.json b/website/docsearch.config.json index 3b083b8a..82eb41f5 100644 --- a/website/docsearch.config.json +++ b/website/docsearch.config.json @@ -1,9 +1,10 @@ { "index_name": "Dagger_docs", - "start_urls": ["https://docs.dagger.io/", "https://devel.docs.dagger.io/"], + "start_urls": [ + "https://deploy-preview-929--devel-docs-dagger-io.netlify.app/" + ], "sitemap_urls": [ - "https://docs.dagger.io/sitemap.xml", - "https://devel.docs.dagger.io/sitemap.xml" + "https://deploy-preview-929--devel-docs-dagger-io.netlify.app/sitemap.xml" ], "sitemap_alternate_links": true, "stop_urls": [], diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 2253de8e..24f04e3a 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -16,7 +16,6 @@ module.exports = { "https://fonts.googleapis.com/css2?family=Karla&family=Poppins:wght@700&display=swap", ], themeConfig: { - sidebarCollapsible: true, sidebarCollapsed: false, prism: { theme: require("prism-react-renderer/themes/okaidia"), diff --git a/website/package.json b/website/package.json index 21f6c033..c7fc3571 100644 --- a/website/package.json +++ b/website/package.json @@ -18,8 +18,8 @@ "ci": "start-server-and-test 'yarn start-server' '3000|3001' 'yarn run cypress run'" }, "dependencies": { - "@docusaurus/core": "2.0.0-beta.4", - "@docusaurus/preset-classic": "2.0.0-beta.2", + "@docusaurus/core": "^2.0.0-beta.5", + "@docusaurus/preset-classic": "^2.0.0-beta.5", "@mdx-js/react": "^1.6.21", "@svgr/webpack": "^5.5.0", "amplitude-js": "^8.5.0", diff --git a/website/src/css/custom.scss b/website/src/css/custom.scss index 8032a0e6..47406518 100644 --- a/website/src/css/custom.scss +++ b/website/src/css/custom.scss @@ -33,9 +33,8 @@ $desktop-xl-width: 1160px; --ifm-background-color: var(--ifm-color-primary-light); --ifm-code-background: var(--ifm-color-primary-dark); --ifm-code-font-size: 100%; - --ifm-code-border-radius: 2rem; --ifm-code-color: var(--ifm-color-primary-light); - --ifm-code-padding-vertical: 0; + --ifm-code-padding-vertical: 0.05rem; --ifm-code-padding-horizontal: 0.2rem; --ifm-color-primary: #0e2b3d; --ifm-color-primary-dark: #131226; @@ -143,6 +142,16 @@ code { } } } + + li { + font-size: 18px; + } + + img { + max-width: 500px; + display: block; + margin: auto; + } } p { @@ -236,6 +245,14 @@ h1[class^="h1Heading"] { .navbar { align-self: center; box-shadow: none; + width: 100%; +} + +.navbar-sidebar__back { + background: transparent; + color: white; + padding: 1rem 0; + text-align: center; } .navbar__item { @@ -336,7 +353,6 @@ html[data-theme="dark"] .table-of-contents__link { /* codeBlock */ div[class^="codeBlockContainer"] { - border-radius: var(--ifm-code-border-radius); margin-bottom: 2.5rem; div[class^="codeBlockTitle"] { @@ -466,6 +482,7 @@ button[class^="copyButton"] { &--active:not(.menu__link--sublist) { background-color: var(--ifm-color-primary); color: var(--ifm-color-primary-light); + font-weight: bold; html[data-theme="dark"] & { background-color: var(--ifm-menu-color-background-hover); @@ -490,6 +507,8 @@ button[class^="copyButton"] { &.menu__link--sublist { color: var(--ifm-color-primary-dark); + padding-right: 2rem; + margin-bottom: 0; &:active, &:focus { @@ -511,6 +530,14 @@ button[class^="copyButton"] { } } } + + &--sublist { + margin-bottom: 0; + } + + &--sublist::after { + margin-left: auto; + } } /* docsearch */ diff --git a/website/src/theme/DocPage/index.js b/website/src/theme/DocPage/index.js index 99835f95..eaa6b371 100644 --- a/website/src/theme/DocPage/index.js +++ b/website/src/theme/DocPage/index.js @@ -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 (
+ + {sidebar && (