@docusaurus/theme-classic 0.0.0-4853 → 0.0.0-4860
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.
- package/lib/theme-classic.d.ts +61 -18
- package/lib-next/theme/CodeBlock/index.js +34 -11
- package/lib-next/theme/CodeBlock/styles.module.css +35 -1
- package/package.json +13 -13
- package/src/theme/CodeBlock/index.tsx +31 -6
- package/src/theme/CodeBlock/styles.module.css +35 -1
- package/src/theme/DocPage/index.tsx +1 -1
- package/src/theme-classic.d.ts +61 -18
package/lib/theme-classic.d.ts
CHANGED
|
@@ -12,6 +12,14 @@
|
|
|
12
12
|
/// <reference types="@docusaurus/plugin-content-blog" />
|
|
13
13
|
/// <reference types="@docusaurus/plugin-content-pages" />
|
|
14
14
|
|
|
15
|
+
// This file, like all the other ambient declaration files for plugins, is
|
|
16
|
+
// needed for TS to understand our `@theme` alias. The export signatures are
|
|
17
|
+
// duplicated from the implementation, which is fine, since every module only
|
|
18
|
+
// default-exports a React component.
|
|
19
|
+
// TODO we'll eventually migrate to TS `paths` option. This is not easy due to
|
|
20
|
+
// our theme shadowing—we probably need the user to specify multiple theme paths
|
|
21
|
+
// in their tsconfig.
|
|
22
|
+
|
|
15
23
|
declare module '@docusaurus/theme-classic' {
|
|
16
24
|
export type Options = {
|
|
17
25
|
customCss?: string | string[];
|
|
@@ -148,6 +156,7 @@ declare module '@theme/CodeBlock' {
|
|
|
148
156
|
readonly metastring?: string;
|
|
149
157
|
readonly title?: string;
|
|
150
158
|
readonly language?: string;
|
|
159
|
+
readonly showLineNumbers?: boolean;
|
|
151
160
|
}
|
|
152
161
|
|
|
153
162
|
export default function CodeBlock(props: Props): JSX.Element;
|
|
@@ -188,6 +197,40 @@ declare module '@theme/DocItemFooter' {
|
|
|
188
197
|
export default function DocItemFooter(props: Props): JSX.Element;
|
|
189
198
|
}
|
|
190
199
|
|
|
200
|
+
declare module '@theme/DocPage/Layout' {
|
|
201
|
+
import type {ReactNode} from 'react';
|
|
202
|
+
|
|
203
|
+
export interface Props {
|
|
204
|
+
readonly children: ReactNode;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export default function DocPageLayout(props: Props): JSX.Element;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
declare module '@theme/DocPage/Layout/Aside' {
|
|
211
|
+
import type {Dispatch, SetStateAction} from 'react';
|
|
212
|
+
import type {PropSidebar} from '@docusaurus/plugin-content-docs';
|
|
213
|
+
|
|
214
|
+
export interface Props {
|
|
215
|
+
readonly sidebar: PropSidebar;
|
|
216
|
+
readonly hiddenSidebarContainer: boolean;
|
|
217
|
+
readonly setHiddenSidebarContainer: Dispatch<SetStateAction<boolean>>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export default function DocPageLayoutAside(props: Props): JSX.Element;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare module '@theme/DocPage/Layout/Main' {
|
|
224
|
+
import type {ReactNode} from 'react';
|
|
225
|
+
|
|
226
|
+
export interface Props {
|
|
227
|
+
readonly hiddenSidebarContainer: boolean;
|
|
228
|
+
readonly children: ReactNode;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export default function DocPageLayoutMain(props: Props): JSX.Element;
|
|
232
|
+
}
|
|
233
|
+
|
|
191
234
|
declare module '@theme/DocPaginator' {
|
|
192
235
|
import type {PropNavigation} from '@docusaurus/plugin-content-docs';
|
|
193
236
|
|
|
@@ -242,7 +285,7 @@ declare module '@theme/DocSidebar/Desktop/Content' {
|
|
|
242
285
|
|
|
243
286
|
declare module '@theme/DocSidebar/Desktop/CollapseButton' {
|
|
244
287
|
export interface Props {
|
|
245
|
-
onClick: React.MouseEventHandler;
|
|
288
|
+
readonly onClick: React.MouseEventHandler;
|
|
246
289
|
}
|
|
247
290
|
|
|
248
291
|
export default function CollapseButton(props: Props): JSX.Element;
|
|
@@ -269,7 +312,7 @@ declare module '@theme/DocSidebarItem/Link' {
|
|
|
269
312
|
import type {PropSidebarItemLink} from '@docusaurus/plugin-content-docs';
|
|
270
313
|
|
|
271
314
|
export interface Props extends DocSidebarItemProps {
|
|
272
|
-
item: PropSidebarItemLink;
|
|
315
|
+
readonly item: PropSidebarItemLink;
|
|
273
316
|
}
|
|
274
317
|
|
|
275
318
|
export default function DocSidebarItemLink(props: Props): JSX.Element;
|
|
@@ -280,7 +323,7 @@ declare module '@theme/DocSidebarItem/Html' {
|
|
|
280
323
|
import type {PropSidebarItemHtml} from '@docusaurus/plugin-content-docs';
|
|
281
324
|
|
|
282
325
|
export interface Props extends DocSidebarItemProps {
|
|
283
|
-
item: PropSidebarItemHtml;
|
|
326
|
+
readonly item: PropSidebarItemHtml;
|
|
284
327
|
}
|
|
285
328
|
|
|
286
329
|
export default function DocSidebarItemHtml(props: Props): JSX.Element;
|
|
@@ -291,7 +334,7 @@ declare module '@theme/DocSidebarItem/Category' {
|
|
|
291
334
|
import type {PropSidebarItemCategory} from '@docusaurus/plugin-content-docs';
|
|
292
335
|
|
|
293
336
|
export interface Props extends DocSidebarItemProps {
|
|
294
|
-
item: PropSidebarItemCategory;
|
|
337
|
+
readonly item: PropSidebarItemCategory;
|
|
295
338
|
}
|
|
296
339
|
|
|
297
340
|
export default function DocSidebarItemCategory(props: Props): JSX.Element;
|
|
@@ -350,7 +393,7 @@ declare module '@theme/Footer/Logo' {
|
|
|
350
393
|
import type {FooterLogo} from '@docusaurus/theme-common';
|
|
351
394
|
|
|
352
395
|
export interface Props {
|
|
353
|
-
logo: FooterLogo;
|
|
396
|
+
readonly logo: FooterLogo;
|
|
354
397
|
}
|
|
355
398
|
|
|
356
399
|
export default function FooterLogo(props: Props): JSX.Element;
|
|
@@ -358,7 +401,7 @@ declare module '@theme/Footer/Logo' {
|
|
|
358
401
|
|
|
359
402
|
declare module '@theme/Footer/Copyright' {
|
|
360
403
|
export interface Props {
|
|
361
|
-
copyright: string;
|
|
404
|
+
readonly copyright: string;
|
|
362
405
|
}
|
|
363
406
|
|
|
364
407
|
export default function FooterCopyright(props: Props): JSX.Element;
|
|
@@ -368,7 +411,7 @@ declare module '@theme/Footer/LinkItem' {
|
|
|
368
411
|
import type {FooterLinkItem} from '@docusaurus/theme-common';
|
|
369
412
|
|
|
370
413
|
export interface Props {
|
|
371
|
-
item: FooterLinkItem;
|
|
414
|
+
readonly item: FooterLinkItem;
|
|
372
415
|
}
|
|
373
416
|
|
|
374
417
|
export default function FooterLinkItem(props: Props): JSX.Element;
|
|
@@ -378,10 +421,10 @@ declare module '@theme/Footer/Layout' {
|
|
|
378
421
|
import type {ReactNode} from 'react';
|
|
379
422
|
|
|
380
423
|
export interface Props {
|
|
381
|
-
style: 'light' | 'dark';
|
|
382
|
-
links: ReactNode;
|
|
383
|
-
logo: ReactNode;
|
|
384
|
-
copyright: ReactNode;
|
|
424
|
+
readonly style: 'light' | 'dark';
|
|
425
|
+
readonly links: ReactNode;
|
|
426
|
+
readonly logo: ReactNode;
|
|
427
|
+
readonly copyright: ReactNode;
|
|
385
428
|
}
|
|
386
429
|
|
|
387
430
|
export default function FooterLayout(props: Props): JSX.Element;
|
|
@@ -391,7 +434,7 @@ declare module '@theme/Footer/Links' {
|
|
|
391
434
|
import type {Footer} from '@docusaurus/theme-common';
|
|
392
435
|
|
|
393
436
|
export interface Props {
|
|
394
|
-
links: Footer['links'];
|
|
437
|
+
readonly links: Footer['links'];
|
|
395
438
|
}
|
|
396
439
|
|
|
397
440
|
export default function FooterLinks(props: Props): JSX.Element;
|
|
@@ -401,7 +444,7 @@ declare module '@theme/Footer/Links/MultiColumn' {
|
|
|
401
444
|
import type {MultiColumnFooter} from '@docusaurus/theme-common';
|
|
402
445
|
|
|
403
446
|
export interface Props {
|
|
404
|
-
columns: MultiColumnFooter['links'];
|
|
447
|
+
readonly columns: MultiColumnFooter['links'];
|
|
405
448
|
}
|
|
406
449
|
|
|
407
450
|
export default function FooterLinksMultiColumn(props: Props): JSX.Element;
|
|
@@ -411,7 +454,7 @@ declare module '@theme/Footer/Links/Simple' {
|
|
|
411
454
|
import type {SimpleFooter} from '@docusaurus/theme-common';
|
|
412
455
|
|
|
413
456
|
export interface Props {
|
|
414
|
-
links: SimpleFooter['links'];
|
|
457
|
+
readonly links: SimpleFooter['links'];
|
|
415
458
|
}
|
|
416
459
|
|
|
417
460
|
export default function FooterLinksSimple(props: Props): JSX.Element;
|
|
@@ -423,7 +466,7 @@ declare module '@theme/Heading' {
|
|
|
423
466
|
type HeadingType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
424
467
|
|
|
425
468
|
export interface Props extends ComponentProps<HeadingType> {
|
|
426
|
-
as: HeadingType;
|
|
469
|
+
readonly as: HeadingType;
|
|
427
470
|
}
|
|
428
471
|
|
|
429
472
|
export default function Heading(props: Props): JSX.Element;
|
|
@@ -625,9 +668,9 @@ declare module '@theme/Navbar/MobileSidebar/Layout' {
|
|
|
625
668
|
import type {ReactNode} from 'react';
|
|
626
669
|
|
|
627
670
|
interface Props {
|
|
628
|
-
header: ReactNode;
|
|
629
|
-
primaryMenu: ReactNode;
|
|
630
|
-
secondaryMenu: ReactNode;
|
|
671
|
+
readonly header: ReactNode;
|
|
672
|
+
readonly primaryMenu: ReactNode;
|
|
673
|
+
readonly secondaryMenu: ReactNode;
|
|
631
674
|
}
|
|
632
675
|
|
|
633
676
|
export default function NavbarMobileSidebarLayout(props: Props): JSX.Element;
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
parseCodeBlockTitle,
|
|
13
13
|
parseLanguage,
|
|
14
14
|
parseLines,
|
|
15
|
+
containsLineNumbers,
|
|
15
16
|
ThemeClassNames,
|
|
16
17
|
usePrismTheme,
|
|
17
18
|
} from '@docusaurus/theme-common';
|
|
@@ -22,6 +23,7 @@ export default function CodeBlock({
|
|
|
22
23
|
className: blockClassName = '',
|
|
23
24
|
metastring,
|
|
24
25
|
title,
|
|
26
|
+
showLineNumbers,
|
|
25
27
|
language: languageProp,
|
|
26
28
|
}) {
|
|
27
29
|
const {prism} = useThemeConfig();
|
|
@@ -76,6 +78,8 @@ export default function CodeBlock({
|
|
|
76
78
|
const language =
|
|
77
79
|
languageProp ?? parseLanguage(blockClassName) ?? prism.defaultLanguage;
|
|
78
80
|
const {highlightLines, code} = parseLines(content, metastring, language);
|
|
81
|
+
const shouldShowLineNumbers =
|
|
82
|
+
showLineNumbers || containsLineNumbers(metastring);
|
|
79
83
|
return (
|
|
80
84
|
<Highlight
|
|
81
85
|
{...defaultProps}
|
|
@@ -104,7 +108,11 @@ export default function CodeBlock({
|
|
|
104
108
|
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
105
109
|
tabIndex={0}
|
|
106
110
|
className={clsx(className, styles.codeBlock, 'thin-scrollbar')}>
|
|
107
|
-
<code
|
|
111
|
+
<code
|
|
112
|
+
className={clsx(
|
|
113
|
+
styles.codeBlockLines,
|
|
114
|
+
shouldShowLineNumbers && styles.codeBlockLinesWithNumbering,
|
|
115
|
+
)}>
|
|
108
116
|
{tokens.map((line, i) => {
|
|
109
117
|
if (line.length === 1 && line[0].content === '\n') {
|
|
110
118
|
line[0].content = '';
|
|
@@ -113,24 +121,39 @@ export default function CodeBlock({
|
|
|
113
121
|
const lineProps = getLineProps({
|
|
114
122
|
line,
|
|
115
123
|
key: i,
|
|
124
|
+
...(shouldShowLineNumbers && {
|
|
125
|
+
className: styles.codeLine,
|
|
126
|
+
}),
|
|
116
127
|
});
|
|
117
128
|
|
|
118
129
|
if (highlightLines.includes(i)) {
|
|
119
130
|
lineProps.className += ' docusaurus-highlight-code-line';
|
|
120
131
|
}
|
|
121
132
|
|
|
133
|
+
const lineTokens = line.map((token, key) => (
|
|
134
|
+
<span
|
|
135
|
+
key={key}
|
|
136
|
+
{...getTokenProps({
|
|
137
|
+
token,
|
|
138
|
+
key,
|
|
139
|
+
})}
|
|
140
|
+
/>
|
|
141
|
+
));
|
|
122
142
|
return (
|
|
123
143
|
<span key={i} {...lineProps}>
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
144
|
+
{shouldShowLineNumbers ? (
|
|
145
|
+
<>
|
|
146
|
+
<span className={styles.codeLineNumber} />
|
|
147
|
+
<span className={styles.codeLineContent}>
|
|
148
|
+
{lineTokens}
|
|
149
|
+
</span>
|
|
150
|
+
</>
|
|
151
|
+
) : (
|
|
152
|
+
<>
|
|
153
|
+
{lineTokens}
|
|
154
|
+
<br />
|
|
155
|
+
</>
|
|
156
|
+
)}
|
|
134
157
|
</span>
|
|
135
158
|
);
|
|
136
159
|
})}
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.codeBlock {
|
|
31
|
+
--ifm-pre-background: inherit;
|
|
31
32
|
margin: 0;
|
|
32
33
|
padding: 0;
|
|
33
|
-
background-color: inherit;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
.codeBlockTitle + .codeBlockContent .codeBlock {
|
|
@@ -44,14 +44,48 @@
|
|
|
44
44
|
|
|
45
45
|
.codeBlockLines {
|
|
46
46
|
font: inherit;
|
|
47
|
+
background: var(--ifm-pre-background);
|
|
47
48
|
/* rtl:ignore */
|
|
48
49
|
float: left;
|
|
49
50
|
min-width: 100%;
|
|
50
51
|
padding: var(--ifm-pre-padding);
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
.codeBlockLinesWithNumbering {
|
|
55
|
+
display: table;
|
|
56
|
+
padding: var(--ifm-pre-padding) 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
@media print {
|
|
54
60
|
.codeBlockLines {
|
|
55
61
|
white-space: pre-wrap;
|
|
56
62
|
}
|
|
57
63
|
}
|
|
64
|
+
|
|
65
|
+
.codeLine {
|
|
66
|
+
display: table-row;
|
|
67
|
+
counter-increment: line-count;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.codeLineNumber {
|
|
71
|
+
display: table-cell;
|
|
72
|
+
text-align: right;
|
|
73
|
+
width: 1%;
|
|
74
|
+
position: sticky;
|
|
75
|
+
left: 0;
|
|
76
|
+
padding: 0 var(--ifm-pre-padding);
|
|
77
|
+
background: var(--ifm-pre-background);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.codeLineNumber::before {
|
|
81
|
+
content: counter(line-count);
|
|
82
|
+
opacity: 0.4;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
:global(.docusaurus-highlight-code-line) .codeLineNumber::before {
|
|
86
|
+
opacity: 0.8;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.codeLineContent {
|
|
90
|
+
padding-right: var(--ifm-pre-padding);
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4860",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@docusaurus/core": "0.0.0-
|
|
25
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
28
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
30
|
-
"@docusaurus/utils": "0.0.0-
|
|
31
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
32
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
24
|
+
"@docusaurus/core": "0.0.0-4860",
|
|
25
|
+
"@docusaurus/plugin-content-blog": "0.0.0-4860",
|
|
26
|
+
"@docusaurus/plugin-content-docs": "0.0.0-4860",
|
|
27
|
+
"@docusaurus/plugin-content-pages": "0.0.0-4860",
|
|
28
|
+
"@docusaurus/theme-common": "0.0.0-4860",
|
|
29
|
+
"@docusaurus/theme-translations": "0.0.0-4860",
|
|
30
|
+
"@docusaurus/utils": "0.0.0-4860",
|
|
31
|
+
"@docusaurus/utils-common": "0.0.0-4860",
|
|
32
|
+
"@docusaurus/utils-validation": "0.0.0-4860",
|
|
33
33
|
"@mdx-js/react": "^1.6.22",
|
|
34
34
|
"clsx": "^1.1.1",
|
|
35
35
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@babel/cli": "^7.17.6",
|
|
46
46
|
"@babel/core": "^7.17.9",
|
|
47
47
|
"@babel/preset-typescript": "^7.16.7",
|
|
48
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
49
|
-
"@docusaurus/types": "0.0.0-
|
|
48
|
+
"@docusaurus/module-type-aliases": "0.0.0-4860",
|
|
49
|
+
"@docusaurus/types": "0.0.0-4860",
|
|
50
50
|
"@types/mdx-js__react": "^1.5.5",
|
|
51
51
|
"@types/prismjs": "^1.26.0",
|
|
52
52
|
"@types/rtlcss": "^3.1.3",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "dd89ce688ef649f835f2bf6be614c6997ba47165"
|
|
66
66
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
parseCodeBlockTitle,
|
|
14
14
|
parseLanguage,
|
|
15
15
|
parseLines,
|
|
16
|
+
containsLineNumbers,
|
|
16
17
|
ThemeClassNames,
|
|
17
18
|
usePrismTheme,
|
|
18
19
|
} from '@docusaurus/theme-common';
|
|
@@ -26,6 +27,7 @@ export default function CodeBlock({
|
|
|
26
27
|
className: blockClassName = '',
|
|
27
28
|
metastring,
|
|
28
29
|
title,
|
|
30
|
+
showLineNumbers,
|
|
29
31
|
language: languageProp,
|
|
30
32
|
}: Props): JSX.Element {
|
|
31
33
|
const {prism} = useThemeConfig();
|
|
@@ -87,6 +89,8 @@ export default function CodeBlock({
|
|
|
87
89
|
const language =
|
|
88
90
|
languageProp ?? parseLanguage(blockClassName) ?? prism.defaultLanguage;
|
|
89
91
|
const {highlightLines, code} = parseLines(content, metastring, language);
|
|
92
|
+
const shouldShowLineNumbers =
|
|
93
|
+
showLineNumbers || containsLineNumbers(metastring);
|
|
90
94
|
|
|
91
95
|
return (
|
|
92
96
|
<Highlight
|
|
@@ -116,24 +120,45 @@ export default function CodeBlock({
|
|
|
116
120
|
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
117
121
|
tabIndex={0}
|
|
118
122
|
className={clsx(className, styles.codeBlock, 'thin-scrollbar')}>
|
|
119
|
-
<code
|
|
123
|
+
<code
|
|
124
|
+
className={clsx(
|
|
125
|
+
styles.codeBlockLines,
|
|
126
|
+
shouldShowLineNumbers && styles.codeBlockLinesWithNumbering,
|
|
127
|
+
)}>
|
|
120
128
|
{tokens.map((line, i) => {
|
|
121
129
|
if (line.length === 1 && line[0]!.content === '\n') {
|
|
122
130
|
line[0]!.content = '';
|
|
123
131
|
}
|
|
124
132
|
|
|
125
|
-
const lineProps = getLineProps({
|
|
133
|
+
const lineProps = getLineProps({
|
|
134
|
+
line,
|
|
135
|
+
key: i,
|
|
136
|
+
...(shouldShowLineNumbers && {className: styles.codeLine}),
|
|
137
|
+
});
|
|
126
138
|
|
|
127
139
|
if (highlightLines.includes(i)) {
|
|
128
140
|
lineProps.className += ' docusaurus-highlight-code-line';
|
|
129
141
|
}
|
|
130
142
|
|
|
143
|
+
const lineTokens = line.map((token, key) => (
|
|
144
|
+
<span key={key} {...getTokenProps({token, key})} />
|
|
145
|
+
));
|
|
146
|
+
|
|
131
147
|
return (
|
|
132
148
|
<span key={i} {...lineProps}>
|
|
133
|
-
{
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
149
|
+
{shouldShowLineNumbers ? (
|
|
150
|
+
<>
|
|
151
|
+
<span className={styles.codeLineNumber} />
|
|
152
|
+
<span className={styles.codeLineContent}>
|
|
153
|
+
{lineTokens}
|
|
154
|
+
</span>
|
|
155
|
+
</>
|
|
156
|
+
) : (
|
|
157
|
+
<>
|
|
158
|
+
{lineTokens}
|
|
159
|
+
<br />
|
|
160
|
+
</>
|
|
161
|
+
)}
|
|
137
162
|
</span>
|
|
138
163
|
);
|
|
139
164
|
})}
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.codeBlock {
|
|
31
|
+
--ifm-pre-background: inherit;
|
|
31
32
|
margin: 0;
|
|
32
33
|
padding: 0;
|
|
33
|
-
background-color: inherit;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
.codeBlockTitle + .codeBlockContent .codeBlock {
|
|
@@ -44,14 +44,48 @@
|
|
|
44
44
|
|
|
45
45
|
.codeBlockLines {
|
|
46
46
|
font: inherit;
|
|
47
|
+
background: var(--ifm-pre-background);
|
|
47
48
|
/* rtl:ignore */
|
|
48
49
|
float: left;
|
|
49
50
|
min-width: 100%;
|
|
50
51
|
padding: var(--ifm-pre-padding);
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
.codeBlockLinesWithNumbering {
|
|
55
|
+
display: table;
|
|
56
|
+
padding: var(--ifm-pre-padding) 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
@media print {
|
|
54
60
|
.codeBlockLines {
|
|
55
61
|
white-space: pre-wrap;
|
|
56
62
|
}
|
|
57
63
|
}
|
|
64
|
+
|
|
65
|
+
.codeLine {
|
|
66
|
+
display: table-row;
|
|
67
|
+
counter-increment: line-count;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.codeLineNumber {
|
|
71
|
+
display: table-cell;
|
|
72
|
+
text-align: right;
|
|
73
|
+
width: 1%;
|
|
74
|
+
position: sticky;
|
|
75
|
+
left: 0;
|
|
76
|
+
padding: 0 var(--ifm-pre-padding);
|
|
77
|
+
background: var(--ifm-pre-background);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.codeLineNumber::before {
|
|
81
|
+
content: counter(line-count);
|
|
82
|
+
opacity: 0.4;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
:global(.docusaurus-highlight-code-line) .codeLineNumber::before {
|
|
86
|
+
opacity: 0.8;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.codeLineContent {
|
|
90
|
+
padding-right: var(--ifm-pre-padding);
|
|
91
|
+
}
|
|
@@ -34,7 +34,7 @@ function extractDocRouteMetadata(props: Props): null | {
|
|
|
34
34
|
versionMetadata,
|
|
35
35
|
location,
|
|
36
36
|
} = props;
|
|
37
|
-
const currentDocRoute = docRoutes
|
|
37
|
+
const currentDocRoute = docRoutes!.find((docRoute) =>
|
|
38
38
|
matchPath(location.pathname, docRoute),
|
|
39
39
|
);
|
|
40
40
|
if (!currentDocRoute) {
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -12,6 +12,14 @@
|
|
|
12
12
|
/// <reference types="@docusaurus/plugin-content-blog" />
|
|
13
13
|
/// <reference types="@docusaurus/plugin-content-pages" />
|
|
14
14
|
|
|
15
|
+
// This file, like all the other ambient declaration files for plugins, is
|
|
16
|
+
// needed for TS to understand our `@theme` alias. The export signatures are
|
|
17
|
+
// duplicated from the implementation, which is fine, since every module only
|
|
18
|
+
// default-exports a React component.
|
|
19
|
+
// TODO we'll eventually migrate to TS `paths` option. This is not easy due to
|
|
20
|
+
// our theme shadowing—we probably need the user to specify multiple theme paths
|
|
21
|
+
// in their tsconfig.
|
|
22
|
+
|
|
15
23
|
declare module '@docusaurus/theme-classic' {
|
|
16
24
|
export type Options = {
|
|
17
25
|
customCss?: string | string[];
|
|
@@ -148,6 +156,7 @@ declare module '@theme/CodeBlock' {
|
|
|
148
156
|
readonly metastring?: string;
|
|
149
157
|
readonly title?: string;
|
|
150
158
|
readonly language?: string;
|
|
159
|
+
readonly showLineNumbers?: boolean;
|
|
151
160
|
}
|
|
152
161
|
|
|
153
162
|
export default function CodeBlock(props: Props): JSX.Element;
|
|
@@ -188,6 +197,40 @@ declare module '@theme/DocItemFooter' {
|
|
|
188
197
|
export default function DocItemFooter(props: Props): JSX.Element;
|
|
189
198
|
}
|
|
190
199
|
|
|
200
|
+
declare module '@theme/DocPage/Layout' {
|
|
201
|
+
import type {ReactNode} from 'react';
|
|
202
|
+
|
|
203
|
+
export interface Props {
|
|
204
|
+
readonly children: ReactNode;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export default function DocPageLayout(props: Props): JSX.Element;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
declare module '@theme/DocPage/Layout/Aside' {
|
|
211
|
+
import type {Dispatch, SetStateAction} from 'react';
|
|
212
|
+
import type {PropSidebar} from '@docusaurus/plugin-content-docs';
|
|
213
|
+
|
|
214
|
+
export interface Props {
|
|
215
|
+
readonly sidebar: PropSidebar;
|
|
216
|
+
readonly hiddenSidebarContainer: boolean;
|
|
217
|
+
readonly setHiddenSidebarContainer: Dispatch<SetStateAction<boolean>>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export default function DocPageLayoutAside(props: Props): JSX.Element;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare module '@theme/DocPage/Layout/Main' {
|
|
224
|
+
import type {ReactNode} from 'react';
|
|
225
|
+
|
|
226
|
+
export interface Props {
|
|
227
|
+
readonly hiddenSidebarContainer: boolean;
|
|
228
|
+
readonly children: ReactNode;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export default function DocPageLayoutMain(props: Props): JSX.Element;
|
|
232
|
+
}
|
|
233
|
+
|
|
191
234
|
declare module '@theme/DocPaginator' {
|
|
192
235
|
import type {PropNavigation} from '@docusaurus/plugin-content-docs';
|
|
193
236
|
|
|
@@ -242,7 +285,7 @@ declare module '@theme/DocSidebar/Desktop/Content' {
|
|
|
242
285
|
|
|
243
286
|
declare module '@theme/DocSidebar/Desktop/CollapseButton' {
|
|
244
287
|
export interface Props {
|
|
245
|
-
onClick: React.MouseEventHandler;
|
|
288
|
+
readonly onClick: React.MouseEventHandler;
|
|
246
289
|
}
|
|
247
290
|
|
|
248
291
|
export default function CollapseButton(props: Props): JSX.Element;
|
|
@@ -269,7 +312,7 @@ declare module '@theme/DocSidebarItem/Link' {
|
|
|
269
312
|
import type {PropSidebarItemLink} from '@docusaurus/plugin-content-docs';
|
|
270
313
|
|
|
271
314
|
export interface Props extends DocSidebarItemProps {
|
|
272
|
-
item: PropSidebarItemLink;
|
|
315
|
+
readonly item: PropSidebarItemLink;
|
|
273
316
|
}
|
|
274
317
|
|
|
275
318
|
export default function DocSidebarItemLink(props: Props): JSX.Element;
|
|
@@ -280,7 +323,7 @@ declare module '@theme/DocSidebarItem/Html' {
|
|
|
280
323
|
import type {PropSidebarItemHtml} from '@docusaurus/plugin-content-docs';
|
|
281
324
|
|
|
282
325
|
export interface Props extends DocSidebarItemProps {
|
|
283
|
-
item: PropSidebarItemHtml;
|
|
326
|
+
readonly item: PropSidebarItemHtml;
|
|
284
327
|
}
|
|
285
328
|
|
|
286
329
|
export default function DocSidebarItemHtml(props: Props): JSX.Element;
|
|
@@ -291,7 +334,7 @@ declare module '@theme/DocSidebarItem/Category' {
|
|
|
291
334
|
import type {PropSidebarItemCategory} from '@docusaurus/plugin-content-docs';
|
|
292
335
|
|
|
293
336
|
export interface Props extends DocSidebarItemProps {
|
|
294
|
-
item: PropSidebarItemCategory;
|
|
337
|
+
readonly item: PropSidebarItemCategory;
|
|
295
338
|
}
|
|
296
339
|
|
|
297
340
|
export default function DocSidebarItemCategory(props: Props): JSX.Element;
|
|
@@ -350,7 +393,7 @@ declare module '@theme/Footer/Logo' {
|
|
|
350
393
|
import type {FooterLogo} from '@docusaurus/theme-common';
|
|
351
394
|
|
|
352
395
|
export interface Props {
|
|
353
|
-
logo: FooterLogo;
|
|
396
|
+
readonly logo: FooterLogo;
|
|
354
397
|
}
|
|
355
398
|
|
|
356
399
|
export default function FooterLogo(props: Props): JSX.Element;
|
|
@@ -358,7 +401,7 @@ declare module '@theme/Footer/Logo' {
|
|
|
358
401
|
|
|
359
402
|
declare module '@theme/Footer/Copyright' {
|
|
360
403
|
export interface Props {
|
|
361
|
-
copyright: string;
|
|
404
|
+
readonly copyright: string;
|
|
362
405
|
}
|
|
363
406
|
|
|
364
407
|
export default function FooterCopyright(props: Props): JSX.Element;
|
|
@@ -368,7 +411,7 @@ declare module '@theme/Footer/LinkItem' {
|
|
|
368
411
|
import type {FooterLinkItem} from '@docusaurus/theme-common';
|
|
369
412
|
|
|
370
413
|
export interface Props {
|
|
371
|
-
item: FooterLinkItem;
|
|
414
|
+
readonly item: FooterLinkItem;
|
|
372
415
|
}
|
|
373
416
|
|
|
374
417
|
export default function FooterLinkItem(props: Props): JSX.Element;
|
|
@@ -378,10 +421,10 @@ declare module '@theme/Footer/Layout' {
|
|
|
378
421
|
import type {ReactNode} from 'react';
|
|
379
422
|
|
|
380
423
|
export interface Props {
|
|
381
|
-
style: 'light' | 'dark';
|
|
382
|
-
links: ReactNode;
|
|
383
|
-
logo: ReactNode;
|
|
384
|
-
copyright: ReactNode;
|
|
424
|
+
readonly style: 'light' | 'dark';
|
|
425
|
+
readonly links: ReactNode;
|
|
426
|
+
readonly logo: ReactNode;
|
|
427
|
+
readonly copyright: ReactNode;
|
|
385
428
|
}
|
|
386
429
|
|
|
387
430
|
export default function FooterLayout(props: Props): JSX.Element;
|
|
@@ -391,7 +434,7 @@ declare module '@theme/Footer/Links' {
|
|
|
391
434
|
import type {Footer} from '@docusaurus/theme-common';
|
|
392
435
|
|
|
393
436
|
export interface Props {
|
|
394
|
-
links: Footer['links'];
|
|
437
|
+
readonly links: Footer['links'];
|
|
395
438
|
}
|
|
396
439
|
|
|
397
440
|
export default function FooterLinks(props: Props): JSX.Element;
|
|
@@ -401,7 +444,7 @@ declare module '@theme/Footer/Links/MultiColumn' {
|
|
|
401
444
|
import type {MultiColumnFooter} from '@docusaurus/theme-common';
|
|
402
445
|
|
|
403
446
|
export interface Props {
|
|
404
|
-
columns: MultiColumnFooter['links'];
|
|
447
|
+
readonly columns: MultiColumnFooter['links'];
|
|
405
448
|
}
|
|
406
449
|
|
|
407
450
|
export default function FooterLinksMultiColumn(props: Props): JSX.Element;
|
|
@@ -411,7 +454,7 @@ declare module '@theme/Footer/Links/Simple' {
|
|
|
411
454
|
import type {SimpleFooter} from '@docusaurus/theme-common';
|
|
412
455
|
|
|
413
456
|
export interface Props {
|
|
414
|
-
links: SimpleFooter['links'];
|
|
457
|
+
readonly links: SimpleFooter['links'];
|
|
415
458
|
}
|
|
416
459
|
|
|
417
460
|
export default function FooterLinksSimple(props: Props): JSX.Element;
|
|
@@ -423,7 +466,7 @@ declare module '@theme/Heading' {
|
|
|
423
466
|
type HeadingType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
424
467
|
|
|
425
468
|
export interface Props extends ComponentProps<HeadingType> {
|
|
426
|
-
as: HeadingType;
|
|
469
|
+
readonly as: HeadingType;
|
|
427
470
|
}
|
|
428
471
|
|
|
429
472
|
export default function Heading(props: Props): JSX.Element;
|
|
@@ -625,9 +668,9 @@ declare module '@theme/Navbar/MobileSidebar/Layout' {
|
|
|
625
668
|
import type {ReactNode} from 'react';
|
|
626
669
|
|
|
627
670
|
interface Props {
|
|
628
|
-
header: ReactNode;
|
|
629
|
-
primaryMenu: ReactNode;
|
|
630
|
-
secondaryMenu: ReactNode;
|
|
671
|
+
readonly header: ReactNode;
|
|
672
|
+
readonly primaryMenu: ReactNode;
|
|
673
|
+
readonly secondaryMenu: ReactNode;
|
|
631
674
|
}
|
|
632
675
|
|
|
633
676
|
export default function NavbarMobileSidebarLayout(props: Props): JSX.Element;
|