@docusaurus/theme-classic 0.0.0-4342 → 0.0.0-4351

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -107,13 +107,14 @@ declare module '@theme/BlogLayout' {
107
107
  }
108
108
 
109
109
  declare module '@theme/CodeBlock' {
110
- import {ReactElement} from 'react';
110
+ import type {ReactElement} from 'react';
111
111
 
112
112
  export interface Props {
113
113
  readonly children: string | ReactElement;
114
114
  readonly className?: string;
115
115
  readonly metastring?: string;
116
116
  readonly title?: string;
117
+ readonly language?: string;
117
118
  }
118
119
 
119
120
  const CodeBlock: (props: Props) => JSX.Element;
@@ -181,7 +182,7 @@ declare module '@theme/EditThisPage' {
181
182
  }
182
183
 
183
184
  declare module '@theme/ErrorPageContent' {
184
- import ErrorComponent from '@theme/Error';
185
+ import type ErrorComponent from '@theme/Error';
185
186
 
186
187
  const ErrorPageContent: typeof ErrorComponent;
187
188
  export default ErrorPageContent;
@@ -219,7 +220,7 @@ declare module '@theme/hooks/useLockBodyScroll' {
219
220
  }
220
221
 
221
222
  declare module '@theme/hooks/usePrismTheme' {
222
- import defaultTheme from 'prism-react-renderer/themes/palenight';
223
+ import type defaultTheme from 'prism-react-renderer/themes/palenight';
223
224
 
224
225
  const usePrismTheme: () => typeof defaultTheme;
225
226
  export default usePrismTheme;
@@ -581,7 +582,7 @@ declare module '@theme/ThemedImage' {
581
582
  }
582
583
 
583
584
  declare module '@theme/Details' {
584
- import {Details, DetailsProps} from '@docusaurus/theme-common';
585
+ import {Details, type DetailsProps} from '@docusaurus/theme-common';
585
586
 
586
587
  export interface Props extends DetailsProps {}
587
588
  export default Details;
@@ -20,9 +20,10 @@ import usePrismTheme from '@theme/hooks/usePrismTheme';
20
20
  import styles from './styles.module.css';
21
21
  export default function CodeBlock({
22
22
  children,
23
- className: blockClassName,
23
+ className: blockClassName = '',
24
24
  metastring,
25
25
  title,
26
+ language: languageProp,
26
27
  }) {
27
28
  const {prism} = useThemeConfig();
28
29
  const [showCopied, setShowCopied] = useState(false);
@@ -73,7 +74,8 @@ export default function CodeBlock({
73
74
  } // The children is now guaranteed to be one/more plain strings
74
75
 
75
76
  const content = Array.isArray(children) ? children.join('') : children;
76
- const language = parseLanguage(blockClassName) ?? prism.defaultLanguage;
77
+ const language =
78
+ languageProp ?? parseLanguage(blockClassName) ?? prism.defaultLanguage;
77
79
  const {highlightLines, code} = parseLines(content, metastring, language);
78
80
 
79
81
  const handleCopyCode = () => {
@@ -94,6 +96,10 @@ export default function CodeBlock({
94
96
  className={clsx(
95
97
  styles.codeBlockContainer,
96
98
  blockClassName,
99
+ {
100
+ [`language-${language}`]:
101
+ language && !blockClassName.includes(`language-${language}`),
102
+ },
97
103
  ThemeClassNames.common.codeBlock,
98
104
  )}>
99
105
  {codeBlockTitle && (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4342",
3
+ "version": "0.0.0-4351",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -23,14 +23,14 @@
23
23
  "update-code-translations": "node -e 'require(\"./update-code-translations.js\").run()'"
24
24
  },
25
25
  "dependencies": {
26
- "@docusaurus/core": "0.0.0-4342",
27
- "@docusaurus/plugin-content-blog": "0.0.0-4342",
28
- "@docusaurus/plugin-content-docs": "0.0.0-4342",
29
- "@docusaurus/plugin-content-pages": "0.0.0-4342",
30
- "@docusaurus/theme-common": "0.0.0-4342",
31
- "@docusaurus/theme-translations": "0.0.0-4342",
32
- "@docusaurus/utils": "0.0.0-4342",
33
- "@docusaurus/utils-validation": "0.0.0-4342",
26
+ "@docusaurus/core": "0.0.0-4351",
27
+ "@docusaurus/plugin-content-blog": "0.0.0-4351",
28
+ "@docusaurus/plugin-content-docs": "0.0.0-4351",
29
+ "@docusaurus/plugin-content-pages": "0.0.0-4351",
30
+ "@docusaurus/theme-common": "0.0.0-4351",
31
+ "@docusaurus/theme-translations": "0.0.0-4351",
32
+ "@docusaurus/utils": "0.0.0-4351",
33
+ "@docusaurus/utils-validation": "0.0.0-4351",
34
34
  "@mdx-js/mdx": "^1.6.21",
35
35
  "@mdx-js/react": "^1.6.21",
36
36
  "clsx": "^1.1.1",
@@ -45,8 +45,8 @@
45
45
  "rtlcss": "^3.3.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@docusaurus/module-type-aliases": "0.0.0-4342",
49
- "@docusaurus/types": "0.0.0-4342",
48
+ "@docusaurus/module-type-aliases": "0.0.0-4351",
49
+ "@docusaurus/types": "0.0.0-4351",
50
50
  "@types/mdx-js__react": "^1.5.4",
51
51
  "@types/parse-numeric-range": "^0.0.1",
52
52
  "@types/rtlcss": "^3.1.1",
@@ -61,5 +61,5 @@
61
61
  "engines": {
62
62
  "node": ">=14"
63
63
  },
64
- "gitHead": "e9ef727d5f5fefa96d92ad98fa61f3e3e961dd1d"
64
+ "gitHead": "6633ee41d0b5c670e9e4c18fb6ddd9c8bb05a41b"
65
65
  }
package/src/index.ts CHANGED
@@ -5,7 +5,11 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import {DocusaurusContext, Plugin, PostCssOptions} from '@docusaurus/types';
8
+ import type {
9
+ DocusaurusContext,
10
+ Plugin,
11
+ PostCssOptions,
12
+ } from '@docusaurus/types';
9
13
  import type {ThemeConfig} from '@docusaurus/theme-common';
10
14
  import {getTranslationFiles, translateThemeConfig} from './translations';
11
15
  import path from 'path';
@@ -7,7 +7,7 @@
7
7
 
8
8
  import React from 'react';
9
9
  import clsx from 'clsx';
10
- import {Props} from '@theme/Admonition';
10
+ import type {Props} from '@theme/Admonition';
11
11
 
12
12
  const icons = {
13
13
  note: (
@@ -7,7 +7,7 @@
7
7
 
8
8
  import React, {isValidElement, useEffect, useState} from 'react';
9
9
  import clsx from 'clsx';
10
- import Highlight, {defaultProps, Language} from 'prism-react-renderer';
10
+ import Highlight, {defaultProps, type Language} from 'prism-react-renderer';
11
11
  import copy from 'copy-text-to-clipboard';
12
12
  import Translate, {translate} from '@docusaurus/Translate';
13
13
  import {
@@ -24,9 +24,10 @@ import styles from './styles.module.css';
24
24
 
25
25
  export default function CodeBlock({
26
26
  children,
27
- className: blockClassName,
27
+ className: blockClassName = '',
28
28
  metastring,
29
29
  title,
30
+ language: languageProp,
30
31
  }: Props): JSX.Element {
31
32
  const {prism} = useThemeConfig();
32
33
 
@@ -85,8 +86,7 @@ export default function CodeBlock({
85
86
  : (children as string);
86
87
 
87
88
  const language =
88
- parseLanguage(blockClassName) ??
89
- (prism.defaultLanguage as Language | undefined);
89
+ languageProp ?? parseLanguage(blockClassName) ?? prism.defaultLanguage;
90
90
  const {highlightLines, code} = parseLines(content, metastring, language);
91
91
 
92
92
  const handleCopyCode = () => {
@@ -102,12 +102,16 @@ export default function CodeBlock({
102
102
  key={String(mounted)}
103
103
  theme={prismTheme}
104
104
  code={code}
105
- language={language ?? ('text' as Language)}>
105
+ language={(language ?? 'text') as Language}>
106
106
  {({className, style, tokens, getLineProps, getTokenProps}) => (
107
107
  <div
108
108
  className={clsx(
109
109
  styles.codeBlockContainer,
110
110
  blockClassName,
111
+ {
112
+ [`language-${language}`]:
113
+ language && !blockClassName.includes(`language-${language}`),
114
+ },
111
115
  ThemeClassNames.common.codeBlock,
112
116
  )}>
113
117
  {codeBlockTitle && (
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {ReactNode} from 'react';
8
+ import React, {type ReactNode} from 'react';
9
9
  import Link from '@docusaurus/Link';
10
- import {
10
+ import type {
11
11
  PropSidebarItemCategory,
12
12
  PropSidebarItemLink,
13
13
  } from '@docusaurus/plugin-content-docs';
@@ -8,7 +8,7 @@
8
8
  import React from 'react';
9
9
 
10
10
  import DocCard from '@theme/DocCard';
11
- import {PropSidebarItem} from '@docusaurus/plugin-content-docs';
11
+ import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
12
12
 
13
13
  export default function DocCardList({
14
14
  items,
@@ -12,7 +12,7 @@ import LastUpdated from '@theme/LastUpdated';
12
12
  import type {Props} from '@theme/DocItem';
13
13
  import EditThisPage from '@theme/EditThisPage';
14
14
  import TagsListInline, {
15
- Props as TagsListInlineProps,
15
+ type Props as TagsListInlineProps,
16
16
  } from '@theme/TagsListInline';
17
17
 
18
18
  import styles from './styles.module.css';
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {ReactNode, useState, useCallback} from 'react';
8
+ import React, {type ReactNode, useState, useCallback} from 'react';
9
9
  import {MDXProvider} from '@mdx-js/react';
10
10
 
11
11
  import renderRoutes from '@docusaurus/renderRoutes';
@@ -11,7 +11,7 @@ import {
11
11
  useThemeConfig,
12
12
  useAnnouncementBar,
13
13
  MobileSecondaryMenuFiller,
14
- MobileSecondaryMenuComponent,
14
+ type MobileSecondaryMenuComponent,
15
15
  ThemeClassNames,
16
16
  useScrollPosition,
17
17
  } from '@docusaurus/theme-common';
@@ -5,14 +5,14 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {ComponentType} from 'react';
8
+ import React, {type ComponentType} from 'react';
9
9
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
10
10
  import Link from '@docusaurus/Link';
11
11
  import Translate from '@docusaurus/Translate';
12
12
  import {
13
13
  useActivePlugin,
14
14
  useDocVersionSuggestions,
15
- GlobalVersion,
15
+ type GlobalVersion,
16
16
  } from '@theme/hooks/useDocs';
17
17
  import {
18
18
  ThemeClassNames,
@@ -10,15 +10,15 @@ import clsx from 'clsx';
10
10
 
11
11
  import Link from '@docusaurus/Link';
12
12
  import {
13
- FooterLinkItem,
13
+ type FooterLinkItem,
14
14
  useThemeConfig,
15
- MultiColumnFooter,
16
- SimpleFooter,
15
+ type MultiColumnFooter,
16
+ type SimpleFooter,
17
17
  } from '@docusaurus/theme-common';
18
18
  import useBaseUrl from '@docusaurus/useBaseUrl';
19
19
  import isInternalUrl from '@docusaurus/isInternalUrl';
20
20
  import styles from './styles.module.css';
21
- import ThemedImage, {Props as ThemedImageProps} from '@theme/ThemedImage';
21
+ import ThemedImage, {type Props as ThemedImageProps} from '@theme/ThemedImage';
22
22
  import IconExternalLink from '@theme/IconExternalLink';
23
23
 
24
24
  function FooterLink({
@@ -5,7 +5,11 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {ComponentProps, isValidElement, ReactElement} from 'react';
8
+ import React, {
9
+ type ComponentProps,
10
+ isValidElement,
11
+ type ReactElement,
12
+ } from 'react';
9
13
  import Head from '@docusaurus/Head';
10
14
  import Link from '@docusaurus/Link';
11
15
  import CodeBlock from '@theme/CodeBlock';
@@ -21,7 +21,7 @@ import useHideableNavbar from '@theme/hooks/useHideableNavbar';
21
21
  import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
22
22
  import useWindowSize from '@theme/hooks/useWindowSize';
23
23
  import {useActivePlugin} from '@theme/hooks/useDocs';
24
- import NavbarItem, {Props as NavbarItemConfig} from '@theme/NavbarItem';
24
+ import NavbarItem, {type Props as NavbarItemConfig} from '@theme/NavbarItem';
25
25
  import Logo from '@theme/Logo';
26
26
  import IconMenu from '@theme/IconMenu';
27
27
  import IconClose from '@theme/IconClose';
@@ -10,7 +10,7 @@ import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
10
10
  import {
11
11
  useActiveVersion,
12
12
  useLatestVersion,
13
- GlobalVersion,
13
+ type GlobalVersion,
14
14
  } from '@theme/hooks/useDocs';
15
15
  import type {Props} from '@theme/NavbarItem/DocsVersionNavbarItem';
16
16
  import {useDocsPreferredVersion} from '@docusaurus/theme-common';
@@ -8,7 +8,7 @@
8
8
  import React from 'react';
9
9
  import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
10
10
  import DropdownNavbarItem, {
11
- Props as DropdownNavbarItemProps,
11
+ type Props as DropdownNavbarItemProps,
12
12
  } from '@theme/NavbarItem/DropdownNavbarItem';
13
13
  import LocaleDropdownNavbarItem from '@theme/NavbarItem/LocaleDropdownNavbarItem';
14
14
  import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';
@@ -7,9 +7,9 @@
7
7
 
8
8
  import React, {useMemo} from 'react';
9
9
  import type {TOCItemsProps} from '@theme/TOCItems';
10
- import {TOCItem} from '@docusaurus/types';
10
+ import type {TOCItem} from '@docusaurus/types';
11
11
  import {
12
- TOCHighlightConfig,
12
+ type TOCHighlightConfig,
13
13
  useThemeConfig,
14
14
  useTOCFilter,
15
15
  useTOCHighlight,
@@ -10,7 +10,7 @@ import React, {
10
10
  cloneElement,
11
11
  Children,
12
12
  isValidElement,
13
- ReactElement,
13
+ type ReactElement,
14
14
  } from 'react';
15
15
  import useIsBrowser from '@docusaurus/useIsBrowser';
16
16
  import useUserPreferencesContext from '@theme/hooks/useUserPreferencesContext';
@@ -8,7 +8,7 @@
8
8
  import React from 'react';
9
9
  import Tag from '@theme/Tag';
10
10
  import type {Props} from '@theme/TagsListByLetter';
11
- import {listTagsByLetters, TagLetterEntry} from '@docusaurus/theme-common';
11
+ import {listTagsByLetters, type TagLetterEntry} from '@docusaurus/theme-common';
12
12
 
13
13
  import styles from './styles.module.css';
14
14
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  import React, {useState, useRef, memo} from 'react';
9
9
  import type {Props} from '@theme/Toggle';
10
- import {useThemeConfig, ColorModeConfig} from '@docusaurus/theme-common';
10
+ import {useThemeConfig, type ColorModeConfig} from '@docusaurus/theme-common';
11
11
  import useIsBrowser from '@docusaurus/useIsBrowser';
12
12
 
13
13
  import clsx from 'clsx';
@@ -107,13 +107,14 @@ declare module '@theme/BlogLayout' {
107
107
  }
108
108
 
109
109
  declare module '@theme/CodeBlock' {
110
- import {ReactElement} from 'react';
110
+ import type {ReactElement} from 'react';
111
111
 
112
112
  export interface Props {
113
113
  readonly children: string | ReactElement;
114
114
  readonly className?: string;
115
115
  readonly metastring?: string;
116
116
  readonly title?: string;
117
+ readonly language?: string;
117
118
  }
118
119
 
119
120
  const CodeBlock: (props: Props) => JSX.Element;
@@ -181,7 +182,7 @@ declare module '@theme/EditThisPage' {
181
182
  }
182
183
 
183
184
  declare module '@theme/ErrorPageContent' {
184
- import ErrorComponent from '@theme/Error';
185
+ import type ErrorComponent from '@theme/Error';
185
186
 
186
187
  const ErrorPageContent: typeof ErrorComponent;
187
188
  export default ErrorPageContent;
@@ -219,7 +220,7 @@ declare module '@theme/hooks/useLockBodyScroll' {
219
220
  }
220
221
 
221
222
  declare module '@theme/hooks/usePrismTheme' {
222
- import defaultTheme from 'prism-react-renderer/themes/palenight';
223
+ import type defaultTheme from 'prism-react-renderer/themes/palenight';
223
224
 
224
225
  const usePrismTheme: () => typeof defaultTheme;
225
226
  export default usePrismTheme;
@@ -581,7 +582,7 @@ declare module '@theme/ThemedImage' {
581
582
  }
582
583
 
583
584
  declare module '@theme/Details' {
584
- import {Details, DetailsProps} from '@docusaurus/theme-common';
585
+ import {Details, type DetailsProps} from '@docusaurus/theme-common';
585
586
 
586
587
  export interface Props extends DetailsProps {}
587
588
  export default Details;
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import {TranslationFile, TranslationFileContent} from '@docusaurus/types';
9
- import {
8
+ import type {TranslationFile, TranslationFileContent} from '@docusaurus/types';
9
+ import type {
10
10
  ThemeConfig,
11
11
  Navbar,
12
12
  NavbarItem,