diff --git a/package.json b/package.json index fa46ef2703..cf4ce7e090 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "build:website:baseUrl": "yarn workspace website build:baseUrl", "build:website:blogOnly": "yarn workspace website build:blogOnly", "build:website:deployPreview": "cross-env NETLIFY=true CONTEXT='deploy-preview' yarn workspace website build", + "build:website:fast": "yarn workspace website build:fast", "build:website:en": "yarn workspace website build --locale en", "clear:website": "yarn workspace website clear", "serve:website": "yarn workspace website serve", diff --git a/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.tsx b/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.tsx index 1a0e7e2b86..bd7d49ac24 100644 --- a/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/CodeBlock/index.tsx @@ -101,7 +101,7 @@ const highlightDirectiveRegex = (lang: string) => { export default function CodeBlock({ children, - className: languageClassName, + className: blockClassName, metastring, title, }: Props): JSX.Element { @@ -141,6 +141,9 @@ export default function CodeBlock({ highlightLines = rangeParser(highlightLinesRange).filter((n) => n > 0); } + const languageClassName = blockClassName + ?.split(' ') + .find((str) => str.startsWith('language-')); let language = languageClassName?.replace(/language-/, '') as Language; if (!language && prism.defaultLanguage) { @@ -209,7 +212,11 @@ export default function CodeBlock({ code={code} language={language}> {({className, style, tokens, getLineProps, getTokenProps}) => ( -
+
{codeBlockTitle && (
{codeBlockTitle} diff --git a/packages/docusaurus-theme-live-codeblock/src/theme/Playground/index.js b/packages/docusaurus-theme-live-codeblock/src/theme/Playground/index.js index 2b35c04b51..92ee17f67d 100644 --- a/packages/docusaurus-theme-live-codeblock/src/theme/Playground/index.js +++ b/packages/docusaurus-theme-live-codeblock/src/theme/Playground/index.js @@ -10,14 +10,20 @@ import {LiveProvider, LiveEditor, LiveError, LivePreview} from 'react-live'; import clsx from 'clsx'; import Translate from '@docusaurus/Translate'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; -import useIsBrowser from '@docusaurus/useIsBrowser'; +import BrowserOnly from '@docusaurus/BrowserOnly'; import usePrismTheme from '@theme/hooks/usePrismTheme'; import styles from './styles.module.css'; +import useIsBrowser from '@docusaurus/core/lib/client/exports/useIsBrowser'; function Header({children}) { return
{children}
; } +function LivePreviewLoader() { + // Is it worth improving/translating? + return
Loading...
; +} + function ResultWithHeader() { return ( <> @@ -28,14 +34,33 @@ function ResultWithHeader() { Result + {/* https://github.com/facebook/docusaurus/issues/5747 */}
- - + }> + {() => ( + <> + + + + )} +
); } +function ThemedLiveEditor() { + const isBrowser = useIsBrowser(); + return ( + + ); +} + function EditorWithHeader() { return ( <> @@ -46,13 +71,12 @@ function EditorWithHeader() { Live Editor - + ); } export default function Playground({children, transformCode, ...props}) { - const isBrowser = useIsBrowser(); const { siteConfig: { themeConfig: { @@ -65,8 +89,7 @@ export default function Playground({children, transformCode, ...props}) { return (
`${code};`)} theme={prismTheme} {...props}> diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 5789a7b237..722563564d 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -38,6 +38,9 @@ const isDev = process.env.NODE_ENV === 'development'; const isDeployPreview = process.env.NETLIFY && process.env.CONTEXT === 'deploy-preview'; +// Used to debug production build issues faster +const isBuildFast = !!process.env.BUILD_FAST; + const baseUrl = process.env.BASE_URL || '/'; // Special deployment for staging locales until they get enough translations @@ -252,10 +255,11 @@ const config = { rehypePlugins: [katex], disableVersioning: isVersioningDisabled, lastVersion: isDev ? 'current' : undefined, - onlyIncludeVersions: - !isVersioningDisabled && (isDev || isDeployPreview) - ? ['current', ...versions.slice(0, 2)] - : undefined, + onlyIncludeVersions: isBuildFast + ? ['current'] + : !isVersioningDisabled && (isDev || isDeployPreview) + ? ['current', ...versions.slice(0, 2)] + : undefined, versions: { current: { label: `${getNextBetaVersionName()} 🚧`, diff --git a/website/package.json b/website/package.json index 493097b44b..67c76bd829 100644 --- a/website/package.json +++ b/website/package.json @@ -16,6 +16,7 @@ "build:baseUrl": "cross-env BASE_URL='/build/' yarn build", "start:blogOnly": "cross-env yarn start --config=docusaurus.config-blog-only.js", "build:blogOnly": "cross-env yarn build --config=docusaurus.config-blog-only.js", + "build:fast": "cross-env BUILD_FAST=true yarn build --locale en", "netlify:build:production": "yarn docusaurus write-translations && yarn netlify:crowdin:delay && yarn netlify:crowdin:uploadSources && yarn netlify:crowdin:downloadTranslations && yarn build", "netlify:build:deployPreview": "yarn docusaurus write-translations --locale fr --messagePrefix '(fr) ' && yarn build", "netlify:crowdin:delay": "node delayCrowdin.js",