@docusaurus/theme-classic 0.0.0-4334 → 0.0.0-4344

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.
@@ -114,6 +114,7 @@ declare module '@theme/CodeBlock' {
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;
@@ -129,18 +130,6 @@ declare module '@theme/DocPaginator' {
129
130
  export default function DocPaginator(props: Props): JSX.Element;
130
131
  }
131
132
 
132
- declare module '@theme/DocPaginatorNavLink' {
133
- import type {PropNavigationLink} from '@docusaurus/plugin-content-docs';
134
-
135
- // May be simpler to provide a {navigation: PropNavigation} prop?
136
- export interface Props {
137
- navLink: PropNavigationLink;
138
- next?: boolean;
139
- }
140
-
141
- export default function DocPaginatorNavLink(props: Props): JSX.Element;
142
- }
143
-
144
133
  declare module '@theme/DocSidebar' {
145
134
  import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
146
135
 
@@ -523,6 +512,18 @@ declare module '@theme/NavbarItem' {
523
512
  export default NavbarItem;
524
513
  }
525
514
 
515
+ declare module '@theme/PaginatorNavLink' {
516
+ import type {ReactNode} from 'react';
517
+ import type {PropNavigationLink} from '@docusaurus/plugin-content-docs';
518
+
519
+ export interface Props extends Omit<PropNavigationLink, 'title'> {
520
+ readonly title: ReactNode;
521
+ readonly subLabel?: JSX.Element;
522
+ }
523
+
524
+ export default function PaginatorNavLink(props: Props): JSX.Element;
525
+ }
526
+
526
527
  declare module '@theme/SearchBar' {
527
528
  export default function SearchBar(): JSX.Element;
528
529
  }
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import Link from '@docusaurus/Link';
9
8
  import Translate, {translate} from '@docusaurus/Translate';
9
+ import PaginatorNavLink from '@theme/PaginatorNavLink';
10
10
 
11
11
  function BlogListPaginator(props) {
12
12
  const {metadata} = props;
@@ -21,30 +21,30 @@ function BlogListPaginator(props) {
21
21
  })}>
22
22
  <div className="pagination-nav__item">
23
23
  {previousPage && (
24
- <Link className="pagination-nav__link" to={previousPage}>
25
- <div className="pagination-nav__label">
26
- &laquo;{' '}
24
+ <PaginatorNavLink
25
+ permalink={previousPage}
26
+ title={
27
27
  <Translate
28
28
  id="theme.blog.paginator.newerEntries"
29
29
  description="The label used to navigate to the newer blog posts page (previous page)">
30
30
  Newer Entries
31
31
  </Translate>
32
- </div>
33
- </Link>
32
+ }
33
+ />
34
34
  )}
35
35
  </div>
36
36
  <div className="pagination-nav__item pagination-nav__item--next">
37
37
  {nextPage && (
38
- <Link className="pagination-nav__link" to={nextPage}>
39
- <div className="pagination-nav__label">
38
+ <PaginatorNavLink
39
+ permalink={nextPage}
40
+ title={
40
41
  <Translate
41
42
  id="theme.blog.paginator.olderEntries"
42
43
  description="The label used to navigate to the older blog posts page (next page)">
43
44
  Older Entries
44
- </Translate>{' '}
45
- &raquo;
46
- </div>
47
- </Link>
45
+ </Translate>
46
+ }
47
+ />
48
48
  )}
49
49
  </div>
50
50
  </nav>
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import Translate, {translate} from '@docusaurus/Translate';
9
- import Link from '@docusaurus/Link';
9
+ import PaginatorNavLink from '@theme/PaginatorNavLink';
10
10
 
11
11
  function BlogPostPaginator(props) {
12
12
  const {nextItem, prevItem} = props;
@@ -20,34 +20,30 @@ function BlogPostPaginator(props) {
20
20
  })}>
21
21
  <div className="pagination-nav__item">
22
22
  {prevItem && (
23
- <Link className="pagination-nav__link" to={prevItem.permalink}>
24
- <div className="pagination-nav__sublabel">
23
+ <PaginatorNavLink
24
+ {...prevItem}
25
+ subLabel={
25
26
  <Translate
26
27
  id="theme.blog.post.paginator.newerPost"
27
28
  description="The blog post button label to navigate to the newer/previous post">
28
29
  Newer Post
29
30
  </Translate>
30
- </div>
31
- <div className="pagination-nav__label">
32
- &laquo; {prevItem.title}
33
- </div>
34
- </Link>
31
+ }
32
+ />
35
33
  )}
36
34
  </div>
37
35
  <div className="pagination-nav__item pagination-nav__item--next">
38
36
  {nextItem && (
39
- <Link className="pagination-nav__link" to={nextItem.permalink}>
40
- <div className="pagination-nav__sublabel">
37
+ <PaginatorNavLink
38
+ {...nextItem}
39
+ subLabel={
41
40
  <Translate
42
41
  id="theme.blog.post.paginator.olderPost"
43
42
  description="The blog post button label to navigate to the older/next post">
44
43
  Older Post
45
44
  </Translate>
46
- </div>
47
- <div className="pagination-nav__label">
48
- {nextItem.title} &raquo;
49
- </div>
50
- </Link>
45
+ }
46
+ />
51
47
  )}
52
48
  </div>
53
49
  </nav>
@@ -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 && (
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import {translate} from '@docusaurus/Translate';
9
- import DocPaginatorNavLink from '@theme/DocPaginatorNavLink';
8
+ import Translate, {translate} from '@docusaurus/Translate';
9
+ import PaginatorNavLink from '@theme/PaginatorNavLink';
10
10
 
11
11
  function DocPaginator(props) {
12
12
  const {previous, next} = props;
@@ -19,10 +19,32 @@ function DocPaginator(props) {
19
19
  description: 'The ARIA label for the docs pagination',
20
20
  })}>
21
21
  <div className="pagination-nav__item">
22
- {previous && <DocPaginatorNavLink navLink={previous} />}
22
+ {previous && (
23
+ <PaginatorNavLink
24
+ {...previous}
25
+ subLabel={
26
+ <Translate
27
+ id="theme.docs.paginator.previous"
28
+ description="The label used to navigate to the previous doc">
29
+ Previous
30
+ </Translate>
31
+ }
32
+ />
33
+ )}
23
34
  </div>
24
35
  <div className="pagination-nav__item pagination-nav__item--next">
25
- {next && <DocPaginatorNavLink navLink={next} next />}
36
+ {next && (
37
+ <PaginatorNavLink
38
+ {...next}
39
+ subLabel={
40
+ <Translate
41
+ id="theme.docs.paginator.next"
42
+ description="The label used to navigate to the next doc">
43
+ Next
44
+ </Translate>
45
+ }
46
+ />
47
+ )}
26
48
  </div>
27
49
  </nav>
28
50
  );
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import Link from '@docusaurus/Link';
9
+
10
+ function PaginatorNavLink(props) {
11
+ const {permalink, title, subLabel} = props;
12
+ return (
13
+ <Link className="pagination-nav__link" to={permalink}>
14
+ {subLabel && <div className="pagination-nav__sublabel">{subLabel}</div>}
15
+ <div className="pagination-nav__label">{title}</div>
16
+ </Link>
17
+ );
18
+ }
19
+
20
+ export default PaginatorNavLink;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4334",
3
+ "version": "0.0.0-4344",
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-4334",
27
- "@docusaurus/plugin-content-blog": "0.0.0-4334",
28
- "@docusaurus/plugin-content-docs": "0.0.0-4334",
29
- "@docusaurus/plugin-content-pages": "0.0.0-4334",
30
- "@docusaurus/theme-common": "0.0.0-4334",
31
- "@docusaurus/theme-translations": "0.0.0-4334",
32
- "@docusaurus/utils": "0.0.0-4334",
33
- "@docusaurus/utils-validation": "0.0.0-4334",
26
+ "@docusaurus/core": "0.0.0-4344",
27
+ "@docusaurus/plugin-content-blog": "0.0.0-4344",
28
+ "@docusaurus/plugin-content-docs": "0.0.0-4344",
29
+ "@docusaurus/plugin-content-pages": "0.0.0-4344",
30
+ "@docusaurus/theme-common": "0.0.0-4344",
31
+ "@docusaurus/theme-translations": "0.0.0-4344",
32
+ "@docusaurus/utils": "0.0.0-4344",
33
+ "@docusaurus/utils-validation": "0.0.0-4344",
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-4334",
49
- "@docusaurus/types": "0.0.0-4334",
48
+ "@docusaurus/module-type-aliases": "0.0.0-4344",
49
+ "@docusaurus/types": "0.0.0-4344",
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": "c7abfb389312cbce8e1af542c3bea6f11402b944"
64
+ "gitHead": "d99393e9e4889d73ad25332cd54b067a80db258c"
65
65
  }
@@ -6,8 +6,8 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import Link from '@docusaurus/Link';
10
9
  import Translate, {translate} from '@docusaurus/Translate';
10
+ import PaginatorNavLink from '@theme/PaginatorNavLink';
11
11
  import type {Props} from '@theme/BlogListPaginator';
12
12
 
13
13
  function BlogListPaginator(props: Props): JSX.Element {
@@ -24,30 +24,30 @@ function BlogListPaginator(props: Props): JSX.Element {
24
24
  })}>
25
25
  <div className="pagination-nav__item">
26
26
  {previousPage && (
27
- <Link className="pagination-nav__link" to={previousPage}>
28
- <div className="pagination-nav__label">
29
- &laquo;{' '}
27
+ <PaginatorNavLink
28
+ permalink={previousPage}
29
+ title={
30
30
  <Translate
31
31
  id="theme.blog.paginator.newerEntries"
32
32
  description="The label used to navigate to the newer blog posts page (previous page)">
33
33
  Newer Entries
34
34
  </Translate>
35
- </div>
36
- </Link>
35
+ }
36
+ />
37
37
  )}
38
38
  </div>
39
39
  <div className="pagination-nav__item pagination-nav__item--next">
40
40
  {nextPage && (
41
- <Link className="pagination-nav__link" to={nextPage}>
42
- <div className="pagination-nav__label">
41
+ <PaginatorNavLink
42
+ permalink={nextPage}
43
+ title={
43
44
  <Translate
44
45
  id="theme.blog.paginator.olderEntries"
45
46
  description="The label used to navigate to the older blog posts page (next page)">
46
47
  Older Entries
47
- </Translate>{' '}
48
- &raquo;
49
- </div>
50
- </Link>
48
+ </Translate>
49
+ }
50
+ />
51
51
  )}
52
52
  </div>
53
53
  </nav>
@@ -7,7 +7,7 @@
7
7
 
8
8
  import React from 'react';
9
9
  import Translate, {translate} from '@docusaurus/Translate';
10
- import Link from '@docusaurus/Link';
10
+ import PaginatorNavLink from '@theme/PaginatorNavLink';
11
11
  import type {Props} from '@theme/BlogPostPaginator';
12
12
 
13
13
  function BlogPostPaginator(props: Props): JSX.Element {
@@ -23,34 +23,30 @@ function BlogPostPaginator(props: Props): JSX.Element {
23
23
  })}>
24
24
  <div className="pagination-nav__item">
25
25
  {prevItem && (
26
- <Link className="pagination-nav__link" to={prevItem.permalink}>
27
- <div className="pagination-nav__sublabel">
26
+ <PaginatorNavLink
27
+ {...prevItem}
28
+ subLabel={
28
29
  <Translate
29
30
  id="theme.blog.post.paginator.newerPost"
30
31
  description="The blog post button label to navigate to the newer/previous post">
31
32
  Newer Post
32
33
  </Translate>
33
- </div>
34
- <div className="pagination-nav__label">
35
- &laquo; {prevItem.title}
36
- </div>
37
- </Link>
34
+ }
35
+ />
38
36
  )}
39
37
  </div>
40
38
  <div className="pagination-nav__item pagination-nav__item--next">
41
39
  {nextItem && (
42
- <Link className="pagination-nav__link" to={nextItem.permalink}>
43
- <div className="pagination-nav__sublabel">
40
+ <PaginatorNavLink
41
+ {...nextItem}
42
+ subLabel={
44
43
  <Translate
45
44
  id="theme.blog.post.paginator.olderPost"
46
45
  description="The blog post button label to navigate to the older/next post">
47
46
  Older Post
48
47
  </Translate>
49
- </div>
50
- <div className="pagination-nav__label">
51
- {nextItem.title} &raquo;
52
- </div>
53
- </Link>
48
+ }
49
+ />
54
50
  )}
55
51
  </div>
56
52
  </nav>
@@ -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 && (
@@ -6,8 +6,8 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import {translate} from '@docusaurus/Translate';
10
- import DocPaginatorNavLink from '@theme/DocPaginatorNavLink';
9
+ import Translate, {translate} from '@docusaurus/Translate';
10
+ import PaginatorNavLink from '@theme/PaginatorNavLink';
11
11
  import type {Props} from '@theme/DocPaginator';
12
12
 
13
13
  function DocPaginator(props: Props): JSX.Element {
@@ -22,10 +22,32 @@ function DocPaginator(props: Props): JSX.Element {
22
22
  description: 'The ARIA label for the docs pagination',
23
23
  })}>
24
24
  <div className="pagination-nav__item">
25
- {previous && <DocPaginatorNavLink navLink={previous} />}
25
+ {previous && (
26
+ <PaginatorNavLink
27
+ {...previous}
28
+ subLabel={
29
+ <Translate
30
+ id="theme.docs.paginator.previous"
31
+ description="The label used to navigate to the previous doc">
32
+ Previous
33
+ </Translate>
34
+ }
35
+ />
36
+ )}
26
37
  </div>
27
38
  <div className="pagination-nav__item pagination-nav__item--next">
28
- {next && <DocPaginatorNavLink navLink={next} next />}
39
+ {next && (
40
+ <PaginatorNavLink
41
+ {...next}
42
+ subLabel={
43
+ <Translate
44
+ id="theme.docs.paginator.next"
45
+ description="The label used to navigate to the next doc">
46
+ Next
47
+ </Translate>
48
+ }
49
+ />
50
+ )}
29
51
  </div>
30
52
  </nav>
31
53
  );
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+ import Link from '@docusaurus/Link';
10
+ import type {Props} from '@theme/PaginatorNavLink';
11
+
12
+ function PaginatorNavLink(props: Props): JSX.Element {
13
+ const {permalink, title, subLabel} = props;
14
+ return (
15
+ <Link className="pagination-nav__link" to={permalink}>
16
+ {subLabel && <div className="pagination-nav__sublabel">{subLabel}</div>}
17
+ <div className="pagination-nav__label">{title}</div>
18
+ </Link>
19
+ );
20
+ }
21
+
22
+ export default PaginatorNavLink;
@@ -114,6 +114,7 @@ declare module '@theme/CodeBlock' {
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;
@@ -129,18 +130,6 @@ declare module '@theme/DocPaginator' {
129
130
  export default function DocPaginator(props: Props): JSX.Element;
130
131
  }
131
132
 
132
- declare module '@theme/DocPaginatorNavLink' {
133
- import type {PropNavigationLink} from '@docusaurus/plugin-content-docs';
134
-
135
- // May be simpler to provide a {navigation: PropNavigation} prop?
136
- export interface Props {
137
- navLink: PropNavigationLink;
138
- next?: boolean;
139
- }
140
-
141
- export default function DocPaginatorNavLink(props: Props): JSX.Element;
142
- }
143
-
144
133
  declare module '@theme/DocSidebar' {
145
134
  import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
146
135
 
@@ -523,6 +512,18 @@ declare module '@theme/NavbarItem' {
523
512
  export default NavbarItem;
524
513
  }
525
514
 
515
+ declare module '@theme/PaginatorNavLink' {
516
+ import type {ReactNode} from 'react';
517
+ import type {PropNavigationLink} from '@docusaurus/plugin-content-docs';
518
+
519
+ export interface Props extends Omit<PropNavigationLink, 'title'> {
520
+ readonly title: ReactNode;
521
+ readonly subLabel?: JSX.Element;
522
+ }
523
+
524
+ export default function PaginatorNavLink(props: Props): JSX.Element;
525
+ }
526
+
526
527
  declare module '@theme/SearchBar' {
527
528
  export default function SearchBar(): JSX.Element;
528
529
  }
@@ -1,36 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import React from 'react';
8
- import clsx from 'clsx';
9
- import Link from '@docusaurus/Link';
10
- import Translate from '@docusaurus/Translate';
11
-
12
- function DocPaginatorNavLink(props) {
13
- const {navLink, next} = props;
14
- return (
15
- <Link className={clsx('pagination-nav__link')} to={navLink.permalink}>
16
- <div className="pagination-nav__sublabel">
17
- {next ? (
18
- <Translate
19
- id="theme.docs.paginator.next"
20
- description="The label used to navigate to the next doc">
21
- Next
22
- </Translate>
23
- ) : (
24
- <Translate
25
- id="theme.docs.paginator.previous"
26
- description="The label used to navigate to the previous doc">
27
- Previous
28
- </Translate>
29
- )}
30
- </div>
31
- <div className="pagination-nav__label">{navLink.title}</div>
32
- </Link>
33
- );
34
- }
35
-
36
- export default DocPaginatorNavLink;
@@ -1,38 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import React from 'react';
9
- import clsx from 'clsx';
10
- import Link from '@docusaurus/Link';
11
- import Translate from '@docusaurus/Translate';
12
- import type {Props} from '@theme/DocPaginatorNavLink';
13
-
14
- function DocPaginatorNavLink(props: Props): JSX.Element {
15
- const {navLink, next} = props;
16
- return (
17
- <Link className={clsx('pagination-nav__link')} to={navLink.permalink}>
18
- <div className="pagination-nav__sublabel">
19
- {next ? (
20
- <Translate
21
- id="theme.docs.paginator.next"
22
- description="The label used to navigate to the next doc">
23
- Next
24
- </Translate>
25
- ) : (
26
- <Translate
27
- id="theme.docs.paginator.previous"
28
- description="The label used to navigate to the previous doc">
29
- Previous
30
- </Translate>
31
- )}
32
- </div>
33
- <div className="pagination-nav__label">{navLink.title}</div>
34
- </Link>
35
- );
36
- }
37
-
38
- export default DocPaginatorNavLink;