File tree 11 files changed +97
-33
lines changed
packages/docusaurus-theme-classic/src/theme/DocCard
11 files changed +97
-33
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,6 @@ function isBlacklisted(pathname: string) {
55
55
'/tests/pages/react-18' ,
56
56
// Flaky because of hydration error
57
57
'/tests/blog/archive' ,
58
- '/tests/docs/tests/custom-props' ,
59
58
'/tests/pages/code-block-tests' ,
60
59
'/tests/pages/embeds' ,
61
60
// Flaky because of hydration error with docusaurus serve + .html
Original file line number Diff line number Diff line change @@ -43,34 +43,38 @@ function useCategoryItemsPlural() {
43
43
}
44
44
45
45
function CardContainer ( {
46
+ className,
46
47
href,
47
48
children,
48
49
} : {
50
+ className ?: string ;
49
51
href : string ;
50
52
children : ReactNode ;
51
53
} ) : ReactNode {
52
54
return (
53
55
< Link
54
56
href = { href }
55
- className = { clsx ( 'card padding--lg' , styles . cardContainer ) } >
57
+ className = { clsx ( 'card padding--lg' , styles . cardContainer , className ) } >
56
58
{ children }
57
59
</ Link >
58
60
) ;
59
61
}
60
62
61
63
function CardLayout ( {
64
+ className,
62
65
href,
63
66
icon,
64
67
title,
65
68
description,
66
69
} : {
70
+ className ?: string ;
67
71
href : string ;
68
72
icon : ReactNode ;
69
73
title : string ;
70
74
description ?: string ;
71
75
} ) : ReactNode {
72
76
return (
73
- < CardContainer href = { href } >
77
+ < CardContainer href = { href } className = { className } >
74
78
< Heading
75
79
as = "h2"
76
80
className = { clsx ( 'text--truncate' , styles . cardTitle ) }
@@ -99,6 +103,7 @@ function CardCategory({item}: {item: PropSidebarItemCategory}): ReactNode {
99
103
100
104
return (
101
105
< CardLayout
106
+ className = { item . className }
102
107
href = { href }
103
108
icon = "🗃️"
104
109
title = { item . label }
@@ -112,6 +117,7 @@ function CardLink({item}: {item: PropSidebarItemLink}): ReactNode {
112
117
const doc = useDocById ( item . docId ?? undefined ) ;
113
118
return (
114
119
< CardLayout
120
+ className = { item . className }
115
121
href = { item . href }
116
122
icon = { icon }
117
123
title = { item . label }
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ ---
2
+ sidebar_class_name : ' dogfood_sidebar_class_name_test'
3
+ ---
4
+
5
+ # Doc With Sidebar Class Name
6
+
7
+ This doc has ` sidebar_label ` front matter
Original file line number Diff line number Diff line change @@ -5,6 +5,6 @@ sidebar_custom_props:
5
5
boolean : true
6
6
---
7
7
8
- # Doc with Custom Props
8
+ # Doc With Custom Props
9
9
10
- This doc has custom props .
10
+ This doc has ` sidebar_custom_props ` front matter .
Original file line number Diff line number Diff line change
1
+ ---
2
+ sidebar_label : Doc With Sidebar Label
3
+ ---
4
+
5
+ # Doc with ` sidebar_label `
6
+
7
+ This doc has ` sidebar_label ` front matter
Original file line number Diff line number Diff line change
1
+ # Doc Without
2
+
3
+ This doc doesn't have any ` sidebar_ ` front matter
Original file line number Diff line number Diff line change
1
+ ---
2
+ sidebar_label : ' Sidebar Front Matter Tests'
3
+ sidebar_class_name : ' dogfood_sidebar_class_name_test'
4
+ ---
5
+
6
+ # Sidebar front matter
7
+
8
+ ``` mdx-code-block
9
+ import Link from '@docusaurus/Link';
10
+ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
11
+ import DocCardList from '@theme/DocCardList';
12
+
13
+ <DocCardList />
14
+
15
+ ---
16
+
17
+ ## Items table
18
+
19
+ export const DocPropsList = ({category}) => {
20
+ const items = [category, ...category.items];
21
+ return (
22
+ <table>
23
+ <thead>
24
+ <tr>
25
+ <th>
26
+ <code>type</code>
27
+ </th>
28
+ <th>
29
+ <code>label</code>
30
+ </th>
31
+ <th>
32
+ <code>customProps</code>
33
+ </th>
34
+ <th>
35
+ <code>className</code>
36
+ </th>
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
+ {items.map((item, index) => (
41
+ <tr key={index}>
42
+ <td>{item.type}</td>
43
+ <td>
44
+ <Link to={item.href}>{item.label}</Link>
45
+ </td>
46
+ <td>{JSON.stringify(item.customProps)}</td>
47
+ <td>{JSON.stringify(item.className)}</td>
48
+ </tr>
49
+ ))}
50
+ </tbody>
51
+ </table>
52
+ );
53
+ };
54
+
55
+ <DocPropsList category={useCurrentSidebarCategory()} />
56
+ ```
Original file line number Diff line number Diff line change @@ -24,6 +24,20 @@ html {
24
24
.navbar {
25
25
border-bottom : solid thin cyan;
26
26
}
27
+
28
+ .dogfood_sidebar_class_name_test {
29
+ & .theme-doc-sidebar-item-link > a {
30
+ color : cyan;
31
+ }
32
+
33
+ & .theme-doc-sidebar-item-category > div > a {
34
+ color : cyan;
35
+ }
36
+
37
+ & .card {
38
+ border : solid thin cyan;
39
+ }
40
+ }
27
41
}
28
42
29
43
& .plugin-blog .plugin-id-blog-tests {
You can’t perform that action at this time.
0 commit comments